Last active
September 10, 2023 12:45
-
-
Save xxxuuu/268dd3d9248094ee189cc88518f7f88b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim.cmd("au FileType go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4") | |
vim.cmd("au FileType vue setlocal noexpandtab tabstop=2 shiftwidth=2 softtabstop=2") | |
-- 显示不可见字符 | |
vim.opt.list = true | |
-- 开启相对行数 | |
vim.opt.relativenumber = true | |
-- Insert Mode 时 jj 映射成 Esc | |
lvim.keys.insert_mode["jj"] = "<Esc>" | |
-- Shift + h/l 左右切换 Tab | |
lvim.keys.normal_mode["<S-l>"] = ":BufferLineCycleNext<CR>" | |
lvim.keys.normal_mode["<S-h>"] = ":BufferLineCyclePrev<CR>" | |
-- option 一般会和系统级快捷键冲突,设置 tt 打开终端 | |
lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = { vim.o.shell, "tt", "Horizontal Terminal", "horizontal", 0.3 } | |
-- 状态栏换成 lualine 的默认布局 | |
-- lvim.builtin.lualine.style = "default" | |
-- 支持透明窗口 | |
-- lvim.transparent_window = true | |
-- 设置主题 | |
lvim.colorscheme = "onedark" | |
lvim.plugins = { | |
-- ----------- | |
-- THEME BEGIN | |
-- ----------- | |
"projekt0n/github-nvim-theme", | |
"rebelot/kanagawa.nvim", | |
"titanzero/zephyrium", | |
"rafamadriz/neon", | |
"Mofiqul/dracula.nvim", | |
"catppuccin/nvim", | |
{ | |
"navarasu/onedark.nvim", | |
config = function() | |
require("onedark").setup { | |
style = "cool" | |
} | |
end, | |
}, | |
"tiagovla/tokyodark.nvim", | |
"folke/tokyonight.nvim", | |
-- --------- | |
-- THEME END | |
-- --------- | |
{ | |
'chipsenkbeil/distant.nvim', | |
branch = 'v0.3', | |
config = function() | |
require('distant').setup { | |
local distant = require('distant') | |
distant:setup() | |
} | |
end | |
}, | |
{ | |
"sindrets/diffview.nvim", | |
event = "BufRead", | |
}, | |
{ | |
"f-person/git-blame.nvim", | |
event = "BufRead", | |
config = function() | |
vim.cmd "highlight default link gitblame SpecialComment" | |
vim.g.gitblame_enabled = 0 | |
end, | |
}, | |
{ | |
"folke/todo-comments.nvim", | |
event = "BufRead", | |
config = function() | |
require("todo-comments").setup() | |
vim.api.nvim_set_keymap("n", "<leader>sT", ":TodoTelescope<cr>", { silent = true }) | |
end, | |
}, | |
{ | |
"phaazon/hop.nvim", | |
event = "BufRead", | |
config = function() | |
require("hop").setup() | |
vim.api.nvim_set_keymap("n", "s", ":HopChar2<cr>", { silent = true }) | |
vim.api.nvim_set_keymap("n", "S", ":HopWord<cr>", { silent = true }) | |
end, | |
}, | |
{ | |
"simrat39/symbols-outline.nvim", | |
config = function () | |
require("symbols-outline").setup { | |
width = 15, | |
} | |
vim.api.nvim_set_keymap("n", "<leader>lo", ":SymbolsOutline<cr>", { silent = true }) | |
end, | |
}, | |
{ | |
"folke/trouble.nvim", | |
dependencies = { "nvim-tree/nvim-web-devicons" }, | |
config = function() | |
lvim.builtin.which_key.mappings["t"] = { | |
name = "+Trouble", | |
r = { "<cmd>Trouble lsp_references<cr>", "References" }, | |
f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" }, | |
d = { "<cmd>Trouble document_diagnostics<cr>", "Diagnostics" }, | |
q = { "<cmd>Trouble quickfix<cr>", "QuickFix" }, | |
l = { "<cmd>Trouble loclist<cr>", "LocationList" }, | |
w = { "<cmd>Trouble workspace_diagnostics<cr>", "Workspace Diagnostics" }, | |
} | |
end, | |
}, | |
{ | |
"kylechui/nvim-surround", | |
version = "*", | |
event = "VeryLazy", | |
config = function() | |
require("nvim-surround").setup() | |
end | |
}, | |
{ | |
"zbirenbaum/copilot-cmp", | |
event = "InsertEnter", | |
dependencies = { "zbirenbaum/copilot.lua" }, | |
config = function() | |
vim.defer_fn(function() | |
require("copilot").setup() -- https://github.com/zbirenbaum/copilot.lua/blob/master/README.md#setup-and-configuration | |
require("copilot_cmp").setup() -- https://github.com/zbirenbaum/copilot-cmp/blob/master/README.md#configuration | |
end, 100) | |
end, | |
}, | |
"olexsmir/gopher.nvim", | |
"leoluz/nvim-dap-go", | |
} | |
------------------------ | |
-- Formatting | |
------------------------ | |
local formatters = require "lvim.lsp.null-ls.formatters" | |
formatters.setup { | |
{ command = "goimports", filetypes = { "go" } }, | |
{ command = "gofumpt", filetypes = { "go" } }, | |
{ command = "goimports-reviser", filetypes = { "go" } }, | |
} | |
lvim.format_on_save = { | |
pattern = { "*.go" }, | |
} | |
------------------------ | |
-- Dap | |
------------------------ | |
local dap_ok, dapgo = pcall(require, "dap-go") | |
if not dap_ok then | |
return | |
end | |
dapgo.setup() | |
------------------------ | |
-- LSP | |
------------------------ | |
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "gopls" }) | |
vim.list_extend(lvim.builtin.treesitter.ensure_installed, { "go", "gomod" }) | |
local lsp_manager = require "lvim.lsp.manager" | |
-- lsp_manager.setup("golangci_lint_ls", { | |
-- on_init = require("lvim.lsp").common_on_init, | |
-- capabilities = require("lvim.lsp").common_capabilities(), | |
-- }) | |
lsp_manager.setup("gopls", { | |
on_attach = function(client, bufnr) | |
require("lvim.lsp").common_on_attach(client, bufnr) | |
local _, _ = pcall(vim.lsp.codelens.refresh) | |
local map = function(mode, lhs, rhs, desc) | |
if desc then | |
desc = desc | |
end | |
vim.keymap.set(mode, lhs, rhs, { silent = true, desc = desc, buffer = bufnr, noremap = true }) | |
end | |
map("n", "<leader>Ci", "<cmd>GoInstallDeps<Cr>", "Install Go Dependencies") | |
map("n", "<leader>CI", "<cmd>GoImpl<Cr>", "Implement Interface") | |
map("n", "<leader>Ct", "<cmd>GoMod tidy<cr>", "Tidy") | |
map("n", "<leader>Ca", "<cmd>GoTestAdd<Cr>", "Add Test") | |
map("n", "<leader>CA", "<cmd>GoTestsAll<Cr>", "Add All Tests") | |
map("n", "<leader>Ce", "<cmd>GoTestsExp<Cr>", "Add Exported Tests") | |
map("n", "<leader>Cg", "<cmd>GoGenerate<Cr>", "Go Generate") | |
map("n", "<leader>Cf", "<cmd>GoGenerate %<Cr>", "Go Generate File") | |
map("n", "<leader>Cc", "<cmd>GoCmt<Cr>", "Generate Comment") | |
map("n", "<leader>dT", "<cmd>lua require('dap-go').debug_test()<cr>", "Debug Test") | |
end, | |
on_init = require("lvim.lsp").common_on_init, | |
capabilities = require("lvim.lsp").common_capabilities(), | |
settings = { | |
gopls = { | |
usePlaceholders = true, | |
gofumpt = true, | |
codelenses = { | |
generate = false, | |
gc_details = true, | |
test = true, | |
tidy = true, | |
}, | |
}, | |
}, | |
}) | |
local status_ok, gopher = pcall(require, "gopher") | |
if not status_ok then | |
return | |
end | |
gopher.setup { | |
commands = { | |
go = "go", | |
gomodifytags = "gomodifytags", | |
gotests = "gotests", | |
impl = "impl", | |
iferr = "iferr", | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment