update format_on_save setup

pull/235/head
ray-x 2 years ago
parent bd2b48fe6b
commit e882757fb2

@ -288,7 +288,11 @@ require'navigator'.setup({
code_lens_action = {enable = true, sign = true, sign_priority = 40, virtual_text = true},
document_highlight = true, -- LSP reference highlight,
-- it might already supported by you setup, e.g. LunarVim
format_on_save = true, -- set to false to disable lsp code format on save (if you are using prettier/efm/formater etc)
format_on_save = true, -- {true|false} set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
-- table: {enable = {'lua', 'go'}, disable = {'javascript', 'typescript'}} to enable/disable specific language
-- enable: a whitelist of language that will be formatted on save
-- disable: a blacklist of language that will not be formatted on save
-- function: function(bufnr) return true end to enable/disable lsp format on save
format_options = {async=false}, -- async: disable by default, the option used in vim.lsp.buf.format({async={true|false}, name = 'xxx'})
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
-- If you using null-ls and want null-ls format your code

@ -294,7 +294,13 @@ Nondefault configuration example:
-- own on_attach
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 disable lsp code format on save (if you are using prettier/efm/formater etc)
format_on_save = true, -- {true|false} set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
-- table: {enable = {'lua', 'go'}, disable = {'javascript', 'typescript'}} to enable/disable specific language
-- enable: a whitelist of language that will be formatted on save
-- disable: a blacklist of language that will not be formatted on save
-- function: function(bufnr) return true end to enable/disable lsp format on save
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
-- only want to enable one lsp server

@ -65,7 +65,11 @@ _NgConfigValues = {
update_in_insert = false, -- update diagnostic message in insert mode
severity_sort = { reverse = true },
},
format_on_save = true, -- set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
format_on_save = true, -- {true|false} set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
-- table: {enable = {'lua', 'go'}, disable = {'javascript', 'typescript'}} to enable/disable specific language
-- enable: a whitelist of language that will be formatted on save
-- disable: a blacklist of language that will not be formatted on save
-- function: function(bufnr) return true end to enable/disable lsp format on save
format_options = { async = false }, -- async: disable by default, I saw something unexpected
disable_nulls_codeaction_sign = true, -- do not show nulls codeactions (as it will alway has a valid action)
disable_format_cap = {}, -- a list of lsp disable file format (e.g. if you using efm or vim-codeformat etc), empty by default

@ -27,6 +27,8 @@ end
local function _update_virtual_text(line, actions)
local namespace = get_namespace()
pcall(api.nvim_buf_clear_namespace, 0, namespace, 0, -1)
local bufnr = api.nvim_get_current_buf()
api.nvim_buf_del_extmark(bufnr, namespace, 1)
if line then
trace(line, actions)
@ -34,7 +36,7 @@ local function _update_virtual_text(line, actions)
local title = actions[1].title
pcall(api.nvim_buf_set_extmark, 0, namespace, line, -1, {
virt_text = { { icon_with_indent .. title, 'LspDiagnosticsSignHint' } },
virt_text = { { icon_with_indent .. title, 'DiagnosticsSignHint' } },
virt_text_pos = 'overlay',
hl_mode = 'combine',
})
@ -45,7 +47,7 @@ local function _update_sign(line)
if vim.tbl_isempty(vim.fn.sign_getdefined(sign_name)) then
vim.fn.sign_define(sign_name, {
text = config.icons.code_action_icon,
texthl = 'LspDiagnosticsSignHint',
texthl = 'DiagnosticsSignHint',
})
end
local winid = get_current_winid()
@ -110,16 +112,13 @@ function code_action:render_action_virtual_text(line, diagnostics)
end
end
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)
else
_update_virtual_text(line, actions)
end
else
_update_virtual_text(line, actions)
end
if not config.lsp.code_action.virtual_text then
return
end
if need_check_diagnostic[vim.bo.filetype] and not next(diagnostics) then
_update_virtual_text()
else
_update_virtual_text(line, actions)
end
end
end
@ -190,7 +189,7 @@ code_action.range_code_action = function(startpos, endpos)
vim.ui.input = require('guihua.input').input
if vim.fn.has('nvim-0.8') then
vim.lsp.buf.code_action({context=context ,range={start = startpos, ['end'] = endpos}})
vim.lsp.buf.code_action({ context = context, range = { start = startpos, ['end'] = endpos } })
else
vim.lsp.buf.range_code_action(context, startpos, endpos)
end

Loading…
Cancel
Save