more refactor

This commit is contained in:
Chris 2021-07-28 17:15:35 -04:00
parent 339aa8756e
commit 78dd92b616
2 changed files with 30 additions and 24 deletions

View file

@ -4,6 +4,7 @@ function lsp_config.config()
require("lsp.kind").setup() require("lsp.kind").setup()
require("lsp.handlers").setup() require("lsp.handlers").setup()
require("lsp.signs").setup() require("lsp.signs").setup()
require("ls.keybindings").setup()
end end
-- My font didn't like this :/ -- My font didn't like this :/
@ -14,30 +15,6 @@ end
-- { noremap = true, silent = true } -- { noremap = true, silent = true }
-- ) -- )
function lsp_config.setup_default_bindings()
if lvim.lsp.default_keybinds then
vim.cmd "nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>"
vim.cmd "nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>"
vim.cmd "nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>"
vim.cmd "nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>"
vim.api.nvim_set_keymap(
"n",
"gl",
'<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = "single" })<CR>',
{ noremap = true, silent = true }
)
vim.cmd "nnoremap <silent> gp <cmd>lua require'lsp.utils'.PeekDefinition()<CR>"
vim.cmd "nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>"
vim.cmd "nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})<CR>"
vim.cmd "nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})<CR>"
-- vim.cmd "nnoremap <silent> <tab> <cmd>lua vim.lsp.buf.signature_help()<CR>"
-- scroll down hover doc or scroll in definition preview
-- scroll up hover doc
-- vim.cmd 'command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()'
end
end
local function no_formatter_on_attach(client, bufnr) local function no_formatter_on_attach(client, bufnr)
if lvim.lsp.on_attach_callback then if lvim.lsp.on_attach_callback then
lvim.lsp.on_attach_callback(client, bufnr) lvim.lsp.on_attach_callback(client, bufnr)

29
lua/lsp/keybinds.lua Normal file
View file

@ -0,0 +1,29 @@
local M = {}
function M.setup()
function M.setup_default_bindings()
if lvim.lsp.default_keybinds then
vim.cmd "nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>"
vim.cmd "nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>"
vim.cmd "nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>"
vim.cmd "nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>"
vim.api.nvim_set_keymap(
"n",
"gl",
'<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = "single" })<CR>',
{ noremap = true, silent = true }
)
vim.cmd "nnoremap <silent> gp <cmd>lua require'lsp.utils'.PeekDefinition()<CR>"
vim.cmd "nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>"
vim.cmd "nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})<CR>"
vim.cmd "nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})<CR>"
-- vim.cmd "nnoremap <silent> <tab> <cmd>lua vim.lsp.buf.signature_help()<CR>"
-- scroll down hover doc or scroll in definition preview
-- scroll up hover doc
-- vim.cmd 'command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()'
end
end
end
return M