nvim: Move to treesitter and lspsaga
Added lspsaga to enhance some of the lsp actions I can do - mappings are mostly the same as before, pretty much all lsp actions can be invoked by g<mnemonic> (e.g. `gr` for rename, `gh` for symbol help, `gd` for go definition, `K` for help hover, `gc` for code completion and some more). `[e` and `]e` move between lsp diagnostic errors. Switched out many syntax highlighting plugins for treesitter, which is an experiment for now, but I would love to keep it like this if it works out.
This commit is contained in:
parent
41bfe2df69
commit
9a6fd3fa04
4 changed files with 67 additions and 22 deletions
8
nvim/.config/nvim/lua/_treesitter.lua
Normal file
8
nvim/.config/nvim/lua/_treesitter.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
require'nvim-treesitter.configs'.setup {
|
||||
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||
ensure_installed = "maintained",
|
||||
highlight = { enable = true },
|
||||
incremental_selection = { enable = true },
|
||||
textobjects = { enable = true },
|
||||
indent = { enable = true },
|
||||
}
|
|
@ -1,27 +1,62 @@
|
|||
local on_attach = function(client, bufnr)
|
||||
local saga = require 'lspsaga'
|
||||
|
||||
|
||||
local on_attach = function(_, _)
|
||||
-- Keybindings for LSPs
|
||||
-- Note these are in on_attach so that they don't override bindings in a non-LSP setting
|
||||
vim.fn.nvim_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>",
|
||||
vim.api.nvim_set_keymap("n", "gh", "<cmd>lua require 'lspsaga.provider'.lsp_finder()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.fn.nvim_set_keymap("n", "gD",
|
||||
"<cmd>lua vim.lsp.buf.implementation()<CR>",
|
||||
vim.api.nvim_set_keymap("n", "gd", "<cmd>lua require'lspsaga.provider'.preview_definition()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.fn.nvim_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>",
|
||||
vim.api.nvim_set_keymap("n", "gc", "<cmd>lua require 'lspsaga.codeaction'.code_action()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.fn.nvim_set_keymap("n", "gK",
|
||||
"<cmd>lua vim.lsp.buf.signature_help()<CR>",
|
||||
vim.api.nvim_set_keymap("v", "gc", "<cmd>'<,'>lua require 'lspsaga.codeaction'.range_code_action()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.fn.nvim_set_keymap("n", "1gD",
|
||||
"<cmd>lua vim.lsp.buf.type_definition()<CR>",
|
||||
vim.api.nvim_set_keymap("n", "K", "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.fn.nvim_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>",
|
||||
vim.api.nvim_set_keymap("n", "gK", "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.fn.nvim_set_keymap("n", "g0",
|
||||
"<cmd>lua vim.lsp.buf.document_symbol()<CR>",
|
||||
vim.api.nvim_set_keymap("n", "gr", "<cmd>lua require('lspsaga.rename').rename()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.fn.nvim_set_keymap("n", "gW",
|
||||
"<cmd>lua vim.lsp.buf.workspace_symbol()<CR>",
|
||||
|
||||
vim.api.nvim_set_keymap("n", "ge", "<cmd>lua require('lspsaga.diagnostic').show_line_diagnostics()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap("n", "[e", "<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_next()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap("n", "]e", "<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_prev()<CR>",
|
||||
{noremap = true, silent = true})
|
||||
|
||||
vim.api.nvim_set_keymap("n", "C-f", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>",
|
||||
{noremap = true, silent = true})
|
||||
vim.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 = '🔖 ',
|
||||
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>'
|
||||
},
|
||||
rename_action_keys = {
|
||||
quit = '<esc>',
|
||||
exec = '<cr>'
|
||||
},
|
||||
definition_preview_icon = '📖 '
|
||||
}
|
||||
end
|
||||
|
||||
require'lspconfig'.pyls.setup {on_attach = on_attach}
|
||||
|
@ -58,3 +93,4 @@ require'lspconfig'.sumneko_lua.setup {
|
|||
},
|
||||
on_attach = on_attach,
|
||||
}
|
||||
saga.init_lsp_saga()
|
||||
|
|
|
@ -64,7 +64,7 @@ let g:completion_chain_complete_list = {
|
|||
\ { 'mode': '<c-n>'}
|
||||
\],
|
||||
\ 'default': [
|
||||
\ { 'complete_items': [ 'lsp', 'snippet' ]},
|
||||
\ { 'complete_items': [ 'ts', 'lsp', 'snippet' ]},
|
||||
\ { 'complete_items': [ 'buffers' ] },
|
||||
\ { 'complete_items': [ 'path' ], 'triggered_only': ['/'] },
|
||||
\ { 'mode': '<c-p>'},
|
||||
|
|
|
@ -40,10 +40,17 @@ Plug 'junegunn/vim-peekaboo'
|
|||
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
|
||||
Plug 'junegunn/fzf.vim'
|
||||
|
||||
" neovim goodies: treesitter and lsp
|
||||
Plug 'neovim/nvim-lspconfig' " some commong language server configurations
|
||||
Plug 'glepnir/lspsaga.nvim' " nice and fast ui for lsp actions
|
||||
|
||||
Plug 'nvim-lua/completion-nvim' " simple completion engine built specifically for nvim and lsp
|
||||
Plug 'steelsojka/completion-buffers' " completion source from words found in current buffers
|
||||
|
||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||
Plug 'nvim-treesitter/completion-treesitter'
|
||||
|
||||
|
||||
Plug 'desmap/ale-sensible' | Plug 'w0rp/ale' " asynchronous linting - might be superseded by lsp or coc.nvim at some point
|
||||
" statusline
|
||||
Plug 'vim-airline/vim-airline'
|
||||
|
@ -71,12 +78,6 @@ Plug 'junegunn/goyo.vim', { 'for': ['pandoc', 'markdown', 'txt'], 'on': 'Goyo' }
|
|||
Plug 'junegunn/limelight.vim', { 'for': ['pandoc', 'markdown', 'txt'], 'on': 'Goyo' } " provide even distraction free-er writing (lowlight paragraphs)
|
||||
" Language Integration
|
||||
Plug 'euclidianAce/BetterLua.vim' " better syntax highlighting for lua
|
||||
Plug 'sheerun/vim-polyglot' " syntax plugins for almost every language
|
||||
Plug 'stephpy/vim-yaml'
|
||||
Plug 'mhartington/nvim-typescript', {'for': 'typescript','do': './install.sh'}
|
||||
|
||||
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
||||
Plug 'aliou/bats.vim'
|
||||
|
||||
if !has('nvim')
|
||||
Plug 'tpope/vim-sensible'
|
||||
|
|
Loading…
Reference in a new issue