-- local ih = require("inlay-hints") require('neodev').setup() -- vim.lsp.ensure_installed({ -- "clangd", -- "gopls", -- "jdtls", -- "eslint", -- "tailwindcss", -- "tsserver", -- "cssmodules_ls", -- "rome", -- "jsonls", -- "sumneko_lua", -- "pylsp", -- "rust_analyzer", -- "stylelint_lsp", -- }) local navic = require("nvim-navic") navic.setup { icons = { File = " ", Module = " ", Namespace = " ", Package = " ", Class = " ", Method = " ", Property = " ", Field = " ", Constructor = " ", Enum = "練", Interface = "練", Function = " ", Variable = " ", Constant = " ", String = " ", Number = " ", Boolean = "◩ ", Array = " ", Object = " ", Key = " ", Null = "ﳠ ", EnumMember = " ", Struct = " ", Event = " ", Operator = " ", TypeParameter = " ", }, highlight = false, separator = " > ", depth_limit = 0, depth_limit_indicator = "..", safe_output = true } local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) local on_attach = function(client, bufnr) local nmap = function(keys, func, desc) if desc then desc = 'LSP: ' .. desc end vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) end -- ih.on_attach(client, bufnr) require("lsp-inlayhints").on_attach(client, bufnr) if client.server_capabilities.documentSymbolProvider then navic.attach(client, bufnr) require("nvim-navbuddy").attach(client, bufnr) end nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') -- Lesser used LSP functionality nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') -- Create a command `:Format` local to the LSP buffer vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) vim.lsp.buf.format() end, { desc = 'Format current buffer with LSP' }) -- format on save autocmd if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) vim.api.nvim_create_autocmd("BufWritePre", { group = augroup, buffer = bufnr, callback = function() -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead -- on later neovim version, you should use vim.lsp.buf.format({ async = false }) instead -- vim.lsp.buf.formatting_sync() --vim.lsp.buf.format({async = false, bufnr = bufnr, filter = function(client) return client.name == "null-ls" end}) vim.lsp.buf.format({async = false, bufnr = bufnr}) end, }) end end local servers = { -- sumneko_lua = { -- Lua = { -- workspace = { checkThirdParty = false }, -- telemetry = { enable = false }, -- }, -- }, } local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) capabilities.offsetEncoding = { "utf-16" } -- fix copilot require('mason').setup() require("mason-nvim-dap").setup({automatic_installation = true, handlers = { function (config) require("mason-nvim-dap").default_setup(config) end }}) local mason_lspconfig = require 'mason-lspconfig' mason_lspconfig.setup { ensure_installed = vim.tbl_keys(servers), } mason_lspconfig.setup_handlers { function(server_name) require('lspconfig')[server_name].setup { capabilities = capabilities, on_attach = on_attach, settings = servers[server_name], } end, } -- require("lspconfig").rust_analyzer.setup{ -- capabilities = capabilities, -- on_attach = on_attach, -- settings = { -- -- ["rust-analyzer"] = { -- cargo = { -- features = "all" -- }, -- inlayHints = { -- closyreCaptureHints = { -- enable = true, -- }, -- }, -- check = { -- command = "clippy", -- features = "all", -- }, -- imports = { -- preferPrelude = true, -- } -- -- }, -- }, -- } require("lspconfig").zls.setup{ cmd = {"zls"}, on_attach = on_attach, } require("lspconfig").tailwindcss.setup { filetypes = { "astro", "astro-markdown", "clojure", "django-html", "htmldjango", "edge", "eelixir", "elixir", "ejs", "erb", "eruby", "gohtml", "haml", "handlebars", "hbs", "html", "html-eex", "heex", "jade", "leaf", "liquid", "markdown", "mdx", "mustache", "njk", "nunjucks", "php", "razor", "slim", "twig", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte", "rust", "fsharp", }, init_options = { userLanguages = { rust = "html", fsharp = "html", }, }, root_dir = require("lspconfig").util.root_pattern("tailwind.config.cjs", "tailwind.config.mjs", "tailwind.config.js", "tailwind.config.ts"), settings = { tailwindCSS = { --files = {exclude = ""}, classAttributes = { "class", "className", "class:list", "classList", "ngClass", "classes" }, lint = { cssConflict = "warning", invalidApply = "error", invalidConfigPath = "error", invalidScreen = "error", invalidTailwindDirective = "error", invalidVariant = "error", recommendedVariantOrder = "warning" }, validate = true } } } require("lspconfig").gleam.setup({}) -- lspinfo require('fidget').setup() local cmp_autopairs = require('nvim-autopairs.completion.cmp') local cmp = require 'cmp' -- local luasnip = require 'luasnip' cmp.setup { -- snippet = { -- expand = function(args) -- luasnip.lsp_expand(args.body) -- end, -- }, mapping = cmp.mapping.preset.insert { -- [""] = cmp.mapping.confirm({ slelect = true}), [""] = cmp.mapping.complete({}), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() -- elseif luasnip.expand_or_jumpable() then -- luasnip.expand_or_jump() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() -- elseif luasnip.jumpable(-1) then -- luasnip.jump(-1) else fallback() end end, { 'i', 's' }), }, sources = { { name = 'nvim_lsp' }, -- { name = 'luasnip' }, { name = "crates" }, { name = 'orgmode' }, }, } cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done() ) vim.diagnostic.config({ signs = true, underline = true, update_in_insert = true, virtual_text = true, }) -- require("luasnip.loaders.from_vscode").lazy_load() -- require("luasnip.loaders.from_snipmate").lazy_load()