fix: golang lsp action

This commit is contained in:
2023-02-26 21:29:03 +08:00
parent 842191f4d0
commit 1f3896974d
38 changed files with 877 additions and 456 deletions

7
lua/plugins/auto-do.lua Normal file
View File

@@ -0,0 +1,7 @@
require("auto-save").setup({
trigger_events = { "InsertLeave", "BufLeave", "BufWinLeave" },
})
require("nvim-autopairs").setup({})
require("nvim-ts-autotag").setup({})
require("unimpaired").setup({})
require("luasnip.loaders.from_vscode").lazy_load()

View File

@@ -1,3 +0,0 @@
require("auto-save").setup {
trigger_events = {"InsertLeave", "BufLeave", "BufWinLeave"},
}

View File

@@ -1,19 +1,19 @@
require("bufferline").setup({
options = {
options = {
-- 使用 nvim 内置lsp
diagnostics = "nvim_lsp",
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict)
return "("..count..")"
end,
always_show_bufferline = false,
-- 左侧让出 nvim-tree 的位置
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
highlight = "Directory",
text_align = "left",
},
},
},
return "(" .. count .. ")"
end,
always_show_bufferline = false,
-- 左侧让出 nvim-tree 的位置
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
highlight = "Directory",
text_align = "left",
},
},
},
})

7
lua/plugins/debug.lua Normal file
View File

@@ -0,0 +1,7 @@
require("dapui").setup()
require("nvim-dap-virtual-text").setup()
-- IMPORTANT: make sure to setup neodev BEFORE lspconfig
require("neodev").setup({
-- add any options here, or leave empty to use the default settings
library = { plugins = { "nvim-dap-ui" }, types = true },
})

View File

@@ -7,36 +7,41 @@ vim.opt.termguicolors = true
-- OR setup with some options
require("nvim-tree").setup({
sort_by = "case_sensitive",
view = {
width = 30,
mappings = {
list = {
{ key = "u", action = "dir_up" },
},
},
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
auto_reload_on_write = true,
sort_by = "case_sensitive",
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_root = true,
},
filters = { custom = { ".git" } },
view = {
width = 30,
mappings = {
list = {
{ key = "u", action = "dir_up" },
},
},
},
renderer = {
group_empty = true,
},
})
local function open_nvim_tree(data)
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
if not directory then
return
end
if not directory then
return
end
-- change to the directory
vim.cmd.cd(data.file)
-- change to the directory
vim.cmd.cd(data.file)
-- open the tree
require("nvim-tree.api").tree.open()
-- open the tree
require("nvim-tree.api").tree.open()
end
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })

View File

@@ -1,9 +1,9 @@
require("go").setup()
local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require("go.format").goimport()
end,
group = format_sync_grp,
pattern = "*.go",
callback = function()
require("go.format").goimport()
end,
group = format_sync_grp,
})

View File

@@ -3,8 +3,8 @@ vim.opt.listchars:append("space:⋅")
vim.opt.listchars:append("eol:↴")
require("indent_blankline").setup({
show_current_context = true,
show_current_context_start = true,
show_end_of_line = true,
space_char_blankline = " ",
show_current_context = true,
show_current_context_start = true,
show_end_of_line = true,
space_char_blankline = " ",
})

View File

@@ -2,11 +2,11 @@ require("leap").add_default_mappings()
require("leap").opts.highlight_unlabeled_phase_one_targets = true
require("flit").setup({
keys = { f = "f", F = "F", t = "t", T = "T" },
-- A string like "nv", "nvo", "o", etc.
labeled_modes = "v",
multiline = true,
-- Like `leap`s similar argument (call-specific overrides).
-- E.g.: opts = { equivalence_classes = {} }
opts = {},
keys = { f = "f", F = "F", t = "t", T = "T" },
-- A string like "nv", "nvo", "o", etc.
labeled_modes = "v",
multiline = true,
-- Like `leap`s similar argument (call-specific overrides).
-- E.g.: opts = { equivalence_classes = {} }
opts = {},
})

View File

@@ -0,0 +1,9 @@
-- 快捷键提示
require("which-key").setup({})
-- 自定义快捷键
require("legendary").setup({
which_key = { auto_register = true },
extensions = {
-- load keymaps and commands from nvim-tree.lua
},
})

View File

@@ -1 +0,0 @@
require("numbers").setup({})

View File

@@ -1,13 +1,13 @@
require("lspsaga").setup({
ui = {
colors = require("catppuccin.groups.integrations.lsp_saga").custom_colors(),
kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(),
},
ui = {
colors = require("catppuccin.groups.integrations.lsp_saga").custom_colors(),
kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(),
},
})
require("lsp-colors").setup({
Error = "#db4b4b",
Warning = "#e0af68",
Information = "#0db9d7",
Hint = "#10B981"
Error = "#db4b4b",
Warning = "#e0af68",
Information = "#0db9d7",
Hint = "#10B981",
})

View File

@@ -1,40 +1,40 @@
require("lualine").setup({
options = {
icons_enabled = true,
theme = "tokyonight",
component_separators = { left = "|", right = "|" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
options = {
icons_enabled = true,
theme = "tokyonight",
component_separators = { left = "|", right = "|" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
})

View File

@@ -1,33 +1,36 @@
require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
})
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"rust_analyzer",
"gopls",
"golangci_lint_ls",
"tsserver",
"volar",
"taplo",
"lemminx",
"yamlls",
"sqlls",
"jsonls",
"jdtls",
"bashls",
"cssls",
"dockerls",
"docker_compose_language_service",
"eslint",
"html",
},
automatic_installation = true,
ensure_installed = {
"clangd",
"emmet_ls",
"cmake",
"gradle_ls",
"kotlin_language_server",
"lua_ls",
"rust_analyzer",
"gopls",
"golangci_lint_ls",
"tsserver",
"volar",
"taplo",
"yamlls",
"jsonls",
"jdtls",
"bashls",
"cssls",
"dockerls",
"docker_compose_language_service",
"eslint",
"html",
},
automatic_installation = true,
})

View File

@@ -1,43 +1,13 @@
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.buf,
null_ls.builtins.formatting.clang_format,
null_ls.builtins.formatting.dart_format,
null_ls.builtins.formatting.eslint_d,
null_ls.builtins.formatting.fixjson,
sources = {
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.gofmt,
null_ls.builtins.formatting.goimports_reviser,
null_ls.builtins.formatting.google_java_format,
null_ls.builtins.formatting.markdownlint,
null_ls.builtins.formatting.markdown_toc,
null_ls.builtins.formatting.rustfmt,
null_ls.builtins.formatting.shfmt,
null_ls.builtins.formatting.taplo,
null_ls.builtins.formatting.xmllint,
null_ls.builtins.formatting.yamlfmt,
null_ls.builtins.formatting.eslint_d,
null_ls.builtins.formatting.protolint,
-- 诊断
null_ls.builtins.diagnostics.buf,
null_ls.builtins.diagnostics.checkmake,
null_ls.builtins.diagnostics.checkstyle,
null_ls.builtins.diagnostics.clang_check,
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.eslint_d,
null_ls.builtins.diagnostics.gitlint,
null_ls.builtins.diagnostics.golangci_lint,
null_ls.builtins.diagnostics.jsonlint,
null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.diagnostics.yamllint,
-- 动作
null_ls.builtins.code_actions.eslint_d,
null_ls.builtins.code_actions.gitrebase,
null_ls.builtins.code_actions.gitsigns,
null_ls.builtins.code_actions.gomodifytags,
null_ls.builtins.code_actions.shellcheck,
null_ls.builtins.code_actions.xo,
-- 完成
null_ls.builtins.completion.luasnip,
},
null_ls.builtins.diagnostics.protolint,
},
})

12
lua/plugins/peaceful.lua Normal file
View File

@@ -0,0 +1,12 @@
-- url罗列
require("urlview").setup({})
-- 行号模式切换
require("numbers").setup({})
-- 终端管理
require("toggleterm").setup({})
-- 错误列表
require("trouble").setup({})
-- ui配置
require("dressing").setup({})
-- lsp状态
require("fidget").setup({})

View File

@@ -1 +1,47 @@
require("telescope").setup({})
-- 模糊搜索
local telescope = require("telescope")
local actions = require("telescope.actions")
local themes = require("telescope.themes")
telescope.setup({
defaults = themes.get_dropdown({
path_display = { "absolute" },
file_ignore_patterns = { ".git/", "node_modules" },
mappings = {
i = {
["<Down>"] = actions.cycle_history_next,
["<Up>"] = actions.cycle_history_prev,
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
},
}),
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case"
},
["ui-select"] = {
require("telescope.themes").get_dropdown({
-- even more opts
}),
},
},
pickers = {
find_files = {
hidden = true,
no_ignore = true,
no_ignore_parent = true,
},
buffers = {
sort_mru = true,
},
},
})
telescope.load_extension("ui-select")
telescope.load_extension("fzf")

View File

@@ -1 +0,0 @@
require("toggleterm").setup({})

View File

@@ -28,6 +28,7 @@ require("nvim-treesitter.configs").setup({
"vim",
"vue",
"yaml",
"proto",
},
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = true,
@@ -39,15 +40,15 @@ require("nvim-treesitter.configs").setup({
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<CR>",
node_incremental = "<CR>",
node_decremental = "<BS>",
scope_incremental = "<TAB>",
},
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<CR>",
node_incremental = "<CR>",
node_decremental = "<BS>",
scope_incremental = "<TAB>",
},
},
indent = {
enable = true,
},

View File

@@ -1 +0,0 @@
require("trouble").setup({})

52
lua/plugins/wilder.lua Normal file
View File

@@ -0,0 +1,52 @@
local G = require("core.g")
local wilder = require("wilder")
wilder.setup({
modes = { ":", "/", "?" },
next_key = 0,
previous_key = 0,
reject_key = 0,
accept_key = 0,
})
wilder.set_option("pipeline", {
wilder.branch(
{
wilder.check(function(_, x)
return G.fn.empty(x)
end),
wilder.history(15),
},
wilder.cmdline_pipeline({
fuzzy = 1,
fuzzy_filter = wilder.vim_fuzzy_filter(),
}),
wilder.search_pipeline()
),
wilder.debounce(10),
})
wilder.set_option(
"renderer",
wilder.popupmenu_renderer(wilder.popupmenu_border_theme({
highlights = {
accent = "WilderAccent",
selected_accent = "WilderSelectedAccent",
},
highlighter = wilder.basic_highlighter(),
left = { " ", wilder.popupmenu_devicons() },
right = { " ", wilder.popupmenu_scrollbar() },
border = "rounded",
max_height = 17, -- 最大高度限制 因为要计算上下 所以17支持最多15个选项
}))
)
G.cmd("silent! UpdateRemotePlugins")
G.hi({
WilderAccent = { fg = 12 },
WilderSelectedAccent = { fg = 12, bg = 239 },
})
G.map({
{ "c", "<tab>", [[wilder#in_context() ? wilder#next() : '<tab>']], { noremap = true, expr = true } },
{ "c", "<Down>", [[wilder#in_context() ? wilder#next() : '<down>']], { noremap = true, expr = true } },
{ "c", "<up>", [[wilder#in_context() ? wilder#previous() : '<up>']], { noremap = true, expr = true } },
{ "c", "0", "0", {} }, -- 不清楚原因导致0无法使用 强制覆盖
})