master
spike 2 years ago
parent bfeb426218
commit be44c24b1f

@ -0,0 +1 @@
set formatoptions+=r " auto add comments on line return

@ -1,10 +1,7 @@
local c = require("base46.colors") local c = require("base46.colors")
local g = vim.g
local M = {}
local colors = require("base46").get_theme_tb "base_30" local colors = require("base46").get_theme_tb "base_30"
local theme = require("base46").get_theme_tb "base_16" -- local theme = require("base46").get_theme_tb "base_16"
local ts_context_hl = c.change_hex_saturation(colors["yellow"], -20) local ts_context_hl = c.change_hex_saturation(colors["yellow"], -20)
local ts_context_hl = c.change_hex_lightness(ts_context_hl, -55) local ts_context_hl = c.change_hex_lightness(ts_context_hl, -55)
@ -30,3 +27,4 @@ end
-- setup section -- setup section
set_hl() set_hl()

@ -22,7 +22,7 @@ M.general = { --{{{
["<C-s>"] = { "<cmd> update <CR>", "update file (save on changes)" }, ["<C-s>"] = { "<cmd> update <CR>", "update file (save on changes)" },
-- luasnip change choice -- luasnip change choice
["<C-u>"] = { "<Plug>luasnip-next-choice", "change luasnip choice" }, ["<C-l>"] = { "<Plug>luasnip-next-choice", "change luasnip choice" },
-- ["<C-u>"] = { "<cmd>lua require('luasnip.extras.select_choice')()<CR>", "change luasnip choice" }, -- ["<C-u>"] = { "<cmd>lua require('luasnip.extras.select_choice')()<CR>", "change luasnip choice" },
},--}}} },--}}}

@ -98,7 +98,7 @@ g.netrw_winsize = 20 -- width of the window (25%)
opt.signcolumn = "yes" opt.signcolumn = "yes"
opt.signcolumn = "auto:1-3" -- accommodate up to 3 icons -- opt.signcolumn = "auto:1-3" -- accommodate up to 3 icons
opt.splitbelow = true opt.splitbelow = true
opt.splitright = true opt.splitright = true
opt.termguicolors = true opt.termguicolors = true

@ -102,7 +102,12 @@ M.ui = {
}, },
DapBreakpointRejected = { DapBreakpointRejected = {
fg = "purple" fg = "purple"
} },
LuaSnipChoice = {
fg = "#ff4848",
bg = "one_bg3",
},
}, },
-- hl_override = { -- hl_override = {
-- CursorLine = { -- CursorLine = {

@ -0,0 +1,37 @@
local present, luasnip = pcall(require, "luasnip")
if not present then
return
end
local types = require("luasnip.util.types")
local options = {
history = true,
updateevents = "TextChanged,TextChangedI",
ext_opts = {
[types.choiceNode] = {
passive = {
virt_text = { { "", "LuaSnipChoice" } },
}
}
},
}
M.setup = function()
luasnip.config.set_config(options)
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" }
vim.api.nvim_create_autocmd("InsertLeave", {
callback = function()
if require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
and not require("luasnip").session.jump_active
then
require("luasnip").unlink_current()
end
end,
})
end
return M

@ -32,6 +32,7 @@ local config = {
{ key = '<Leader>ct', func = require('navigator.ctags').ctags, desc = 'lsp ctags' }, { key = '<Leader>ct', func = require('navigator.ctags').ctags, desc = 'lsp ctags' },
{ key = 'K', func = vim.lsp.buf.hover, desc = 'lsp hover' }, { key = 'K', func = vim.lsp.buf.hover, desc = 'lsp hover' },
{ key = '<M-a>', mode = 'n', func = require('navigator.codeAction').code_action, desc = 'lsp code_action' }, { key = '<M-a>', mode = 'n', func = require('navigator.codeAction').code_action, desc = 'lsp code_action' },
{ key = '<M-a>', mode = 'i', func = require('navigator.codeAction').code_action, desc = 'lsp code_action' },
{ {
key = '<M-a>', key = '<M-a>',
mode = 'v', mode = 'v',

@ -116,17 +116,18 @@ return {
lock = false, lock = false,
config = function() config = function()
-- load default config first -- load default config first
require("plugins.configs.others").luasnip() require("custom.plugins.configs.luasnip").setup()
vim.g.my_snippets_paths = { "./custom_snippets" } vim.g.my_snippets_paths = { "./custom_snippets" }
require("luasnip").filetype_extend("markdown", { "markdown_zk" }) require("luasnip").filetype_extend("markdown", { "markdown_zk" })
-- load snippets from "honza/vim-snippets" -- load snippets from "honza/vim-snippets"
-- includes ultisnips and snipmate snippets -- includes ultisnips and snipmate snippets
require("luasnip.loaders.from_snipmate").lazy_load({ override_priority = 800 }) -- default priority for snipmate is 1000
require("luasnip.loaders.from_snipmate").lazy_load({ override_priority = 500 })
require("luasnip.loaders.from_snipmate").lazy_load { require("luasnip.loaders.from_snipmate").lazy_load {
paths = vim.g.my_snippets_paths, paths = vim.g.my_snippets_paths,
override_priority = 800 override_priority = 600
} }
end end
}, -- }}} }, -- }}}

@ -1,7 +1,7 @@
local present, cmp = pcall(require, "cmp") local present, cmp = pcall(require, "cmp")
if not present then if not present then
return return
end end
require("base46").load_highlight "cmp" require("base46").load_highlight "cmp"
@ -9,143 +9,154 @@ require("base46").load_highlight "cmp"
vim.opt.completeopt = "menuone,noselect" vim.opt.completeopt = "menuone,noselect"
local function border(hl_name) local function border(hl_name)
return { return {
{ "", hl_name }, { "", hl_name },
{ "", hl_name }, { "", hl_name },
{ "", hl_name }, { "", hl_name },
{ "", hl_name }, { "", hl_name },
{ "", hl_name }, { "", hl_name },
{ "", hl_name }, { "", hl_name },
{ "", hl_name }, { "", hl_name },
{ "", hl_name }, { "", hl_name },
} }
end end
local cmp_window = require "cmp.utils.window" local cmp_window = require "cmp.utils.window"
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp_window.info_ = cmp_window.info cmp_window.info_ = cmp_window.info
cmp_window.info = function(self) cmp_window.info = function(self)
local info = self:info_() local info = self:info_()
info.scrollable = false info.scrollable = false
return info return info
end end
local options = { local options = {
window = { -- preselect = cmp.PreselectMode.None,
completion = { window = {
border = border "CmpBorder", completion = {
winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", border = border "CmpBorder",
winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
},
documentation = {
border = border "CmpDocBorder",
},
}, },
documentation = { snippet = {
border = border "CmpDocBorder", expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
}, },
}, formatting = {
snippet = { format = function(entry, vim_item)
expand = function(args) local icons = require("nvchad_ui.icons").lspkind
require("luasnip").lsp_expand(args.body) vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
end, -- show source
}, vim_item.menu = ({
formatting = { buffer = ":buf",
format = function(entry, vim_item) nvim_lsp = ":lsp",
local icons = require("nvchad_ui.icons").lspkind luasnip = ":LuaS",
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) nvim_lua = ":lua",
-- show source latex_symbols = ":ltx",
vim_item.menu = ({ })[entry.source.name]
buffer = ":buf", return vim_item
nvim_lsp = ":lsp", end,
luasnip = ":lsnp",
nvim_lua = ":lua",
latex_symbols = ":ltx",
})[entry.source.name]
return vim_item
end,
},
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
-- Try to emulate native neovim C-x completion style behavior
["<C-e><C-e>"] = cmp.mapping.complete(),
["<C-c>"] = cmp.mapping.close(),
["<C-e>"] = cmp.mapping.abort(),
["<C-y>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
}, },
["<CR>"] = cmp.mapping.confirm { mapping = {
behavior = cmp.ConfirmBehavior.Replace, ["<C-p>"] = cmp.mapping.select_prev_item(),
select = false, ["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
-- Try to emulate native neovim C-x completion style behavior
["<C-e><C-e>"] = cmp.mapping.complete(),
["<C-c>"] = cmp.mapping.close(),
["<C-e>"] = cmp.mapping.abort(),
["<C-y>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
-- luasnip forward jump
["<C-k>"] = cmp.mapping(function(fallback)
local luasnip = require("luasnip")
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.confirm()
else
fallback()
end
end, {
"i",
"s",
}),
-- luasnip reverse jump
["<C-j>"] = cmp.mapping(function(fallback)
local luasnip = require("luasnip")
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
["<Tab>"] = cmp.mapping(function(fallback)
local luasnip = require("luasnip")
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.confirm()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
local luasnip = require("luasnip")
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
}, },
-- luasnip forward jump sources = {
["<C-k>"] = cmp.mapping(function(fallback) { name = "luasnip", priority = 1000 },
local luasnip = require("luasnip") { name = "nvim_lsp", priority = 800 },
if luasnip.jumpable(1) then {
luasnip.jump(1) name = "buffer",
elseif luasnip.expandable() then option = {
luasnip.expand_or_jump() get_bufnrs = function()
else local bufs = {}
fallback() for _, win in ipairs(vim.api.nvim_list_wins()) do
end bufs[vim.api.nvim_win_get_buf(win)] = true
end, { end
"i", return vim.tbl_keys(bufs)
"s", end
}), },
-- luasnip reverse jump },
["<C-j>"] = cmp.mapping(function(fallback) { name = "nvim_lua", priority = 900 },
local luasnip = require("luasnip") { name = "path" },
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
else
fallback()
end
end, {
"i",
"s",
}),
},
sources = {
{ name = "luasnip" },
{ name = "nvim_lsp" },
{
name = "buffer",
option = {
get_bufnrs = function()
local bufs = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
bufs[vim.api.nvim_win_get_buf(win)] = true
end
return vim.tbl_keys(bufs)
end
},
}, },
{ name = "nvim_lua" },
{ name = "path" },
},
} }
-- check for any override -- check for any override

@ -106,35 +106,6 @@ M.comment = function()
nvim_comment.setup(options) nvim_comment.setup(options)
end end
M.luasnip = function()
local present, luasnip = pcall(require, "luasnip")
if not present then
return
end
local options = {
history = true,
updateevents = "TextChanged,TextChangedI",
}
options = load_override(options, "L3MON4D3/LuaSnip")
luasnip.config.set_config(options)
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" }
vim.api.nvim_create_autocmd("InsertLeave", {
callback = function()
if
require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
and not require("luasnip").session.jump_active
then
require("luasnip").unlink_current()
end
end,
})
end
M.gitsigns = function() M.gitsigns = function()
local present, gitsigns = pcall(require, "gitsigns") local present, gitsigns = pcall(require, "gitsigns")

@ -33,8 +33,8 @@ local options = {
triggers_blacklist = { triggers_blacklist = {
-- list of mode / prefixes that should never be hooked by WhichKey -- list of mode / prefixes that should never be hooked by WhichKey
i = { "j", "k" }, i = { "j", "k" },
v = { "j", "k" }, v = { "j", "k", "<C-x>" },
-- n = { "\"", "@" }, -- disable registers n = { "\"", "@" }, -- disable registers
}, },
} }

@ -64,7 +64,12 @@ local config = {
end, end,
desc = '[dapui] float watches' desc = '[dapui] float watches'
}, },
B = { P = {
rhs = function()
require('dapui').float_element('scopes')
end,
desc = '[dapui] float scopes'
},B = {
rhs = function() rhs = function()
require('dapui').float_element('breakpoints') require('dapui').float_element('breakpoints')
end, end,

@ -17,7 +17,8 @@ function M.gopls_onattach(client, bufnr)
end end
autocmd({"BufWritePre", "InsertLeave"}, { -- autocmd({"BufWritePre", "InsertLeave"}, {
autocmd({"BufWritePre"}, {
group = augroup(augroupname, {clear = true}), group = augroup(augroupname, {clear = true}),
buffer = bufnr, buffer = bufnr,
callback = function() callback = function()

Loading…
Cancel
Save