Поправил кучку недостатков в neovim
This commit is contained in:
parent
28a7b1f678
commit
74e201e92c
11 changed files with 444 additions and 234 deletions
|
@ -18,6 +18,7 @@ vim.g.maplocalleader = " "
|
|||
vim.g.colorcolumn = 120
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
vim.cmd("filetype plugin indent on")
|
||||
|
||||
require("options")
|
||||
require("plugins")
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"nvim-dap": { "branch": "master", "commit": "8df427aeba0a06c6577dc3ab82de3076964e3b8d" },
|
||||
"nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "12506bdaccd94964d4fb40367e36ade1960c8947" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "1b801f68d09e70e59e6dd967b663b6d84ee3e87d" },
|
||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "582ae48c9e43d2bcd55dfcc8e2e7a1f29065d924" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "94ea4f436d2b59c80f02e293466c374584f03b8c" },
|
||||
|
@ -30,7 +30,5 @@
|
|||
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
|
||||
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
|
||||
"smartcolumn.nvim": { "branch": "main", "commit": "92f3773af80d674f1eb61e112dca79e2fa449fd1" },
|
||||
"telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" },
|
||||
"vim-snippets": { "branch": "master", "commit": "f0a3184d9f90b96b044d5914625a25c554d7f301" }
|
||||
"telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" }
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ vim.api.nvim_create_autocmd("BufEnter", {
|
|||
return
|
||||
end
|
||||
vim.schedule(function()
|
||||
vim.cmd("nohlsearch")
|
||||
local treeapi = require("nvim-tree.api")
|
||||
treeapi.tree.find_file({
|
||||
update_root = false,
|
||||
|
@ -134,6 +135,17 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, {
|
|||
require("nvim-tree.api").tree.open()
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "go",
|
||||
callback = function()
|
||||
vim.opt_local.expandtab = false
|
||||
vim.opt_local.tabstop = 4
|
||||
vim.opt_local.shiftwidth = 4
|
||||
vim.opt_local.autoindent = true
|
||||
vim.opt_local.smartindent = true
|
||||
vim.opt_local.cindent = false
|
||||
end,
|
||||
})
|
||||
-- vim.api.nvim_create_autocmd("InsertEnter", {
|
||||
-- pattern = "*",
|
||||
-- command = "set norelativenumber",
|
||||
|
|
|
@ -37,8 +37,9 @@ local options = {
|
|||
--foldexpr = "nvim_treesitter#foldexpr()",
|
||||
foldlevelstart = 0,
|
||||
foldenable = true,
|
||||
scrolloff = 999,
|
||||
}
|
||||
|
||||
vim.opt.formatoptions:append({ r = true, o = true })
|
||||
vim.opt.shortmess:append("c")
|
||||
|
||||
for k, v in pairs(options) do
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
local source_mapping = {
|
||||
buffer = "[Buffer]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[Lua]",
|
||||
luasnip = "[Snip]",
|
||||
path = "[Path]",
|
||||
}
|
||||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
|
@ -18,33 +25,51 @@ return {
|
|||
config = function()
|
||||
require("plugins.snippets")
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<C-K>",
|
||||
function()
|
||||
require("luasnip").expand()
|
||||
end,
|
||||
silent = true,
|
||||
},
|
||||
{
|
||||
"<C-L>",
|
||||
function()
|
||||
require("luasnip").jump(1)
|
||||
end,
|
||||
silent = true,
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local source_mapping = {
|
||||
buffer = "[Buffer]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[Lua]",
|
||||
path = "[Path]",
|
||||
}
|
||||
cmp.setup({
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if require("luasnip").expand_or_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if require("luasnip").jumpable(-1) then
|
||||
{
|
||||
"<C-J>",
|
||||
function()
|
||||
require("luasnip").jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
end,
|
||||
silent = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
-- preselect = require("cmp").PreselectMode.None,
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
|
||||
confirmation = {
|
||||
default_behavior = require("cmp").ConfirmBehavior.Replace,
|
||||
},
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noinsert,noselect",
|
||||
keyword_length = 2,
|
||||
},
|
||||
mapping = require("cmp").mapping.preset.insert({
|
||||
["<C-b>"] = require("cmp").mapping.scroll_docs(-4),
|
||||
["<C-f>"] = require("cmp").mapping.scroll_docs(4),
|
||||
["<C-Space>"] = require("cmp").mapping.complete(),
|
||||
["<C-e>"] = require("cmp").mapping.abort(),
|
||||
["<CR>"] = require("cmp").mapping.confirm({ select = false }),
|
||||
["<Right>"] = require("cmp").mapping.confirm({ select = true }),
|
||||
}),
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
|
@ -57,13 +82,12 @@ return {
|
|||
return vim_item
|
||||
end,
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
sources = require("cmp").config.sources({
|
||||
{ name = "nvim_lsp", priority = 1000 },
|
||||
{ name = "luasnip", priority = 750 },
|
||||
{ name = "path", priority = 500 },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,3 +1,103 @@
|
|||
local default_config = {
|
||||
delve = {
|
||||
path = "dlv",
|
||||
initialize_timeout_sec = 20,
|
||||
port = "${port}",
|
||||
args = {},
|
||||
build_flags = "",
|
||||
-- Automatically handle the issue on delve Windows versions < 1.24.0
|
||||
-- where delve needs to be run in attched mode or it will fail (actually crashes).
|
||||
detached = vim.fn.has("win32") == 0,
|
||||
output_mode = "remote",
|
||||
},
|
||||
tests = {
|
||||
verbose = false,
|
||||
},
|
||||
}
|
||||
|
||||
local function setup_go_configuration(dap, configs)
|
||||
local common_debug_configs = {
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug",
|
||||
request = "launch",
|
||||
program = "${file}",
|
||||
buildFlags = configs.delve.build_flags,
|
||||
outputMode = configs.delve.output_mode,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug (Arguments)",
|
||||
request = "launch",
|
||||
program = "${file}",
|
||||
args = get_arguments,
|
||||
buildFlags = configs.delve.build_flags,
|
||||
outputMode = configs.delve.output_mode,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug (Arguments & Build Flags)",
|
||||
request = "launch",
|
||||
program = "${file}",
|
||||
args = get_arguments,
|
||||
buildFlags = get_build_flags,
|
||||
outputMode = configs.delve.output_mode,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug Package",
|
||||
request = "launch",
|
||||
program = "${fileDirname}",
|
||||
buildFlags = configs.delve.build_flags,
|
||||
outputMode = configs.delve.output_mode,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Attach",
|
||||
mode = "local",
|
||||
request = "attach",
|
||||
processId = filtered_pick_process,
|
||||
buildFlags = configs.delve.build_flags,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug test",
|
||||
request = "launch",
|
||||
mode = "test",
|
||||
program = "${file}",
|
||||
buildFlags = configs.delve.build_flags,
|
||||
outputMode = configs.delve.output_mode,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug test (go.mod)",
|
||||
request = "launch",
|
||||
mode = "test",
|
||||
program = "./${relativeFileDirname}",
|
||||
buildFlags = configs.delve.build_flags,
|
||||
outputMode = configs.delve.output_mode,
|
||||
},
|
||||
}
|
||||
|
||||
if dap.configurations.go == nil then
|
||||
dap.configurations.go = {}
|
||||
end
|
||||
|
||||
for _, config in ipairs(common_debug_configs) do
|
||||
table.insert(dap.configurations.go, config)
|
||||
end
|
||||
|
||||
if configs == nil or configs.dap_configurations == nil then
|
||||
return
|
||||
end
|
||||
|
||||
for _, config in ipairs(configs.dap_configurations) do
|
||||
if config.type == "go" then
|
||||
table.insert(dap.configurations.go, config)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
"leoluz/nvim-dap-go",
|
||||
dependencies = { "mfussenegger/nvim-dap" },
|
||||
|
@ -13,6 +113,10 @@ return {
|
|||
args = { "dap", "-l", "127.0.0.1:${port}" },
|
||||
},
|
||||
}
|
||||
|
||||
setup_go_configuration(dap, default_config)
|
||||
|
||||
dap.defaults.fallback.terminal_win_cmd = "enew | set filetype=dap-terminal"
|
||||
dap.listeners.before.attach.dapui_config = function()
|
||||
dapui.open()
|
||||
end
|
||||
|
@ -25,29 +129,30 @@ return {
|
|||
dap.listeners.before.event_exited.dapui_config = function()
|
||||
dapui.close()
|
||||
end
|
||||
|
||||
vim.api.nvim_set_hl(0, "DapBreakpoint", { ctermbg = 0, fg = "#993939", bg = "#31353f" })
|
||||
vim.api.nvim_set_hl(0, "DapLogPoint", { ctermbg = 0, fg = "#61afef", bg = "#31353f" })
|
||||
vim.api.nvim_set_hl(0, "DapStopped", { ctermbg = 0, fg = "#98c379", bg = "#31353f" })
|
||||
|
||||
vim.fn.sign_define(
|
||||
"DapBreakpoint",
|
||||
{ text = "🐞", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" }
|
||||
{ text = "!", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" }
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"DapBreakpointCondition",
|
||||
{ text = "ﳁ", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" }
|
||||
{ text = "?", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" }
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"DapBreakpointRejected",
|
||||
{ text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" }
|
||||
{ text = "RJ", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" }
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"DapLogPoint",
|
||||
{ text = "", texthl = "DapLogPoint", linehl = "DapLogPoint", numhl = "DapLogPoint" }
|
||||
{ text = "i", texthl = "DapLogPoint", linehl = "DapLogPoint", numhl = "DapLogPoint" }
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"DapStopped",
|
||||
{ text = "", texthl = "DapStopped", linehl = "DapStopped", numhl = "DapStopped" }
|
||||
{ text = "→", texthl = "DapStopped", linehl = "DapStopped", numhl = "DapStopped" }
|
||||
)
|
||||
end,
|
||||
keys = {
|
||||
|
|
|
@ -37,8 +37,8 @@ return {
|
|||
},
|
||||
opts = {
|
||||
icons = {
|
||||
expanded = "▾",
|
||||
collapsed = "▸",
|
||||
expanded = "[-]",
|
||||
collapsed = "[+]",
|
||||
},
|
||||
mappings = {
|
||||
open = "o",
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
require("luasnip").config.setup({
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local rep = require("luasnip.extras").rep
|
||||
|
||||
ls.config.setup({
|
||||
history = true,
|
||||
update_events = "TextChanged,TextChangedI",
|
||||
})
|
||||
|
@ -6,3 +18,4 @@ require("luasnip.loaders.from_vscode").lazy_load()
|
|||
require("luasnip.loaders.from_vscode").lazy_load({
|
||||
paths = { vim.fn.stdpath("config") .. "/snippets" },
|
||||
})
|
||||
ls.add_snippets("json", require("snippets.json"))
|
||||
|
|
44
nvim/lua/snippets/json.lua
Normal file
44
nvim/lua/snippets/json.lua
Normal file
|
@ -0,0 +1,44 @@
|
|||
local ls = require("luasnip")
|
||||
-- some shorthands...
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local l = require("luasnip.extras").lambda
|
||||
local rep = require("luasnip.extras").rep
|
||||
local p = require("luasnip.extras").partial
|
||||
local m = require("luasnip.extras").match
|
||||
local n = require("luasnip.extras").nonempty
|
||||
local dl = require("luasnip.extras").dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local types = require("luasnip.util.types")
|
||||
local conds = require("luasnip.extras.conditions")
|
||||
local conds_expand = require("luasnip.extras.conditions.expand")
|
||||
|
||||
return {
|
||||
s(
|
||||
"launch",
|
||||
fmt(
|
||||
[[
|
||||
{{
|
||||
"name": "Launch {1}",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"program": "${{workspaceFolder}}/cmd/{2}",
|
||||
"args": [{3}],
|
||||
"outputMode": "remote"
|
||||
}}{4}]],
|
||||
{
|
||||
i(1),
|
||||
rep(1),
|
||||
i(2),
|
||||
i(0),
|
||||
}
|
||||
)
|
||||
),
|
||||
}
|
|
@ -16,8 +16,13 @@
|
|||
"prefix": "construct"
|
||||
},
|
||||
"if err := ...; err != nil": {
|
||||
"prefix": "iferr",
|
||||
"prefix": "iferrr",
|
||||
"body": "if err := ${1}; err != nil {\n\t${2:return ${3:nil, }${4:err}}\n}",
|
||||
"description": "Snippet for if err := ...; err != nil"
|
||||
},
|
||||
"if err != nil": {
|
||||
"prefix": "iferr",
|
||||
"body": "if err != nil {\n\t${1:return ${2:nil, }${3:err}}\n}",
|
||||
"description": "Snippet for if err != nil"
|
||||
}
|
||||
}
|
||||
|
|
351
zsh/p10k.zsh
351
zsh/p10k.zsh
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue