nvim: Remove lsp-zero in favor of built-in lsp support
This commit is contained in:
parent
d5f92f0fb9
commit
585f1404b3
4 changed files with 78 additions and 64 deletions
19
_config/nvim/lsp/luals.lua
Normal file
19
_config/nvim/lsp/luals.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
return {
|
||||
-- Command and arguments to start the server.
|
||||
cmd = { 'lua-language-server' },
|
||||
-- Filetypes to automatically attach to.
|
||||
filetypes = { 'lua' },
|
||||
-- Sets the "workspace" to the directory where any of these files is found.
|
||||
-- Files that share a root directory will reuse the LSP server connection.
|
||||
-- Nested lists indicate equal priority, see |vim.lsp.Config|.
|
||||
root_markers = { { '.luarc.json', '.luarc.jsonc' }, '.git' },
|
||||
-- Specific settings to send to the server. The schema is server-defined.
|
||||
-- Example: https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,49 +1,58 @@
|
|||
vim.diagnostic.config({ virtual_text = true })
|
||||
vim.lsp.enable('ts_ls')
|
||||
vim.lsp.enable('luals')
|
||||
vim.lsp.enable('clangd')
|
||||
|
||||
local lsp = require('lsp-zero').preset({})
|
||||
-- LSP keymaps to mimic lsp-zero's defaults
|
||||
-- Source for lsp-zero defaults: see note at bottom
|
||||
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
-- see :help lsp-zero-keybindings
|
||||
-- to learn the available actions
|
||||
lsp.default_keymaps({buffer = bufnr})
|
||||
end)
|
||||
-- Create the autocommand once
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserLspKeymaps', { clear = true }),
|
||||
callback = function(ev)
|
||||
local buf = ev.buf
|
||||
|
||||
-- " (Optional) Configure lua language server for neovim
|
||||
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
||||
local function map(mode, lhs, rhs, desc)
|
||||
vim.keymap.set(mode, lhs, rhs, { buffer = buf, silent = true, noremap = true, desc = desc })
|
||||
end
|
||||
|
||||
-- Hover
|
||||
map('n', 'K', vim.lsp.buf.hover, 'LSP: Hover')
|
||||
|
||||
-- Go to...
|
||||
map('n', 'gd', vim.lsp.buf.definition, 'LSP: Go to Definition')
|
||||
map('n', 'gD', vim.lsp.buf.declaration, 'LSP: Go to Declaration')
|
||||
map('n', 'gi', vim.lsp.buf.implementation, 'LSP: Go to Implementation')
|
||||
map('n', 'go', vim.lsp.buf.type_definition, 'LSP: Go to Type Definition')
|
||||
map('n', 'gr', vim.lsp.buf.references, 'LSP: List References')
|
||||
|
||||
-- Signatures
|
||||
map('n', 'gs', vim.lsp.buf.signature_help, 'LSP: Signature Help')
|
||||
|
||||
-- Rename / Actions / Format (normal + visual)
|
||||
map('n', '<F2>', vim.lsp.buf.rename, 'LSP: Rename')
|
||||
map({ 'n', 'x' }, '<F3>', function()
|
||||
vim.lsp.buf.format({ async = false })
|
||||
end, 'LSP: Format')
|
||||
map({ 'n', 'x' }, '<F4>', vim.lsp.buf.code_action, 'LSP: Code Action')
|
||||
end,
|
||||
})
|
||||
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup {
|
||||
ensure_installed = { "rust_analyzer" },
|
||||
}
|
||||
|
||||
-- You need to setup `cmp` after lsp-zero
|
||||
local cmp = require('cmp')
|
||||
local cmp_action = require('lsp-zero').cmp_action()
|
||||
local cmp_nvim_lsp = require('cmp_nvim_lsp')
|
||||
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
-- `Enter` key to confirm completion
|
||||
['<CR>'] = cmp.mapping.confirm({select = false}),
|
||||
|
||||
-- Ctrl+Space to trigger completion menu
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
|
||||
-- Navigate between snippet placeholder
|
||||
['<C-f>'] = cmp_action.luasnip_jump_forward(),
|
||||
['<C-b>'] = cmp_action.luasnip_jump_backward(),
|
||||
}
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
||||
}),
|
||||
})
|
||||
|
||||
lsp.ensure_installed({
|
||||
'ts_ls',
|
||||
})
|
||||
|
||||
local null_ls = require('null-ls')
|
||||
local null_opts = lsp.build_options('null-ls', {})
|
||||
|
||||
null_ls.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
null_opts.on_attach(client, bufnr)
|
||||
--- you can add more stuff here if you need it
|
||||
end,
|
||||
sources = {
|
||||
null_ls.builtins.formatting.black,
|
||||
}
|
||||
})
|
||||
|
||||
lsp.setup()
|
||||
cmp_nvim_lsp.default_capabilities()
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
local rt = require("rust-tools")
|
||||
|
||||
rt.setup({
|
||||
server = {
|
||||
on_attach = function(_, bufnr)
|
||||
-- Hover actions
|
||||
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||
|
||||
-- Code action groups
|
||||
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
||||
end,
|
||||
},
|
||||
require('rust-tools').setup({
|
||||
server = {
|
||||
on_attach = function(_, bufnr)
|
||||
-- Example keymaps
|
||||
vim.keymap.set("n", "<C-space>", require("rust-tools").hover_actions.hover_actions, { buffer = bufnr })
|
||||
vim.keymap.set("n", "<Leader>a", require("rust-tools").code_action_group.code_action_group,
|
||||
{ buffer = bufnr })
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
|
|
@ -4,14 +4,7 @@ Plug 'tpope/vim-fugitive'
|
|||
Plug 'vim-syntastic/syntastic'
|
||||
Plug 'junegunn/fzf.vim'
|
||||
Plug 'tpope/vim-surround'
|
||||
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
|
||||
" Plug 'deoplete-plugins/deoplete-clang'
|
||||
" Plug 'deoplete-plugins/deoplete-jedi'
|
||||
" Plug 'deoplete-plugins/deoplete-go', { 'do': 'make'}
|
||||
" Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install tern'}
|
||||
" Plug 'tbodt/deoplete-tabnine', { 'do': './install.sh' }
|
||||
Plug 'mg979/vim-visual-multi'
|
||||
" Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
||||
" Plug 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' }
|
||||
Plug 'luochen1990/rainbow'
|
||||
" Plug 'wlangstroth/vim-racket'
|
||||
|
@ -24,18 +17,14 @@ Plug 'neovim/nvim-lspconfig'
|
|||
Plug 'williamboman/mason.nvim'
|
||||
Plug 'williamboman/mason-lspconfig.nvim'
|
||||
|
||||
Plug 'nvim-lua/plenary.nvim'
|
||||
Plug 'nvimtools/none-ls.nvim'
|
||||
|
||||
" Autocompletion
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
Plug 'L3MON4D3/LuaSnip'
|
||||
|
||||
Plug 'VonHeikemen/lsp-zero.nvim', {'branch': 'v2.x'}
|
||||
|
||||
Plug 'simrat39/rust-tools.nvim'
|
||||
|
||||
" Debugging
|
||||
Plug 'mfussenegger/nvim-dap'
|
||||
Plug 'rcarriga/nvim-dap-ui'
|
||||
Plug 'nvim-neotest/nvim-nio'
|
||||
|
|
Loading…
Add table
Reference in a new issue