return { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs and related tools to stdpath for neovim 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', -- Useful status updates for LSP. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { 'j-hui/fidget.nvim', opts = {} }, }, config = function() vim.api.nvim_create_autocmd('LspAttach', { callback = function(event) local map = function(keys, func, desc) vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end -- map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') map('gd', function() vim.lsp.buf.definition() end, '[G]oto [D]efinition') -- map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') -- map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- map('rn', vim.lsp.buf.rename, '[R]e[n]ame') -- map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') -- map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') map('bf', vim.lsp.buf.format, '[B]uffer [F]ormat') -- The following two autocommands are used to highlight references of the -- word under your cursor when your cursor rests there for a little while. -- See `:help CursorHold` for information about when this is executed -- -- When you move your cursor, the highlights will be cleared (the second autocommand). local client = vim.lsp.get_client_by_id(event.data.client_id) if client and client.server_capabilities.documentHighlightProvider then vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, callback = vim.lsp.buf.document_highlight, }) vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { buffer = event.buf, callback = vim.lsp.buf.clear_references, }) end -- autoformat vim.api.nvim_create_autocmd("BufWritePre", { buffer = event.buf, callback = function() vim.lsp.buf.format { async = false, id = event.data.client_id } end, }) end, }) -- Ensure the servers and tools above are installed -- To check the current status of installed tools and/or manually install -- other tools, you can run -- :Mason -- -- You can press `g?` for help in this menu require('mason').setup() -- You can add other tools here that you want Mason to install -- for you, so that they are available from within Neovim. require('mason-tool-installer').setup {} require('mason-lspconfig').setup {} vim.lsp.config("lua_ls", { settings = { Lua = { -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings -- diagnostics = { disable = { 'missing-fields' } }, diagnostics = { globals = { "vim", "require" } }, workspace = { library = { [vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.stdpath("config") .. "/lua"] = true } } }, } }) -- local vue_path = vim.fn.stdpath("data") .. -- "/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@vue/typescript-plugin" local vue_path = vim.fn.stdpath("data") .. "/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@vue/typescript-plugin" vim.lsp.config('ts_ls', { init_options = { plugins = { { name = "@vue/typescript-plugin", -- location = vim.fn.stdpath("data") .. "/erikcustom/language-tools/packages/typescript-plugin", -- /mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@vue/typescript-plugin location = vue_path, languages = { "javascript", "typescript", "vue" }, }, }, settings = { typescript = { tsserver = { useSyntaxServer = false, }, inlayHints = { includeInlayParameterNameHints = 'all', includeInlayParameterNameHintsWhenArgumentMatchesName = true, includeInlayFunctionParameterTypeHints = true, includeInlayVariableTypeHints = true, includeInlayVariableTypeHintsWhenTypeMatchesName = true, includeInlayPropertyDeclarationTypeHints = true, includeInlayFunctionLikeReturnTypeHints = true, includeInlayEnumMemberValueHints = true, }, }, }, }, filetypes = { "javascript", "typescript", "vue", }, }) end, }