mirror of
https://github.com/elkowar/dots-of-war.git
synced 2024-11-06 03:12:24 +00:00
set up nvim-lsp
This commit is contained in:
parent
1681b4fd09
commit
a23e8836f3
4 changed files with 205 additions and 27 deletions
23
init.vim
23
init.vim
|
@ -207,7 +207,12 @@ au Syntax * RainbowParenthesesLoadSquare
|
||||||
au Syntax * RainbowParenthesesLoadBraces
|
au Syntax * RainbowParenthesesLoadBraces
|
||||||
|
|
||||||
|
|
||||||
nnoremap <silent> <C-p> :Files<CR>
|
"nnoremap <silent> <C-p> :Files<CR>
|
||||||
|
nnoremap <silent> <C-p> :Telescope find_files<CR>
|
||||||
|
|
||||||
|
|
||||||
|
lua require('telescope').load_extension('media_files')
|
||||||
|
|
||||||
|
|
||||||
"map <Leader>f <Plug>(easymotion-bd-f)
|
"map <Leader>f <Plug>(easymotion-bd-f)
|
||||||
"map <Leader>s <Plug>(easymotion-overwin-f2)
|
"map <Leader>s <Plug>(easymotion-overwin-f2)
|
||||||
|
@ -344,5 +349,19 @@ nnoremap ö a
|
||||||
|
|
||||||
|
|
||||||
source $VIM_ROOT/whichkeyConfig.vim
|
source $VIM_ROOT/whichkeyConfig.vim
|
||||||
source $VIM_ROOT/lsp.vim
|
|
||||||
|
|
||||||
|
luafile $VIM_ROOT/lsp.lua
|
||||||
|
"source $VIM_ROOT/lsp.vim
|
||||||
|
|
||||||
|
|
||||||
|
" this is apparently necessary for nvim-lsp stuff
|
||||||
|
set completeopt=menuone,noselect
|
||||||
|
|
||||||
|
|
||||||
|
inoremap <silent><expr> <C-Space> compe#complete()
|
||||||
|
inoremap <silent><expr> <CR> compe#confirm('<CR>')
|
||||||
|
inoremap <silent><expr> <esc> compe#close('<esc>')
|
||||||
|
|
||||||
|
|
||||||
|
"nnoremap <silent> <C-d> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>
|
||||||
|
"nnoremap <silent> <C-u> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>
|
||||||
|
|
96
lsp.lua
Normal file
96
lsp.lua
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
|
||||||
|
|
||||||
|
local lsp = require('lspconfig')
|
||||||
|
local util = lsp.util
|
||||||
|
local saga = require('lspsaga')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
if client.resolved_capabilities.document_highlight then
|
||||||
|
vim.api.nvim_exec([[
|
||||||
|
hi LspReferenceRead cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828'
|
||||||
|
hi LspReferenceText cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828'
|
||||||
|
hi LspReferenceWrite cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828'
|
||||||
|
augroup lsp_document_highlight
|
||||||
|
autocmd! * <buffer>
|
||||||
|
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||||
|
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||||
|
augroup END
|
||||||
|
]], false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
lsp.rust_analyzer.setup { on_attach = on_attach }
|
||||||
|
lsp.jsonls.setup { on_attach = on_attach }
|
||||||
|
lsp.vimls.setup { on_attach = on_attach }
|
||||||
|
lsp.tsserver.setup { on_attach = on_attach }
|
||||||
|
lsp.bashls.setup { on_attach = on_attach }
|
||||||
|
lsp.html.setup { on_attach = on_attach }
|
||||||
|
|
||||||
|
lsp.denols.setup {
|
||||||
|
root_dir = lsp.util.root_pattern(".git");
|
||||||
|
on_attach = on_attach
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lsp.hls.setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = {
|
||||||
|
languageServerHaskell = {
|
||||||
|
formattingProvider = "stylish-haskell"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
require('compe').setup {
|
||||||
|
enabled = true;
|
||||||
|
autocomplete = true;
|
||||||
|
debug = false;
|
||||||
|
min_length = 1;
|
||||||
|
preselect = 'enable';
|
||||||
|
throttle_time = 80;
|
||||||
|
source_timeout = 200;
|
||||||
|
incomplete_delay = 400;
|
||||||
|
max_abbr_width = 100;
|
||||||
|
max_kind_width = 100;
|
||||||
|
max_menu_width = 100;
|
||||||
|
documentation = true;
|
||||||
|
|
||||||
|
source = {
|
||||||
|
path = true;
|
||||||
|
buffer = true;
|
||||||
|
calc = true;
|
||||||
|
nvim_lsp = true;
|
||||||
|
nvim_lua = true;
|
||||||
|
vsnip = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
--vim.lsp.handlers['textDocument/codeAction'] = require('lsputil.codeAction').code_action_handler
|
||||||
|
--vim.lsp.handlers['textDocument/references'] = require('lsputil.locations').references_handler
|
||||||
|
--vim.lsp.handlers['textDocument/definition'] = require('lsputil.locations').definition_handler
|
||||||
|
--vim.lsp.handlers['textDocument/declaration'] = require('lsputil.locations').declaration_handler
|
||||||
|
--vim.lsp.handlers['textDocument/typeDefinition'] = require('lsputil.locations').typeDefinition_handler
|
||||||
|
--vim.lsp.handlers['textDocument/implementation'] = require('lsputil.locations').implementation_handler
|
||||||
|
--vim.lsp.handlers['textDocument/documentSymbol'] = require('lsputil.symbols').document_handler
|
||||||
|
--vim.lsp.handlers['workspace/symbol'] = require('lsputil.symbols').workspace_handler
|
||||||
|
|
||||||
|
|
||||||
|
saga.init_lsp_saga {
|
||||||
|
border_style = 1,
|
||||||
|
code_action_keys = { quit = '<esc>', exec = '<CR>' },
|
||||||
|
rename_action_keys = { quit = '<esc>', exec = '<CR>' },
|
||||||
|
finder_action_keys = {
|
||||||
|
quit = '<esc>',
|
||||||
|
open = '<CR>',
|
||||||
|
vsplit = 'v',
|
||||||
|
split = 'b',
|
||||||
|
scroll_up = '<C-u>',
|
||||||
|
scroll_down = '<C-d>'
|
||||||
|
},
|
||||||
|
}
|
29
plugins.vim
29
plugins.vim
|
@ -7,6 +7,9 @@ endif
|
||||||
|
|
||||||
call plug#begin('~/.vim/plugged')
|
call plug#begin('~/.vim/plugged')
|
||||||
|
|
||||||
|
Plug 'Olical/aniseed', { 'tag': 'v3.16.0' }
|
||||||
|
Plug 'bakpakin/fennel.vim'
|
||||||
|
|
||||||
Plug 'tweekmonster/startuptime.vim'
|
Plug 'tweekmonster/startuptime.vim'
|
||||||
Plug 'tpope/vim-repeat'
|
Plug 'tpope/vim-repeat'
|
||||||
|
|
||||||
|
@ -57,7 +60,7 @@ call plug#begin('~/.vim/plugged')
|
||||||
Plug 'unblevable/quick-scope' " highlight targets when pressing f<character>
|
Plug 'unblevable/quick-scope' " highlight targets when pressing f<character>
|
||||||
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() } } " :MarkdownPreview for live markdown preview
|
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() } } " :MarkdownPreview for live markdown preview
|
||||||
|
|
||||||
Plug 'jiangmiao/auto-pairs'
|
"Plug 'jiangmiao/auto-pairs'
|
||||||
|
|
||||||
Plug 'machakann/vim-highlightedyank'
|
Plug 'machakann/vim-highlightedyank'
|
||||||
|
|
||||||
|
@ -88,6 +91,9 @@ call plug#begin('~/.vim/plugged')
|
||||||
|
|
||||||
Plug 'bhurlow/vim-parinfer'
|
Plug 'bhurlow/vim-parinfer'
|
||||||
|
|
||||||
|
Plug 'Olical/conjure', {'tag': 'v4.17.0'}
|
||||||
|
|
||||||
|
|
||||||
" Language Plugins ----------------------------------------------------- {{{
|
" Language Plugins ----------------------------------------------------- {{{
|
||||||
|
|
||||||
Plug 'ziglang/zig.vim'
|
Plug 'ziglang/zig.vim'
|
||||||
|
@ -101,7 +107,7 @@ call plug#begin('~/.vim/plugged')
|
||||||
Plug 'ianks/vim-tsx'
|
Plug 'ianks/vim-tsx'
|
||||||
Plug 'leafgarland/typescript-vim'
|
Plug 'leafgarland/typescript-vim'
|
||||||
Plug 'sheerun/vim-polyglot' " Syntax highlighting for most languages
|
Plug 'sheerun/vim-polyglot' " Syntax highlighting for most languages
|
||||||
Plug 'mattn/emmet-vim'
|
"Plug 'mattn/emmet-vim'
|
||||||
|
|
||||||
Plug 'udalov/kotlin-vim'
|
Plug 'udalov/kotlin-vim'
|
||||||
|
|
||||||
|
@ -119,11 +125,28 @@ call plug#begin('~/.vim/plugged')
|
||||||
Plug 'mattn/webapi-vim'
|
Plug 'mattn/webapi-vim'
|
||||||
|
|
||||||
|
|
||||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||||
Plug 'thyrgle/vim-dyon'
|
Plug 'thyrgle/vim-dyon'
|
||||||
|
|
||||||
|
Plug 'tjdevries/nlua.nvim'
|
||||||
|
Plug 'nvim-lua/completion-nvim'
|
||||||
|
|
||||||
"Plug 'mxw/vim-prolog'
|
"Plug 'mxw/vim-prolog'
|
||||||
|
|
||||||
|
Plug 'neovim/nvim-lspconfig'
|
||||||
|
Plug 'hrsh7th/nvim-compe'
|
||||||
|
Plug 'glepnir/lspsaga.nvim'
|
||||||
|
Plug 'cohama/lexima.vim'
|
||||||
|
|
||||||
|
Plug 'nvim-lua/popup.nvim'
|
||||||
|
Plug 'nvim-lua/plenary.nvim'
|
||||||
|
Plug 'nvim-telescope/telescope.nvim'
|
||||||
|
|
||||||
|
Plug 'RishabhRD/popfix'
|
||||||
|
Plug 'RishabhRD/nvim-lsputils'
|
||||||
|
|
||||||
|
Plug 'nvim-telescope/telescope-media-files.nvim'
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
|
|
|
@ -23,32 +23,72 @@ let g:which_key_map = {
|
||||||
\ }
|
\ }
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
"\ 's' : [ ':CocFzfList symbols' , 'list symbols' ] ,
|
||||||
|
|
||||||
" Maps for code actions
|
" Maps for code actions
|
||||||
|
"let g:which_key_map['m'] = {
|
||||||
|
"\ 'name' : '+Code-actions' ,
|
||||||
|
"\ 'd' : [ ':call luaeval("vim.lsp.buf.hover()")' , 'show documentation' ] ,
|
||||||
|
"\ 'b' : [ ':Lspsaga lsp_finder' , 'find stuff' ] ,
|
||||||
|
"\ 'x' : [ ':Lspsaga preview_definition' , 'Preview definition' ] ,
|
||||||
|
"\ 'o' : [ ':Telescope lsp_document_symbols' , 'symbols in document' ] ,
|
||||||
|
"\ 's' : [ ':Telescope lsp_workspace_symbols' , 'symbols in workspace' ] ,
|
||||||
|
"\ 'g' : [ ':call luaeval("vim.lsp.buf.definition()")' , 'go to definition' ] ,
|
||||||
|
"\ 't' : [ ':call luaeval("vim.lsp.buf.signature_help()")' , 'Show signature help' ] ,
|
||||||
|
"\ 'i' : [ ':call luaeval("vim.lsp.buf.implementation()")' , 'show implementation' ] ,
|
||||||
|
"\ 'r' : [ ':call luaeval("vim.lsp.buf.references()")' , 'show references' ] ,
|
||||||
|
"\ 'n' : [ ':call luaeval("vim.lsp.buf.rename()")' , 'rename' ] ,
|
||||||
|
"\ 'f' : [ ':call luaeval("vim.lsp.buf.formatting()")' , 'format file' ] ,
|
||||||
|
"\ 'v' : [ ':call luaeval("vim.lsp.buf.code_action()")' , 'apply codeaction' ] ,
|
||||||
|
"\ 'e' : [ ':call luaeval("vim.lsp.diagnostic.goto_next()")' , 'Jump to next error' ] ,
|
||||||
|
"\ 'E' : [ ':call luaeval("vim.lsp.diagnostic.goto_prev()")' , 'Jump to previous error' ] ,
|
||||||
|
"\ 'a' : [ ':call luaeval("vim.lsp.diagnostic.show_line_diagnostics()")' , 'diagnostics info' ] ,
|
||||||
|
"\ }
|
||||||
|
|
||||||
let g:which_key_map['m'] = {
|
let g:which_key_map['m'] = {
|
||||||
\ 'name' : '+Code-actions' ,
|
\ 'name' : '+Code-actions' ,
|
||||||
\ 'd' : [ ':call Show_documentation()' , 'show documentation' ] ,
|
\ 'd' : [ ':Lspsaga hover_doc' , 'show documentation' ] ,
|
||||||
\ 's' : [ ':CocFzfList symbols' , 'list symbols' ] ,
|
\ 'b' : [ ':Lspsaga lsp_finder' , 'find stuff' ] ,
|
||||||
\ 'o' : [ ':CocFzfList outline' , 'show outline' ] ,
|
\ 'x' : [ ':Lspsaga preview_definition' , 'Preview definition' ] ,
|
||||||
\ 'c' : [ ':CocFzfList commands' , 'show all coc-commands' ] ,
|
\ 'o' : [ ':Telescope lsp_document_symbols' , 'symbols in document' ] ,
|
||||||
\ 'g' : [ '<Plug>(coc-definition)' , 'go to definition' ] ,
|
\ 's' : [ ':Telescope lsp_workspace_symbols' , 'symbols in workspace' ] ,
|
||||||
\ 't' : [ '<Plug>(coc-type-definition)' , 'show type definition' ] ,
|
\ 'g' : [ ':call luaeval("vim.lsp.buf.definition()")' , 'go to definition' ] ,
|
||||||
\ 'i' : [ '<Plug>(coc-implementation)' , 'show implementation' ] ,
|
\ 't' : [ ':Lspsaga signature_help' , 'Show signature help' ] ,
|
||||||
\ 'r' : [ '<Plug>(coc-references-used)' , 'show references' ] ,
|
\ 'i' : [ ':call luaeval("vim.lsp.buf.implementation()")' , 'show implementation' ] ,
|
||||||
\ 'b' : [ '<Plug>(coc-refactor)' , 'refactor' ] ,
|
\ 'r' : [ ':call luaeval("vim.lsp.buf.references()")' , 'show references' ] ,
|
||||||
\ 'n' : [ '<Plug>(coc-rename)' , 'rename' ] ,
|
\ 'n' : [ ':Lspsaga rename' , 'rename' ] ,
|
||||||
\ 'F' : [ '<Plug>(coc-format-selected)' , 'format selection' ] ,
|
\ 'f' : [ ':call luaeval("vim.lsp.buf.formatting()")' , 'format file' ] ,
|
||||||
\ 'f' : [ '<Plug>(coc-format)' , 'format file' ] ,
|
\ 'v' : [ ':Lspsaga code_action' , 'apply codeaction' ] ,
|
||||||
"\ 'v' : [ ':CocCommand actions.open' , 'apply codeaction' ] ,
|
\ 'e' : [ ':call luaeval("vim.lsp.diagnostic.goto_next()")' , 'Jump to the next error' ] ,
|
||||||
\ 'v' : [ '<Plug>(coc-codeaction-cursor)', 'apply codeaction' ] ,
|
\ 'E' : [ ':Telescope lsp_workspace_diagnostics' , 'List diagnostics' ] ,
|
||||||
\ 'V' : [ '<Plug>(coc-codeaction-line)' , 'codeaction current line'] ,
|
\ 'a' : [ ':Lspsaga show_cursor_diagnostics' , 'Cursor diagnostics' ] ,
|
||||||
\ 'e' : [ ':CocList diagnostics' , 'list all errors' ] ,
|
\ 'A' : [ ':Lspsaga show_line_diagnostics' , 'Line diagnostics' ] ,
|
||||||
\ 'L' : [ '<Plug>(coc-diagnostic-next)' , 'go to next error' ] ,
|
|
||||||
\ 'H' : [ '<Plug>(coc-diagnostic-prev)' , 'go to prev error' ] ,
|
|
||||||
\ 'a' : [ '<Plug>(coc-diagnostic-info)' , 'diagnostics info' ] ,
|
|
||||||
\ 'O' : [ '<Plug>(coc-openlink)' , 'open link under cursor' ] ,
|
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
"let g:which_key_map['m'] = {
|
||||||
|
"\ 'name' : '+Code-actions' ,
|
||||||
|
"\ 'd' : [ ':call Show_documentation()' , 'show documentation' ] ,
|
||||||
|
"\ 's' : [ ':CocFzfList symbols' , 'list symbols' ] ,
|
||||||
|
"\ 'o' : [ ':CocFzfList outline' , 'show outline' ] ,
|
||||||
|
"\ 'c' : [ ':CocFzfList commands' , 'show all coc-commands' ] ,
|
||||||
|
"\ 'g' : [ '<Plug>(coc-definition)' , 'go to definition' ] ,
|
||||||
|
"\ 't' : [ '<Plug>(coc-type-definition)' , 'show type definition' ] ,
|
||||||
|
"\ 'i' : [ '<Plug>(coc-implementation)' , 'show implementation' ] ,
|
||||||
|
"\ 'r' : [ '<Plug>(coc-references-used)' , 'show references' ] ,
|
||||||
|
"\ 'b' : [ '<Plug>(coc-refactor)' , 'refactor' ] ,
|
||||||
|
"\ 'n' : [ '<Plug>(coc-rename)' , 'rename' ] ,
|
||||||
|
"\ 'F' : [ '<Plug>(coc-format-selected)' , 'format selection' ] ,
|
||||||
|
"\ 'f' : [ '<Plug>(coc-format)' , 'format file' ] ,
|
||||||
|
""\ 'v' : [ ':CocCommand actions.open' , 'apply codeaction' ] ,
|
||||||
|
"\ 'v' : [ '<Plug>(coc-codeaction-cursor)', 'apply codeaction' ] ,
|
||||||
|
"\ 'V' : [ '<Plug>(coc-codeaction-line)' , 'codeaction current line'] ,
|
||||||
|
"\ 'e' : [ ':CocList diagnostics' , 'list all errors' ] ,
|
||||||
|
"\ 'L' : [ '<Plug>(coc-diagnostic-next)' , 'go to next error' ] ,
|
||||||
|
"\ 'H' : [ '<Plug>(coc-diagnostic-prev)' , 'go to prev error' ] ,
|
||||||
|
"\ 'a' : [ '<Plug>(coc-diagnostic-info)' , 'diagnostics info' ] ,
|
||||||
|
"\ 'O' : [ '<Plug>(coc-openlink)' , 'open link under cursor' ] ,
|
||||||
|
"\}
|
||||||
|
|
||||||
let g:which_key_map['f'] = {
|
let g:which_key_map['f'] = {
|
||||||
\ 'name': '+folds',
|
\ 'name': '+folds',
|
||||||
\ 'o': [ ':foldopen' , 'open fold' ] ,
|
\ 'o': [ ':foldopen' , 'open fold' ] ,
|
||||||
|
|
Loading…
Reference in a new issue