mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-01 16:45:00 +02:00
wrap lsp functions in simple commands
This commit is contained in:
parent
7da8f32a95
commit
4308a66977
6 changed files with 153 additions and 20 deletions
|
@ -46,7 +46,6 @@ $HOME/.config/nvim/lua/nv-vscode/init.vim
|
|||
- formatting using efm server for python
|
||||
- formatting using efm server for prettier/eslint
|
||||
- add git signs to whichkey (This will require wrapping in Lua commands)
|
||||
- wrap all whichkey lsp in functions
|
||||
- snippet support
|
||||
|
||||
**LOW PRIORITY**
|
||||
|
|
1
init.lua
1
init.lua
|
@ -34,6 +34,7 @@ else
|
|||
|
||||
-- Which Key (Hope to replace with Lua plugin someday)
|
||||
vim.cmd('source ~/.config/nvim/vimscript/nv-whichkey/init.vim')
|
||||
vim.cmd('source ~/.config/nvim/vimscript/functions.vim')
|
||||
-- vim.cmd('source ~/.config/nvim/vimscript/nv-commentary/init.vim')
|
||||
|
||||
-- LSP
|
||||
|
|
136
lua/utils.lua
136
lua/utils.lua
|
@ -1,4 +1,6 @@
|
|||
local function define_augroups(definitions) -- {{{1
|
||||
local function_wrapper = {}
|
||||
|
||||
function function_wrapper.define_augroups(definitions) -- {{{1
|
||||
-- Create autocommand groups based on the passed definitions
|
||||
--
|
||||
-- The key will be the name of the group, and each definition
|
||||
|
@ -19,8 +21,7 @@ local function define_augroups(definitions) -- {{{1
|
|||
vim.cmd('augroup END')
|
||||
end
|
||||
end
|
||||
|
||||
define_augroups(
|
||||
function_wrapper.define_augroups(
|
||||
{_general_settings = {
|
||||
{'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'IncSearch\', timeout = 200})'},
|
||||
{'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
|
||||
|
@ -36,3 +37,132 @@ define_augroups(
|
|||
|
||||
-- Add this to lightbulb, java makes this annoying tho
|
||||
-- autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()
|
||||
|
||||
-- lsp
|
||||
|
||||
function function_wrapper.add_to_workspace_folder()
|
||||
vim.lsp.buf.add_workspace_folder()
|
||||
end
|
||||
|
||||
function function_wrapper.clear_references()
|
||||
vim.lsp.buf.clear_references()
|
||||
end
|
||||
|
||||
function function_wrapper.code_action()
|
||||
vim.lsp.buf.code_action()
|
||||
end
|
||||
|
||||
function function_wrapper.declaration()
|
||||
vim.lsp.buf.declaration()
|
||||
vim.lsp.buf.clear_references()
|
||||
end
|
||||
|
||||
function function_wrapper.definition()
|
||||
vim.lsp.buf.definition()
|
||||
vim.lsp.buf.clear_references()
|
||||
end
|
||||
|
||||
function function_wrapper.document_highlight()
|
||||
vim.lsp.buf.document_highlight()
|
||||
end
|
||||
|
||||
function function_wrapper.document_symbol()
|
||||
vim.lsp.buf.document_symbol()
|
||||
end
|
||||
|
||||
function function_wrapper.formatting()
|
||||
vim.lsp.buf.formatting()
|
||||
end
|
||||
|
||||
function function_wrapper.formatting_sync()
|
||||
vim.lsp.buf.formatting_sync()
|
||||
end
|
||||
|
||||
function function_wrapper.hover()
|
||||
vim.lsp.buf.hover()
|
||||
end
|
||||
|
||||
function function_wrapper.implementation()
|
||||
vim.lsp.buf.implementation()
|
||||
end
|
||||
|
||||
function function_wrapper.incoming_calls()
|
||||
vim.lsp.buf.incoming_calls()
|
||||
end
|
||||
|
||||
function function_wrapper.list_workspace_folders()
|
||||
vim.lsp.buf.list_workspace_folders()
|
||||
end
|
||||
|
||||
function function_wrapper.outgoing_calls()
|
||||
vim.lsp.buf.outgoing_calls()
|
||||
end
|
||||
|
||||
function function_wrapper.range_code_action()
|
||||
vim.lsp.buf.range_code_action()
|
||||
end
|
||||
|
||||
function function_wrapper.range_formatting()
|
||||
vim.lsp.buf.range_formatting()
|
||||
end
|
||||
|
||||
function function_wrapper.references()
|
||||
vim.lsp.buf.references()
|
||||
vim.lsp.buf.clear_references()
|
||||
end
|
||||
|
||||
function function_wrapper.remove_workspace_folder()
|
||||
vim.lsp.buf.remove_workspace_folder()
|
||||
end
|
||||
|
||||
function function_wrapper.rename()
|
||||
vim.lsp.buf.rename()
|
||||
end
|
||||
|
||||
function function_wrapper.signature_help()
|
||||
vim.lsp.buf.signature_help()
|
||||
end
|
||||
|
||||
function function_wrapper.type_definition()
|
||||
vim.lsp.buf.type_definition()
|
||||
end
|
||||
|
||||
function function_wrapper.workspace_symbol()
|
||||
vim.lsp.buf.workspace_symbol()
|
||||
end
|
||||
|
||||
-- diagnostic
|
||||
|
||||
function function_wrapper.get_all()
|
||||
vim.lsp.diagnostic.get_all()
|
||||
end
|
||||
|
||||
function function_wrapper.get_next()
|
||||
vim.lsp.diagnostic.get_next()
|
||||
end
|
||||
|
||||
function function_wrapper.get_prev()
|
||||
vim.lsp.diagnostic.get_prev()
|
||||
end
|
||||
|
||||
function function_wrapper.goto_next()
|
||||
vim.lsp.diagnostic.goto_next()
|
||||
end
|
||||
|
||||
function function_wrapper.goto_prev()
|
||||
vim.lsp.diagnostic.goto_prev()
|
||||
end
|
||||
|
||||
function function_wrapper.show_line_diagnostics()
|
||||
vim.lsp.diagnostic.show_line_diagnostics()
|
||||
end
|
||||
|
||||
-- git signs
|
||||
|
||||
-- misc
|
||||
|
||||
|
||||
-- autoformat
|
||||
-- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000)
|
||||
|
||||
return function_wrapper
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
command! LspCodeAction lua require 'function-wrapper'.code_action()
|
||||
command! LspDeclaration lua require 'function-wrapper'.declaration()
|
||||
command! LspDefinition lua require 'function-wrapper'.definition()
|
||||
command! LspDocumentSymbol lua require 'function-wrapper'.document_symbol()
|
||||
command! LspFormatting lua require 'function-wrapper'.formatting()
|
||||
command! LspFormattingSync lua require 'function-wrapper'.formatting_sync()
|
||||
command! LspHover lua require 'function-wrapper'.hover()
|
||||
command! LspImplementation lua require 'function-wrapper'.implementation()
|
||||
command! LspRangeCodeAction lua require 'function-wrapper'.range_code_action()
|
||||
command! LspRangeFormatting lua require 'function-wrapper'.range_formatting()
|
||||
command! LspReferences lua require 'function-wrapper'.references()
|
||||
command! LspRename lua require 'function-wrapper'.rename()
|
||||
command! LspTypeDefinition lua require 'function-wrapper'.type_definition()
|
||||
command! LspWorkspaceSymbol lua require 'function-wrapper'.workspace_symbol()
|
||||
command! LspGotoNext lua require 'function-wrapper'.goto_next()
|
||||
command! LspGotoPrev lua require 'function-wrapper'.goto_prev()
|
||||
command! LspShowLineDiagnostics lua require 'function-wrapper'.show_line_diagnostics()
|
|
@ -1,11 +0,0 @@
|
|||
function! Comment()
|
||||
if (mode() == "n" )
|
||||
execute "Commentary"
|
||||
else
|
||||
execute "'<,'>Commentary"
|
||||
endif
|
||||
endfunction
|
||||
vnoremap <silent> <space>/ :call Comment()
|
||||
autocmd! BufRead,BufNewFile *.{jsx,jx,js} setlocal filetype=javascript
|
||||
"autocmd FileType javascriptreact setlocal commentstring={/*\ %s\ */}
|
||||
|
|
@ -47,17 +47,14 @@ let g:which_key_map['v'] = [ '<C-W>v' ,
|
|||
let g:which_key_map.a = {
|
||||
\ 'name' : '+actions' ,
|
||||
\ 'c' : [':ColorizerToggle' , 'colorizer'],
|
||||
\ 'e' : [':CocCommand explorer' , 'explorer'],
|
||||
\ 'h' : [':let @/ = ""' , 'remove search highlight'],
|
||||
\ 'l' : [':Bracey' , 'start live server'],
|
||||
\ 'L' : [':BraceyStop' , 'stop live server'],
|
||||
\ 'n' : [':set nonumber!' , 'line-numbers'],
|
||||
\ 's' : [':s/\%V\(.*\)\%V/"\1"/' , 'surround'],
|
||||
\ 'r' : [':set norelativenumber!' , 'relative line nums'],
|
||||
\ 't' : [':FloatermToggle' , 'terminal'],
|
||||
\ 'v' : [':Codi' , 'virtual repl on'],
|
||||
\ 'V' : [':Codi!' , 'virtual repl off'],
|
||||
\ 'w' : [':StripWhitespace' , 'strip whitespace'],
|
||||
\ }
|
||||
|
||||
" b is for buffer
|
||||
|
@ -188,19 +185,19 @@ let g:which_key_map.l = {
|
|||
\ 'd' : [':Telescope lsp_document_diagnostics' , 'document diagnostics'],
|
||||
\ 'D' : [':Telescope lsp_workspace_diagnostics', 'workspace diagnostics'],
|
||||
\ 'f' : [':LspFormatting' , 'format'],
|
||||
\ 'H' : [':Lspsaga signature_help' , 'signature_help'],
|
||||
\ 'I' : [':LspInfo' , 'lsp info'],
|
||||
\ 'l' : [':Lspsaga lsp_finder' , 'lsp finder'],
|
||||
\ 'L' : [':Lspsaga show_line_diagnostics' , 'line_diagnostics'],
|
||||
\ 'o' : [':Vista!!' , 'outline'],
|
||||
\ 'p' : [':Lspsaga preview_definition' , 'preview definition'],
|
||||
\ 'q' : [':Telescope quickfix' , 'quickfix'],
|
||||
\ 'r' : [':LspRename' , 'rename'],
|
||||
\ 'r' : [':Lspsaga rename' , 'rename'],
|
||||
\ 'T' : [':LspTypeDefinition' , 'type defintion'],
|
||||
\ 'x' : [':cclose' , 'close quickfix'],
|
||||
\ 's' : [':Telescope lsp_document_symbols' , 'document symbols'],
|
||||
\ 'S' : [':Telescope lsp_workspace_symbols' , 'workspace symbols'],
|
||||
\ }
|
||||
" \ 'H' : [':Lspsaga signature_help' , 'signature_help'],
|
||||
|
||||
" t is for terminal
|
||||
let g:which_key_map.t = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue