This commit is contained in:
blob42 2023-01-30 22:01:49 +01:00
parent 465dbe3de7
commit dceac7591d
5 changed files with 86 additions and 2 deletions

View File

@ -1001,7 +1001,7 @@ M.gitsigns = {
["<leader>gr"] = { "<cmd> lua require'gitsigns'.reset_buffer()<CR>", ["<leader>gr"] = { "<cmd> lua require'gitsigns'.reset_buffer()<CR>",
"Reset the lines of all hunks in the buffer", "Reset the lines of all hunks in the buffer",
}, },
["<leader>gp"] = { "<cmd> lua require'gitsigns'.preview_hunk()<CR>", ["<leader>gpr"] = { "<cmd> lua require'gitsigns'.preview_hunk()<CR>",
"Git preview hunk", "Git preview hunk",
}, },
["<leader>gu"] = { "<cmd> lua require'gitsigns'.undo_stage_hunk()<CR>", ["<leader>gu"] = { "<cmd> lua require'gitsigns'.undo_stage_hunk()<CR>",
@ -1104,4 +1104,15 @@ M.refactoring = {
} }
} }
M.null_ls = {
plugin = true,
n = {
["<leader>nlr"] = {function()
require('null-ls').toggle({
name = 'revive'
})
end, "null-ls toggle golang linter <revive>"},
}
}
return M return M

View File

@ -1,3 +1,8 @@
local ok, null_ls = pcall(require, 'null-ls')
if not ok then
vim.notify("missing module null-ls", vim.log.levels.WARN)
end
local M = {} local M = {}
local config = { local config = {
@ -13,10 +18,15 @@ local config = {
dap_debug_keymap = false, dap_debug_keymap = false,
-- dap_debug_gui = false, -- dap_debug_gui = false,
-- dap_debug_vt = false, -- dap_debug_vt = false,
log_path = vim.fn.stdpath('cache') .. '/gonvim.log',
} }
function M.setup() function M.setup()
require("go").setup(config) require("go").setup(config)
local gotest = require('go.null_ls').gotest()
local gotest_codeaction = require("go.null_ls").gotest_action()
null_ls.register(gotest)
null_ls.register(gotest_codeaction)
end end
return M return M

View File

@ -0,0 +1,47 @@
local ok, null_ls = pcall(require, 'null-ls')
if not ok then
vim.notify("missing module null-ls", vim.log.levels.WARN)
return
end
local vim, api = vim, vim.api
local M = {}
M.config = {
debounce = 1000,
default_timeout = 5000,
sources = {
null_ls.builtins.code_actions.gitsigns,
-- null_ls.builtins.diagnostics.golangci_lint,
-- golang revive
null_ls.builtins.diagnostics.revive,
},
on_attach = function(client, bufnr)
local util = require('navigator.util')
local log = util.log
local trace = util.trace
require('navigator.lspclient.highlight').add_highlight()
require('navigator.lspclient.highlight').diagnositc_config_sign()
api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
require('navigator.lspclient.mapping').setup({
client = client,
bufnr = bufnr,
})
if client.server_capabilities.documentHighlightProvider == true then
trace('attaching doc highlight: ', bufnr, client.name)
vim.defer_fn(function()
require('navigator.dochighlight').documentHighlight(bufnr)
end, 50) -- allow a bit time for it to settle down
else
log('skip doc highlight: ', bufnr, client.name)
end
require('navigator.lspclient.lspkind').init()
end
}
M.setup = function()
null_ls.setup(M.config)
end
return M

View File

@ -610,6 +610,16 @@ return {
}, -- }}} }, -- }}}
["jose-elias-alvarez/null-ls.nvim"] = {
requires = {"nvim-lua/plenary.nvim"},
setup = function()
require('core.utils').load_mappings 'null_ls'
end,
config = function()
require("custom.plugins.configs.null-ls").setup()
end,
},
-- side panel with symbols (replaced by Navigator :LspSymbols cmd) -- side panel with symbols (replaced by Navigator :LspSymbols cmd)
-- ["liuchengxu/vista.vim"] = { -- ["liuchengxu/vista.vim"] = {
-- cmd = "Vista", -- cmd = "Vista",
@ -716,6 +726,7 @@ return {
-- after = {"nvim-lspconfig", "navigator.lua", "guihua.lua"}, -- after = {"nvim-lspconfig", "navigator.lua", "guihua.lua"},
ft = { "go" }, ft = { "go" },
opt = true, opt = true,
after = {"null-ls.nvim"},
config = function() config = function()
require("custom.plugins.configs.gonvim").setup() require("custom.plugins.configs.gonvim").setup()
require("core.utils").load_mappings "gonvim" require("core.utils").load_mappings "gonvim"

View File

@ -107,6 +107,11 @@ return {
local Lsp = vim.lsp.util.get_progress_messages()[1] local Lsp = vim.lsp.util.get_progress_messages()[1]
-- hide spammy null-ls progress
if Lsp and Lsp.name:match "null%-ls" then
return ""
end
if vim.o.columns < 120 or not Lsp then if vim.o.columns < 120 or not Lsp then
return "" return ""
end end