45 lines
1.8 KiB
Lua
Raw Normal View History

local mapkey = require("util.keymapper").mapvimkey
local M = {}
M.on_attach = function(client, bufnr)
local opts = { noremap = true, silent = true, buffer = bufnr }
mapkey("<leader>fd", "Lspsaga finder", "n", opts) -- go to definition
mapkey("<leader>gS", "vsplit | Lspsaga goto_definition", "n", opts) -- go to definition
mapkey("<leader>ca", "Lspsaga code_action", "n", opts) -- see available code actions
mapkey("<leader>rn", "Lspsaga rename", "n", opts) -- smart rename
mapkey("<leader>D", "Lspsaga show_line_diagnostics", "n", opts) -- show diagnostics for line
mapkey("<leader>d", "Lspsaga show_cursor_diagnostics", "n", opts) -- show diagnostics for cursor
mapkey("<leader>pd", "Lspsaga diagnostic_jump_prev", "n", opts) -- jump to prev diagnostic in buffer
mapkey("<leader>nd", "Lspsaga diagnostic_jump_next", "n", opts) -- jump to next diagnostic in buffer
mapkey("<leader>nt", "Lspsaga term_toggle", "n", opts) -- jump to next diagnostic in buffer
mapkey("K", "Lspsaga hover_doc", "n", opts) -- show documentation for what is under cursor
if client.name == "pyright" then
mapkey("<leader>oi", "PyrightOrganizeImports", "n", opts) -- organise imports
mapkey("<leader>db", "DapToggleBreakpoint", "n", opts) -- toggle breakpoint
mapkey("<leader>dr", "DapContinue", "n", opts) -- continue/invoke debugger
mapkey("<leader>dt", "lua require('dap-python').test_method()", "n", opts) -- run tests
end
if client.name == "ts_ls" then
mapkey("<leader>oi", "TypeScriptOrganizeImports", "n", opts) -- organise imports
end
end
M.typescript_organise_imports = {
description = "Organise Imports",
function()
local params = {
command = "_typescript.organizeImports",
arguments = { vim.fn.expand("%:p") },
}
-- reorganise imports
vim.lsp.buf.execute_command(params)
end,
}
return M