nvim: Add experimental navigator lsp configurator
This commit is contained in:
parent
ff0ddb2b2d
commit
d5cd91d107
2 changed files with 79 additions and 158 deletions
|
@ -1,12 +1,6 @@
|
||||||
local api = vim.api
|
|
||||||
|
|
||||||
local saga = require 'lspsaga'
|
|
||||||
local lspcfg = require 'lspconfig'
|
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local lspkind = require 'lspkind'
|
local lspkind = require 'lspkind'
|
||||||
|
|
||||||
require"lsp_signature".setup()
|
|
||||||
|
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
return col ~= 0 and
|
return col ~= 0 and
|
||||||
|
@ -20,12 +14,6 @@ local feedkey = function(key, mode)
|
||||||
mode, true)
|
mode, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Enable the following language servers
|
|
||||||
local servers = {
|
|
||||||
'bashls', 'gopls', 'texlab', 'pyright', 'rust_analyzer', 'tsserver', 'vimls'
|
|
||||||
-- sumneko_lua further down, needs more setup
|
|
||||||
}
|
|
||||||
|
|
||||||
vim.o.completeopt = "menu,menuone,noselect"
|
vim.o.completeopt = "menu,menuone,noselect"
|
||||||
|
|
||||||
-- completion items
|
-- completion items
|
||||||
|
@ -93,86 +81,46 @@ cmp.setup.cmdline(':', {
|
||||||
sources = cmp.config.sources({{name = 'path'}}, {{name = 'cmdline'}})
|
sources = cmp.config.sources({{name = 'path'}}, {{name = 'cmdline'}})
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Setup lspconfig.
|
require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol
|
||||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp
|
|
||||||
.protocol
|
|
||||||
.make_client_capabilities())
|
.make_client_capabilities())
|
||||||
|
|
||||||
local on_attach = function(_, _)
|
-- requires the lua-language-server package to be installed
|
||||||
-- Keybindings for LSPs
|
-- The arch package defaults to the following directory
|
||||||
-- Note these are in on_attach so that they don't override bindings in a non-LSP setting
|
local sumneko_root_path = "/usr/share/lua-language-server"
|
||||||
api.nvim_set_keymap("n", "gh",
|
require'navigator'.setup({
|
||||||
"<cmd>lua require 'lspsaga.provider'.lsp_finder()<CR>",
|
lsp = {
|
||||||
{noremap = true, silent = true})
|
servers = {'efm'},
|
||||||
api.nvim_set_keymap("n", "gd",
|
sumneko_lua = {
|
||||||
"<cmd>lua require'lspsaga.provider'.preview_definition()<CR>",
|
cmd = {
|
||||||
{noremap = true, silent = true})
|
"lua-language-server", "-E", sumneko_root_path .. "/main.lua"
|
||||||
api.nvim_set_keymap("n", "gE",
|
|
||||||
"<cmd>lua require 'lspsaga.codeaction'.code_action()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("v", "gE",
|
|
||||||
"<cmd>'<,'>lua require 'lspsaga.codeaction'.range_code_action()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "K",
|
|
||||||
"<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "gK",
|
|
||||||
"<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "gr",
|
|
||||||
"<cmd>lua require('lspsaga.rename').rename()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
|
|
||||||
api.nvim_set_keymap("n", "ge",
|
|
||||||
"<cmd>lua require('lspsaga.diagnostic').show_line_diagnostics()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "]e",
|
|
||||||
"<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_next()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "[e",
|
|
||||||
"<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_prev()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
|
|
||||||
api.nvim_set_keymap("n", "C-f",
|
|
||||||
"<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "C-b",
|
|
||||||
"<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
|
|
||||||
require("lspsaga").init_lsp_saga {
|
|
||||||
error_sign = 'X',
|
|
||||||
warn_sign = '⚠️',
|
|
||||||
hint_sign = '⚡',
|
|
||||||
infor_sign = 'ℹ️',
|
|
||||||
-- code_action_icon = '●',
|
|
||||||
finder_definition_icon = '📖 ',
|
|
||||||
finder_reference_icon = '🔖 ',
|
|
||||||
definition_preview_icon = '📖 ',
|
|
||||||
finder_action_keys = {
|
|
||||||
open = '<cr>',
|
|
||||||
split = 's',
|
|
||||||
vsplit = 'v',
|
|
||||||
quit = '<esc>',
|
|
||||||
scroll_down = '<c-f>',
|
|
||||||
scroll_up = '<c-b>'
|
|
||||||
},
|
},
|
||||||
code_action_keys = {quit = '<esc>', exec = '<cr>'},
|
settings = {
|
||||||
rename_action_keys = {quit = '<esc>', exec = '<cr>'}
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||||
|
version = 'LuaJIT',
|
||||||
|
-- Setup your lua path
|
||||||
|
path = vim.split(package.path, ';')
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
-- Get the language server to recognize additional globals
|
||||||
|
globals = {
|
||||||
|
'vim', 'before_each', 'after_each', 'describe',
|
||||||
|
'it', 'mock', 'stub'
|
||||||
}
|
}
|
||||||
vim.cmd("command! LspHover lua vim.lsp.buf.hover()<CR>")
|
},
|
||||||
vim.cmd(
|
workspace = {
|
||||||
"command! LspDisable lua vim.lsp.stop_client(vim.lsp.get_active_clients())<CR>")
|
-- Make the server aware of additional runtime files
|
||||||
print('LSP ready')
|
library = {
|
||||||
end
|
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
|
||||||
|
[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true,
|
||||||
-- set up simple servers
|
["/usr/share/lua/5.1/busted/"] = true
|
||||||
for _, lsp in ipairs(servers) do
|
}
|
||||||
lspcfg[lsp].setup {on_attach = on_attach, capabilities = capabilities}
|
}
|
||||||
end
|
}
|
||||||
|
}
|
||||||
lspcfg.efm.setup {
|
},
|
||||||
on_attach = on_attach,
|
efm = {
|
||||||
init_options = {
|
init_options = {
|
||||||
documentFormatting = true,
|
documentFormatting = true,
|
||||||
codeAction = true,
|
codeAction = true,
|
||||||
|
@ -188,46 +136,16 @@ lspcfg.efm.setup {
|
||||||
{
|
{
|
||||||
lintCommand = 'shellcheck -f gcc -x',
|
lintCommand = 'shellcheck -f gcc -x',
|
||||||
lintFormats = {
|
lintFormats = {
|
||||||
'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m',
|
'%f:%l:%c: %trror: %m',
|
||||||
'%f:%l:%c: %tote: %m'
|
'%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'
|
||||||
}
|
}
|
||||||
}, {formatCommand = 'shfmt -ci -s -bn', formatStdin = true}
|
},
|
||||||
|
{formatCommand = 'shfmt -ci -s -bn', formatStdin = true}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- requires the lua-language-server package to be installed
|
|
||||||
-- The arch package defaults to the following directory
|
|
||||||
local sumneko_root_path = "/usr/share/lua-language-server"
|
|
||||||
lspcfg.sumneko_lua.setup {
|
|
||||||
cmd = {"lua-language-server", "-E", sumneko_root_path .. "/main.lua"},
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
runtime = {
|
|
||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
||||||
version = 'LuaJIT',
|
|
||||||
-- Setup your lua path
|
|
||||||
path = vim.split(package.path, ';')
|
|
||||||
},
|
|
||||||
diagnostics = {
|
|
||||||
-- Get the language server to recognize additional globals
|
|
||||||
globals = {
|
|
||||||
'vim', 'before_each', 'after_each', 'describe', 'it',
|
|
||||||
'mock', 'stub'
|
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
workspace = {
|
require"lsp_signature".setup()
|
||||||
-- Make the server aware of additional runtime files
|
|
||||||
library = {
|
|
||||||
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
|
|
||||||
[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true,
|
|
||||||
["/usr/share/lua/5.1/busted/"] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
on_attach = on_attach
|
|
||||||
}
|
|
||||||
|
|
||||||
saga.init_lsp_saga()
|
|
||||||
|
|
|
@ -170,29 +170,10 @@ require("packer").startup(function()
|
||||||
use "nvim-telescope/telescope-fzy-native.nvim"
|
use "nvim-telescope/telescope-fzy-native.nvim"
|
||||||
use "nvim-telescope/telescope-fzf-writer.nvim"
|
use "nvim-telescope/telescope-fzf-writer.nvim"
|
||||||
|
|
||||||
-- lsp
|
|
||||||
use 'neovim/nvim-lspconfig' -- some commong language server configurations
|
|
||||||
use 'tami5/lspsaga.nvim' -- nice and fast ui for lsp actions WILL HAVE TO BE REPLACED SOON
|
|
||||||
use 'simrat39/symbols-outline.nvim' -- vista-like outline view for code
|
|
||||||
use 'ray-x/lsp_signature.nvim'
|
|
||||||
-- and completion
|
|
||||||
use {
|
|
||||||
'hrsh7th/nvim-cmp', -- simple completion engine built specifically for nvim and lsp
|
|
||||||
requires = {
|
|
||||||
'onsails/lspkind-nvim', 'andersevenrud/cmp-tmux', -- completion source from adjacent tmux panes
|
|
||||||
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-path',
|
|
||||||
'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-vsnip',
|
|
||||||
'kdheepak/cmp-latex-symbols', 'ray-x/cmp-treesitter',
|
|
||||||
'f3fora/cmp-spell', 'jc-doyle/cmp-pandoc-references',
|
|
||||||
'cbarrete/completion-vcard'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-- snippeting
|
-- snippeting
|
||||||
use {"hrsh7th/vim-vsnip", event = "InsertEnter"} -- snippet engine
|
use {"hrsh7th/vim-vsnip", event = "InsertEnter"} -- snippet engine
|
||||||
use {"rafamadriz/friendly-snippets", event = "InsertEnter"} -- many snippets
|
use {"rafamadriz/friendly-snippets", event = "InsertEnter"} -- many snippets
|
||||||
|
|
||||||
require('plug._lsp')
|
|
||||||
|
|
||||||
-- treesitter
|
-- treesitter
|
||||||
use {
|
use {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
@ -222,4 +203,26 @@ require("packer").startup(function()
|
||||||
config = function() require('spellsitter').setup() end
|
config = function() require('spellsitter').setup() end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- lsp
|
||||||
|
use 'neovim/nvim-lspconfig' -- some commong language server configurations
|
||||||
|
use 'simrat39/symbols-outline.nvim' -- vista-like outline view for code
|
||||||
|
use 'ray-x/lsp_signature.nvim'
|
||||||
|
use {
|
||||||
|
'ray-x/navigator.lua',
|
||||||
|
requires = {'ray-x/guihua.lua', run = 'cd lua/fzy && make'}
|
||||||
|
}
|
||||||
|
-- and completion
|
||||||
|
use {
|
||||||
|
'hrsh7th/nvim-cmp', -- simple completion engine built specifically for nvim and lsp
|
||||||
|
requires = {
|
||||||
|
'onsails/lspkind-nvim', 'andersevenrud/cmp-tmux', -- completion source from adjacent tmux panes
|
||||||
|
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-path',
|
||||||
|
'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-vsnip',
|
||||||
|
'kdheepak/cmp-latex-symbols', 'ray-x/cmp-treesitter',
|
||||||
|
'f3fora/cmp-spell', 'jc-doyle/cmp-pandoc-references',
|
||||||
|
'cbarrete/completion-vcard'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require('plug._lsp')
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue