You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
3.6 KiB
125 lines
3.6 KiB
vim.pack.add {
|
|
{ src = 'https://github.com/neovim/nvim-lspconfig' },
|
|
}
|
|
|
|
local on_attach = function(_, bufnr)
|
|
local opts = { buffer = bufnr, remap = false }
|
|
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
|
vim.keymap.set("n", "<leader>k", function() vim.lsp.buf.hover() end, opts)
|
|
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
|
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
|
vim.keymap.set("n", "[d", function() vim.lsp.diagnostics.goto_next() end, opts)
|
|
vim.keymap.set("n", "]d", function() vim.lsp.diagnostic.goto_prev() end, opts)
|
|
vim.keymap.set("n", "<leader>ca", function() vim.lsp.buf.code_action() end, opts)
|
|
vim.keymap.set("n", "gr", function() vim.lsp.buf.references() end, opts)
|
|
vim.keymap.set("n", "<leader>rn", function() vim.lsp.buf.rename() end, opts)
|
|
vim.keymap.set("i", "<C-k>", function() vim.lsp.buf.signature_help() end, opts)
|
|
vim.keymap.set("n", "<leader>fo", function() vim.lsp.buf.format() end, opts)
|
|
vim.keymap.set('n', '<Leader>D', vim.lsp.buf.type_definition, opts)
|
|
vim.keymap.set('n', '<Leader>e', vim.diagnostic.open_float, opts)
|
|
end
|
|
|
|
vim.lsp.config['rust_analyser'] = {
|
|
-- capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
filetypes = { 'rust' },
|
|
settings = {
|
|
['rust-analyzer'] = {
|
|
checkOnSave = {
|
|
allFeatures = true,
|
|
overrideCommand = {
|
|
'cargo', 'clippy', '--workspace', '--message-format=json',
|
|
'--all-targets', '--all-features'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
vim.lsp.enable('rust_analyser')
|
|
|
|
vim.lsp.config['lua_ls'] = {
|
|
on_attach = on_attach,
|
|
filetypes = { 'lua' },
|
|
-- capabilities = capabilities,
|
|
settings = {
|
|
Lua = {
|
|
runtime = {
|
|
version = 'LuaJIT',
|
|
},
|
|
diagnostics = {
|
|
globals = { 'vim' },
|
|
},
|
|
workspace = {
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
},
|
|
telemetry = {
|
|
enable = false,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
vim.lsp.enable('lua_ls')
|
|
|
|
vim.lsp.config['pyright'] = {
|
|
-- capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
}
|
|
vim.lsp.enable('pyright')
|
|
|
|
vim.lsp.config['bashls'] = {
|
|
-- capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
}
|
|
vim.lsp.enable('bashls')
|
|
|
|
vim.lsp.config['clangd'] = {
|
|
-- capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
}
|
|
vim.lsp.enable('clangd')
|
|
|
|
local tsserver_filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }
|
|
local global_node_modules = vim.fn.system("npm root -g"):gsub("%s+", "")
|
|
local vue_language_server_path = global_node_modules .. '/@vue/language-server'
|
|
|
|
local vue_plugin = {
|
|
name = '@vue/typescript-plugin',
|
|
location = vue_language_server_path,
|
|
languages = { 'vue' },
|
|
configNamespace = 'typescript',
|
|
}
|
|
|
|
vim.lsp.config['ts_ls'] = {
|
|
init_options = {
|
|
plugins = {
|
|
vue_plugin,
|
|
},
|
|
},
|
|
filetypes = tsserver_filetypes,
|
|
on_attach = on_attach,
|
|
}
|
|
|
|
vim.lsp.config['vtsls'] = {
|
|
on_attach = on_attach,
|
|
settings = {
|
|
vtsls = {
|
|
tsserver = {
|
|
globalPlugins = {
|
|
vue_plugin,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
filetypes = tsserver_filetypes,
|
|
}
|
|
|
|
|
|
vim.lsp.config['vue_ls'] = {
|
|
filetypes = tsserver_filetypes,
|
|
-- capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
}
|
|
vim.lsp.enable({ 'vtsls', 'vue_ls' })
|