diff --git a/README.md b/README.md index 7eb08b3..0257b9b 100644 --- a/README.md +++ b/README.md @@ -215,7 +215,6 @@ require'navigator'.setup({ -- please check mapping.lua for all keymaps treesitter_analysis = true, -- treesitter variable context transparency = 50, -- 0 ~ 100 blur the main window, 100: fully transparent, 0: opaque, set to nil or 100 to disable it - code_action_prompt = {enable = true, sign = true, sign_priority = 40, virtual_text = true}, icons = { -- Code action code_action_icon = "🏏", @@ -225,8 +224,9 @@ require'navigator'.setup({ -- refer to lua/navigator.lua for more icons setups }, lspinstall = false, -- set to true if you would like use the lsp installed by lspinstall - lsp = { + code_action = {enable = true, sign = true, sign_priority = 40, virtual_text = true}, + code_lens_action = {enable = true, sign = true, sign_priority = 40, virtual_text = true}, format_on_save = true, -- set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc) disable_format_cap = {"sqls", "sumneko_lua", "gopls"}, -- a list of lsp disable format capacity (e.g. if you using efm or vim-codeformat etc), empty {} by default disable_lsp = {'pylsd', 'sqlls'}, -- a list of lsp server disabled for your project, e.g. denols and tsserver you may diff --git a/lua/navigator.lua b/lua/navigator.lua index d058338..29171a4 100644 --- a/lua/navigator.lua +++ b/lua/navigator.lua @@ -17,13 +17,16 @@ _NgConfigValues = { -- -- your on_attach will be called at end of navigator on_attach -- end, ts_fold = false, - code_action_prompt = {enable = true, sign = true, sign_priority = 40, virtual_text = true}, - code_lens_action_prompt = {enable = true, sign = true, sign_priority = 40, virtual_text = true}, + -- code_action_prompt = {enable = true, sign = true, sign_priority = 40, virtual_text = true}, + -- code_lens_action_prompt = {enable = true, sign = true, sign_priority = 40, virtual_text = true}, treesitter_analysis = true, -- treesitter variable context transparency = 50, -- 0 ~ 100 blur the main window, 100: fully transparent, 0: opaque, set to nil to disable it signature_help_cfg = nil, -- if you would like to init lsp_signature plugin in navigator, pass in signature help -- setup here. if it is nil, navigator will not init signature help lsp = { + + code_action = {enable = true, sign = true, sign_priority = 40, virtual_text = true, virtual_text_icon = true}, + code_lens_action = {enable = true, sign = true, sign_priority = 40, virtual_text = true, virtual_text_icon = true}, format_on_save = true, -- set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc) disable_format_cap = {}, -- a list of lsp disable file format (e.g. if you using efm or vim-codeformat etc), empty by default disable_lsp = nil, -- a list of lsp server disabled for your project, e.g. denols and tsserver you may @@ -90,6 +93,13 @@ vim.cmd( M.deprecated = function(cfg) local warn = require'navigator.util'.warn + if cfg.code_action_prompt then + warn("code_action_prompt moved to lsp.code_action") + end + if cfg.code_lens_action_prompt then + warn("code_lens_action_prompt moved to lsp.code_lens_action") + end + if cfg.lsp ~= nil and cfg.lsp.disable_format_ft ~= nil and cfg.lsp.disable_format_ft ~= {} then warn('disable_format_ft renamed to disable_format_cap') end @@ -148,7 +158,7 @@ M.setup = function(cfg) require("navigator.implementation") -- log("navigator loader") - if _NgConfigValues.code_action_prompt.enable then + if _NgConfigValues.lsp.code_action_prompt.enable then vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'navigator.codeAction'.code_action_prompt()]] end diff --git a/lua/navigator/codeAction.lua b/lua/navigator/codeAction.lua index a830df9..14af099 100644 --- a/lua/navigator/codeAction.lua +++ b/lua/navigator/codeAction.lua @@ -5,7 +5,7 @@ local code_action = {} local gui = require "navigator.gui" local config = require("navigator").config_values() local api = vim.api -trace = log +-- trace = log local sign_name = "NavigatorLightBulb" @@ -233,7 +233,7 @@ local function _update_sign(line) if line then -- log("updatasign", line, sign_group, sign_name) vim.fn.sign_place(line, sign_group, sign_name, "%", - {lnum = line + 1, priority = config.code_action_prompt.sign_priority}) + {lnum = line + 1, priority = config.lsp.code_action.sign_priority}) code_action[winid].lightbulb_line = line end end @@ -245,15 +245,15 @@ function code_action:render_action_virtual_text(line, diagnostics) return function(err, actions, context) if actions == nil or type(actions) ~= "table" or vim.tbl_isempty(actions) then -- no actions cleanup - if config.code_action_prompt.virtual_text then + if config.lsp.code_action.virtual_text then _update_virtual_text(nil) end - if config.code_action_prompt.sign then + if config.lsp.code_action.sign then _update_sign(nil) end else trace(err, line, diagnostics, actions, context) - if config.code_action_prompt.sign then + if config.lsp.code_action.sign then if need_check_diagnostic[vim.bo.filetype] then if next(diagnostics) == nil then _update_sign(nil) @@ -266,7 +266,7 @@ function code_action:render_action_virtual_text(line, diagnostics) end end - if config.code_action_prompt.virtual_text then + if config.lsp.code_action.virtual_text then if need_check_diagnostic[vim.bo.filetype] then if next(diagnostics) == nil then _update_virtual_text(nil) diff --git a/lua/navigator/codelens.lua b/lua/navigator/codelens.lua index 982442e..f7eedf0 100644 --- a/lua/navigator/codelens.lua +++ b/lua/navigator/codelens.lua @@ -39,7 +39,7 @@ local function _update_sign(line) if line then -- log("updatasign", line, sign_group, sign_name) vim.fn.sign_place(line, sign_group, sign_name, "%", - {lnum = line + 1, priority = config.code_lens_action_prompt.sign_priority}) + {lnum = line + 1, priority = config.lsp.code_lens_action.sign_priority}) code_lens_action[winid].lightbulb_line = line end end