2022-08-26 14:28:12 +00:00
|
|
|
local present, navigator = pcall(require, "navigator")
|
|
|
|
|
2023-08-06 12:15:51 +00:00
|
|
|
|
2022-08-26 14:28:12 +00:00
|
|
|
if not present then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2023-08-08 01:50:01 +00:00
|
|
|
local myicons = require("custom.chadrc").ui.myicons
|
|
|
|
|
2022-08-29 14:46:20 +00:00
|
|
|
M = {}
|
|
|
|
|
2023-02-22 18:50:20 +00:00
|
|
|
local get_current_gomod = function()
|
|
|
|
local file = io.open('go.mod', 'r')
|
|
|
|
if file == nil then
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
local first_line = file:read()
|
|
|
|
local mod_name = first_line:gsub('module ', '')
|
|
|
|
file:close()
|
|
|
|
return mod_name
|
|
|
|
end
|
|
|
|
|
2023-08-06 12:15:51 +00:00
|
|
|
-- default config
|
|
|
|
-- "~/.local/share/nvim/site/pack/packer/opt/navigator.lua/lua/navigator.lua"
|
2023-08-08 01:50:01 +00:00
|
|
|
-- "~/.local/share/nvim/site/pack/packer/opt/navigator.lua/lua/navigator/lspclient/mapping.lua"
|
2022-08-26 14:28:12 +00:00
|
|
|
local config = {
|
2022-09-29 18:49:40 +00:00
|
|
|
debug = false,
|
2022-08-29 14:46:20 +00:00
|
|
|
transparency = 5,
|
2022-09-09 18:52:07 +00:00
|
|
|
lsp_signature_help = false, -- needs plugin lsp_signature
|
2022-09-25 03:03:21 +00:00
|
|
|
default_mapping = false,
|
2023-02-10 19:59:24 +00:00
|
|
|
on_attach = require('plugins.configs.lspconfig').on_attach,
|
2022-08-31 16:15:21 +00:00
|
|
|
keymaps = {
|
2023-09-06 10:56:34 +00:00
|
|
|
{
|
|
|
|
key = 'gr',
|
|
|
|
func = require('navigator.reference').async_ref,
|
|
|
|
desc = 'lsp async_ref'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key = '<leader>lr',
|
|
|
|
func = require('navigator.reference').reference,
|
|
|
|
desc = 'lsp reference'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key = 'g0',
|
|
|
|
func = require('navigator.symbols').document_symbols,
|
|
|
|
desc = 'lsp document_symbols'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key = 'gW',
|
|
|
|
func = require('navigator.workspace').workspace_symbol_live,
|
|
|
|
desc = 'lsp workspace_symbol_live'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key = '<c-]>',
|
|
|
|
func = require('navigator.definition').definition,
|
|
|
|
desc = 'lsp definition'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key = '<C-LeftMouse>',
|
|
|
|
func = require('navigator.definition').definition,
|
|
|
|
desc = "lsp definition"
|
|
|
|
},
|
|
|
|
{ key = 'gd', func = require('navigator.definition').definition, desc = 'definition' },
|
|
|
|
{ key = 'gD', func = vim.lsp.buf.declaration, desc = 'declaration' },
|
|
|
|
{ key = 'gm', func = vim.lsp.buf.implementation, desc = 'implementation' },
|
|
|
|
{ key = 'g<LeftMouse>', func = vim.lsp.buf.implementation, desc = 'implementation' },
|
|
|
|
{
|
|
|
|
key = 'gp',
|
|
|
|
func = require('navigator.definition').definition_preview,
|
|
|
|
desc = 'lsp definition preview'
|
|
|
|
},
|
|
|
|
{ key = "<BS>h", func = function()
|
|
|
|
vim.lsp.inlay_hint(0, nil)
|
|
|
|
end, desc = "toggle lsp hints"},
|
|
|
|
{ key = '<leader>D', func = vim.lsp.buf.type_definition, desc = 'type_definition' },
|
|
|
|
{ key = '<leader>Dp', func = require('navigator.definition').type_definition_preview, desc = 'lsp type definition preview' },
|
2023-02-10 19:59:24 +00:00
|
|
|
|
2022-10-09 02:51:47 +00:00
|
|
|
{ key = '<M-a>', mode = 'n', func = require('navigator.codeAction').code_action, desc = 'lsp code_action' },
|
2022-10-16 23:50:45 +00:00
|
|
|
{ key = '<M-a>', mode = 'i', func = require('navigator.codeAction').code_action, desc = 'lsp code_action' },
|
2022-10-19 13:36:36 +00:00
|
|
|
{ key = '<BS><Right>', mode = 'n', func = require('navigator.symbols').side_panel, desc = 'toggle lsp outline pannel'},
|
2022-08-31 16:15:21 +00:00
|
|
|
{
|
2022-10-09 02:51:47 +00:00
|
|
|
key = '<M-a>',
|
2022-08-31 16:15:21 +00:00
|
|
|
mode = 'v',
|
|
|
|
func = require('navigator.codeAction').range_code_action,
|
|
|
|
desc = 'lsp range_code_action',
|
|
|
|
},
|
|
|
|
{ key = '<Space>rn', func = require('navigator.rename').rename, desc = 'lsp rename' },
|
2023-09-06 10:56:34 +00:00
|
|
|
{ key = '<Leader>gi', func = vim.lsp.buf.incoming_calls, desc = 'lsp incoming_calls' },
|
|
|
|
{ key = '<Leader>go', func = vim.lsp.buf.outgoing_calls, desc = 'lsp outgoing_calls' },
|
2022-08-31 16:15:21 +00:00
|
|
|
{ key = 'gL', func = require('navigator.diagnostics').show_diagnostics, desc = 'lsp show_diagnostics' },
|
|
|
|
{ key = 'gG', func = require('navigator.diagnostics').show_buf_diagnostics, desc = 'lsp show_buf_diagnostics' },
|
2023-09-06 10:56:34 +00:00
|
|
|
--TODO: toggle diagnostics
|
|
|
|
{
|
|
|
|
key = ']d',
|
|
|
|
func = vim.diagnostic.goto_next,
|
|
|
|
desc = 'next diagnostics',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key = '[d',
|
|
|
|
func = vim.diagnostic.goto_prev,
|
|
|
|
desc = 'prev diagnostics',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key = ']O',
|
|
|
|
func = vim.diagnostic.set_loclist,
|
|
|
|
desc = 'diagnostics set loclist',
|
|
|
|
},
|
2022-08-31 16:15:21 +00:00
|
|
|
{ key = ']r', func = require('navigator.treesitter').goto_next_usage, desc = 'lsp goto_next_usage' },
|
|
|
|
{ key = '[r', func = require('navigator.treesitter').goto_previous_usage, desc = 'lsp goto_previous_usage' },
|
2023-09-06 10:56:34 +00:00
|
|
|
{
|
|
|
|
key = '<leader>lf',
|
|
|
|
func = vim.lsp.buf.format,
|
|
|
|
mode = 'n',
|
|
|
|
desc = 'lsp format'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key = '<leader>lf',
|
|
|
|
func = vim.lsp.buf.range_formatting,
|
|
|
|
mode = 'v',
|
|
|
|
desc = 'lsp range format'
|
|
|
|
},
|
2022-08-31 16:15:21 +00:00
|
|
|
{ key = '<Leader>k', func = require('navigator.dochighlight').hi_symbol, desc = 'lsp hi_symbol' },
|
2022-10-13 00:50:18 +00:00
|
|
|
{ key = '<leader>wa', func = require('navigator.workspace').add_workspace_folder, desc = 'lsp add_workspace_folder' },
|
2022-08-31 16:15:21 +00:00
|
|
|
{
|
2022-10-13 00:50:18 +00:00
|
|
|
key = '<leader>wr',
|
2022-08-31 16:15:21 +00:00
|
|
|
func = require('navigator.workspace').remove_workspace_folder,
|
|
|
|
desc = 'lsp lsp remove_workspace_folder',
|
|
|
|
},
|
2022-10-13 00:50:18 +00:00
|
|
|
{ key = '<leader>wl', func = require('navigator.workspace').list_workspace_folders, desc = 'lsp list_workspace_folders' },
|
|
|
|
{ key = '<leader>ll', mode = 'n', func = require('navigator.codelens').run_action, desc = 'lsp run code lens action' },
|
2022-08-31 16:15:21 +00:00
|
|
|
},
|
2022-08-29 14:46:20 +00:00
|
|
|
|
2022-08-27 03:09:00 +00:00
|
|
|
icons = {
|
|
|
|
icons = true, -- set to false to use system default ( if you using a terminal does not have nerd/icon)
|
|
|
|
-- Code action
|
2023-08-06 12:15:51 +00:00
|
|
|
code_action_icon = '', -- "",
|
2022-08-29 14:46:20 +00:00
|
|
|
|
2022-08-27 03:09:00 +00:00
|
|
|
-- code lens
|
2022-09-09 18:52:07 +00:00
|
|
|
code_lens_action_icon = '',
|
2022-08-29 14:46:20 +00:00
|
|
|
|
2022-08-27 03:09:00 +00:00
|
|
|
-- Diagnostics
|
2023-08-08 01:50:01 +00:00
|
|
|
diagnostic_head = myicons.lsp.diagnostic_head, -- default diagnostic head on dialogs
|
|
|
|
diagnostic_err = myicons.lsp.diagnostic_err, -- severity 1
|
|
|
|
diagnostic_warn = myicons.lsp.diagnostic_warn, -- 2
|
|
|
|
diagnostic_info = myicons.lsp.diagnostic_info, -- 3
|
|
|
|
diagnostic_hint = myicons.lsp.diagnostic_hint, -- 4
|
2022-08-27 03:09:00 +00:00
|
|
|
|
2022-08-29 14:46:20 +00:00
|
|
|
-- used in the diagnostics summary window
|
|
|
|
diagnostic_head_severity_1 = '',
|
|
|
|
diagnostic_head_severity_2 = '',
|
|
|
|
diagnostic_head_severity_3 = 'i',
|
|
|
|
diagnostic_head_description = ' ',
|
|
|
|
diagnostic_virtual_text = '',
|
2023-08-06 12:15:51 +00:00
|
|
|
diagnostic_file = ' ',
|
2023-07-31 16:39:56 +00:00
|
|
|
|
2022-08-27 03:09:00 +00:00
|
|
|
-- Values
|
2023-07-31 16:39:56 +00:00
|
|
|
--
|
2022-10-09 19:18:15 +00:00
|
|
|
value_changed = '碑',
|
2023-07-31 16:39:56 +00:00
|
|
|
value_definition = ':', -- it is easier to see than 🦕
|
2022-08-27 03:09:00 +00:00
|
|
|
side_panel = {
|
|
|
|
section_separator = '',
|
|
|
|
line_num_left = '',
|
|
|
|
line_num_right = '',
|
|
|
|
inner_node = '├○',
|
|
|
|
outer_node = '╰○',
|
|
|
|
bracket_left = '⟪',
|
|
|
|
bracket_right = '⟫',
|
|
|
|
},
|
|
|
|
-- Treesitter
|
|
|
|
match_kinds = {
|
2023-07-31 16:39:56 +00:00
|
|
|
var = ' ',
|
|
|
|
method = 'ƒ ',
|
|
|
|
['function'] = ' ',
|
|
|
|
parameter = '',
|
2022-10-09 19:18:15 +00:00
|
|
|
associated = '',
|
|
|
|
namespace = '',
|
2022-08-27 03:09:00 +00:00
|
|
|
type = ' ',
|
2022-10-09 19:18:15 +00:00
|
|
|
field = '',
|
|
|
|
module = '',
|
|
|
|
flag = '',
|
2022-08-27 03:09:00 +00:00
|
|
|
},
|
2023-08-06 12:15:51 +00:00
|
|
|
treesitter_defult = '',
|
2022-08-27 03:09:00 +00:00
|
|
|
doc_symbols = '',
|
|
|
|
},
|
2022-09-23 00:50:02 +00:00
|
|
|
mason = true,
|
|
|
|
mason_disabled_for = {"ccls"}, -- disable mason for specified lspclients
|
2022-08-26 14:28:12 +00:00
|
|
|
lsp = {
|
|
|
|
document_highlight = false,
|
|
|
|
format_on_save = false, -- applies to all formatting feature of neovim
|
2022-09-09 18:52:07 +00:00
|
|
|
-- including auto-fold
|
2022-08-29 14:46:20 +00:00
|
|
|
diagnostic = {
|
|
|
|
underline = true,
|
|
|
|
virtual_text = {
|
|
|
|
spacing = 3,
|
|
|
|
source = true
|
|
|
|
}, -- show virtual for diagnostic message
|
|
|
|
update_in_insert = false, -- update diagnostic message in insert mode
|
2022-11-05 18:46:15 +00:00
|
|
|
severity_sort = { reverse = false },
|
2022-08-29 14:46:20 +00:00
|
|
|
},
|
|
|
|
|
2023-08-06 12:15:51 +00:00
|
|
|
code_action = {
|
|
|
|
delay = 5000, -- 5 sec delay
|
|
|
|
virtual_text_icon = false,
|
|
|
|
},
|
|
|
|
|
2022-09-09 18:52:07 +00:00
|
|
|
diagnostic_scrollbar_sign = false,
|
2023-04-29 18:38:10 +00:00
|
|
|
display_diagnostic_qf = false,
|
2022-09-09 18:52:07 +00:00
|
|
|
|
2022-10-10 22:12:27 +00:00
|
|
|
disable_lsp = {"clangd", "rust_analyzer"},
|
2022-08-29 14:46:20 +00:00
|
|
|
|
|
|
|
-- disable auto start of lsp per language
|
|
|
|
-- set global default on lspconfig (see lspconfig doc)
|
2022-09-09 18:52:07 +00:00
|
|
|
gopls = {
|
2022-12-05 13:44:06 +00:00
|
|
|
-- cmd = { "nc", "localhost", "9999" },
|
2022-11-13 17:34:52 +00:00
|
|
|
-- cmd = {"socat", "-" ,"tcp:localhost:4444"},
|
2022-09-29 18:49:40 +00:00
|
|
|
-- on_attach = require("spike.lsp.go").custom_attach,
|
|
|
|
on_attach = require("spike.lsp.go").gopls_onattach,
|
2022-09-09 18:52:07 +00:00
|
|
|
settings = {
|
2023-02-22 18:50:20 +00:00
|
|
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
|
|
gopls = {
|
|
|
|
hints = {
|
|
|
|
assignVariableTypes = true,
|
|
|
|
compositeLiteralFields = true,
|
|
|
|
compositeLiteralTypes = true,
|
|
|
|
constantValues = true,
|
|
|
|
functionTypeParameters = true,
|
|
|
|
parameterNames = true,
|
|
|
|
rangeVariableTypes = true,
|
|
|
|
},
|
|
|
|
analyses = {
|
|
|
|
unreachable = true,
|
|
|
|
nilness = true,
|
|
|
|
unusedparams = true,
|
|
|
|
useany = true,
|
|
|
|
unusedwrite = true,
|
|
|
|
ST1003 = true,
|
|
|
|
undeclaredname = true,
|
|
|
|
fillreturns = true,
|
|
|
|
nonewvars = true,
|
|
|
|
fieldalignment = false,
|
|
|
|
shadow = true,
|
|
|
|
},
|
|
|
|
codelenses = {
|
|
|
|
generate = true, -- show the `go generate` lens.
|
|
|
|
gc_details = true, -- Show a code lens toggling the display of gc's choices.
|
|
|
|
test = true,
|
|
|
|
tidy = true,
|
|
|
|
vendor = true,
|
|
|
|
regenerate_cgo = true,
|
|
|
|
upgrade_dependency = true,
|
|
|
|
},
|
|
|
|
usePlaceholders = true,
|
|
|
|
completeUnimported = true,
|
|
|
|
staticcheck = true,
|
|
|
|
matcher = 'Fuzzy',
|
|
|
|
diagnosticsDelay = '500ms',
|
|
|
|
symbolMatcher = 'fuzzy',
|
|
|
|
['local'] = get_current_gomod(),
|
|
|
|
-- gofumpt = _GO_NVIM_CFG.lsp_gofumpt or false, -- true|false, -- turn on for new repos, gofmpt is good but also create code turmoils
|
|
|
|
buildFlags = { '-tags', 'integration' },
|
|
|
|
}
|
2022-09-09 18:52:07 +00:00
|
|
|
}
|
|
|
|
},
|
2023-02-07 18:55:59 +00:00
|
|
|
pylsp = {
|
|
|
|
settings = {
|
|
|
|
pylsp = {
|
|
|
|
plugins = {
|
2023-04-29 18:38:10 +00:00
|
|
|
black = { enabled = true},
|
2023-02-07 18:55:59 +00:00
|
|
|
autopep8 = { enabled = false },
|
2023-02-10 19:59:24 +00:00
|
|
|
-- pylint = { enabled = false }, -- disabled in null-ls
|
2023-02-07 18:55:59 +00:00
|
|
|
flake8 = { enabled = false },
|
2023-05-28 10:47:51 +00:00
|
|
|
mccabe = { enabled = false },
|
2023-02-07 18:55:59 +00:00
|
|
|
pycodestyle= { enabled = false},
|
|
|
|
pyflakes = { enabled = false },
|
2023-08-08 01:50:01 +00:00
|
|
|
|
|
|
|
-- install python-lsp-ruff
|
|
|
|
-- if using mason activate venv from mason package
|
|
|
|
-- and install inside venv
|
|
|
|
-- select isort and pycodestyle
|
|
|
|
ruff = { enabled = true, select = {"I", "E"}}
|
2023-02-07 18:55:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2023-04-09 23:23:49 +00:00
|
|
|
lua_ls = {
|
2023-01-30 21:14:14 +00:00
|
|
|
before_init=require("neodev.lsp").before_init,
|
|
|
|
}
|
2022-09-09 18:52:07 +00:00
|
|
|
|
2023-01-28 03:01:20 +00:00
|
|
|
-- FIX: deperecated https://github.com/ray-x/navigator.lua/commit/1b2a0856f4adfffc5c4e785a6779c62759c8c926
|
2023-01-30 21:14:14 +00:00
|
|
|
-- ["neodev"] = {
|
|
|
|
-- library = {
|
|
|
|
-- enabled = true,
|
|
|
|
-- runtime = true,
|
|
|
|
-- -- plugins = true,
|
|
|
|
-- plugins = {"plenary.nvim"},
|
|
|
|
-- -- plugins = {"navigator.lua", "guihua.lua", "go.nvim", "plenary.nvim"},
|
|
|
|
-- types = true,
|
|
|
|
-- },
|
|
|
|
-- setup_jsonls = true,
|
|
|
|
-- },
|
2022-08-26 14:28:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-29 14:46:20 +00:00
|
|
|
M.setup = function()
|
|
|
|
navigator.setup(config)
|
|
|
|
end
|
|
|
|
|
2022-08-31 16:15:21 +00:00
|
|
|
-- make sure LSP is not started automatically
|
|
|
|
-- TODO: how to it per project basis
|
2022-09-09 18:52:07 +00:00
|
|
|
-- M.enable = function()
|
|
|
|
-- local lspconfig = require("lspconfig")
|
|
|
|
-- lspconfig.util.default_config = vim.tbl_extend(
|
|
|
|
-- "force",
|
|
|
|
-- lspconfig.util.default_config,
|
|
|
|
-- {
|
|
|
|
-- autostart = true
|
|
|
|
-- }
|
|
|
|
-- )
|
|
|
|
-- vim.cmd[[
|
|
|
|
-- LspStart
|
|
|
|
-- ]]
|
|
|
|
-- end
|
2022-08-29 14:46:20 +00:00
|
|
|
|
|
|
|
return M
|