update config to lazy

- add some new plugins
- remove some old ones
- clean up/update some configs
This commit is contained in:
2025-02-16 01:47:35 -08:00
parent f1d8f5f834
commit 9c083c98a3
87 changed files with 2377 additions and 2242 deletions

View File

@@ -1,7 +1,7 @@
local augroup = vim.api.nvim_create_augroup
local autocmd = vim.api.nvim_create_autocmd
-- Restore cursor position
-- {{{ Restore cursor position
local restore_cursor = augroup("RestoreCursor", { clear = true })
autocmd("BufReadPost", {
group = restore_cursor,
@@ -13,23 +13,27 @@ autocmd("BufReadPost", {
end
end,
})
-- }}}
-- Help and man pages in vertical split
-- {{{ Open help and man in vertical split
local help_config = augroup("HelpConfig", { clear = true })
autocmd("FileType", {
group = help_config,
pattern = { "help", "man" },
command = "wincmd L",
})
-- }}}
-- Terminal settings
-- {{{ set term options
local term_config = augroup("TermConfig", { clear = true })
autocmd("TermOpen", {
group = term_config,
pattern = "*",
command = "setlocal nonumber norelativenumber",
})
-- }}}
-- {{{ Highlight yanked text
local highlight_yank = augroup("HighlightYank", { clear = true })
autocmd("TextYankPost", {
group = highlight_yank,
@@ -38,7 +42,9 @@ autocmd("TextYankPost", {
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 420 })
end,
})
-- }}}
-- {{{ Disable indent-blankline for dashboard
function disable_for_dashboard()
local buftype = vim.api.nvim_buf_get_option(0, "buftype")
local filetype = vim.api.nvim_buf_get_option(0, "filetype")
@@ -52,39 +58,19 @@ vim.cmd([[
autocmd FileType dashboard lua disable_for_dashboard()
augroup END
]])
-- }}}
-- Code actions on cursor hold
-- local code_action = augroup('CodeAction', { clear = true })
-- autocmd({ 'CursorHold', 'CursorHoldI' }, {
-- group = code_action,
-- callback = function()
-- if vim.tbl_isempty(vim.lsp.buf_get_clients()) then
-- require('code_action_utils').code_action_listener()
-- end
-- end
-- })
-- {{{ Code companion hook
local group = vim.api.nvim_create_augroup("CodeCompanionHooks", {})
local function set_timeoutlen_for_insert_mode()
if vim.bo.buftype == "terminal" or vim.bo.filetype == "codecompanion" then
vim.o.timeoutlen = 0
else
vim.o.timeoutlen = 300 -- Default timeoutlen for other buffers
end
end
-- Create an augroup for managing the autocmds
local augroup = vim.api.nvim_create_augroup("InsertModeTimeout", { clear = true })
-- Autocommand to adjust timeoutlen when entering insert mode
vim.api.nvim_create_autocmd("InsertEnter", {
group = augroup,
callback = set_timeoutlen_for_insert_mode,
})
-- Autocommand to reset timeoutlen when leaving insert mode
vim.api.nvim_create_autocmd("InsertLeave", {
group = augroup,
callback = function()
vim.o.timeoutlen = 300
vim.api.nvim_create_autocmd({ "User" }, {
pattern = "CodeCompanionInline*",
group = group,
callback = function(request)
if request.match == "CodeCompanionInlineFinished" then
-- Format the buffer after the inline request has completed
require("conform").format({ bufnr = request.buf })
end
end,
})
-- }}}

59
lua/core/highlights.lua Normal file
View File

@@ -0,0 +1,59 @@
-- gray
vim.api.nvim_set_hl(0, "CmpItemAbbrDeprecated", { bg = "NONE", strikethrough = true, fg = "#808080" })
-- blue
vim.api.nvim_set_hl(0, "CmpItemAbbrMatch", { bg = "NONE", fg = "#569CD6" })
vim.api.nvim_set_hl(0, "CmpItemAbbrMatchFuzzy", { link = "CmpIntemAbbrMatch" })
-- light blue
vim.api.nvim_set_hl(0, "CmpItemKindVariable", { bg = "NONE", fg = "#9CDCFE" })
vim.api.nvim_set_hl(0, "CmpItemKindInterface", { link = "CmpItemKindVariable" })
vim.api.nvim_set_hl(0, "CmpItemKindText", { link = "CmpItemKindVariable" })
-- pink
vim.api.nvim_set_hl(0, "CmpItemKindFunction", { bg = "NONE", fg = "#C586C0" })
vim.api.nvim_set_hl(0, "CmpItemKindMethod", { link = "CmpItemKindFunction" })
-- front
vim.api.nvim_set_hl(0, "CmpItemKindKeyword", { bg = "NONE", fg = "#D4D4D4" })
vim.api.nvim_set_hl(0, "CmpItemKindProperty", { link = "CmpItemKindKeyword" })
vim.api.nvim_set_hl(0, "CmpItemKindUnit", { link = "CmpItemKindKeyword" })
-- Customization for Pmenu
vim.api.nvim_set_hl(0, "PmenuSel", { bg = "#282C34", fg = "NONE" })
vim.api.nvim_set_hl(0, "Pmenu", { fg = "#C5CDD9", bg = "#22252A" })
vim.api.nvim_set_hl(0, "CmpItemAbbrDeprecated", { fg = "#7E8294", bg = "NONE", strikethrough = true })
vim.api.nvim_set_hl(0, "CmpItemAbbrMatch", { fg = "#82AAFF", bg = "NONE", bold = true })
vim.api.nvim_set_hl(0, "CmpItemAbbrMatchFuzzy", { fg = "#82AAFF", bg = "NONE", bold = true })
vim.api.nvim_set_hl(0, "CmpItemMenu", { fg = "#C792EA", bg = "NONE", italic = true })
vim.api.nvim_set_hl(0, "CmpItemKindField", { fg = "#EED8DA", bg = "#B5585F" })
vim.api.nvim_set_hl(0, "CmpItemKindProperty", { fg = "#EED8DA", bg = "#B5585F" })
vim.api.nvim_set_hl(0, "CmpItemKindEvent", { fg = "#EED8DA", bg = "#B5585F" })
vim.api.nvim_set_hl(0, "CmpItemKindText", { fg = "#C3E88D", bg = "#9FBD73" })
vim.api.nvim_set_hl(0, "CmpItemKindEnum", { fg = "#C3E88D", bg = "#9FBD73" })
vim.api.nvim_set_hl(0, "CmpItemKindKeyword", { fg = "#C3E88D", bg = "#9FBD73" })
vim.api.nvim_set_hl(0, "CmpItemKindConstant", { fg = "#FFE082", bg = "#D4BB6C" })
vim.api.nvim_set_hl(0, "CmpItemKindConstructor", { fg = "#FFE082", bg = "#D4BB6C" })
vim.api.nvim_set_hl(0, "CmpItemKindReference", { fg = "#FFE082", bg = "#D4BB6C" })
vim.api.nvim_set_hl(0, "CmpItemKindFunction", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindStruct", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindClass", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindModule", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindOperator", { fg = "#EADFF0", bg = "#A377BF" })
vim.api.nvim_set_hl(0, "CmpItemKindVariable", { fg = "#C5CDD9", bg = "#7E8294" })
vim.api.nvim_set_hl(0, "CmpItemKindFile", { fg = "#C5CDD9", bg = "#7E8294" })
vim.api.nvim_set_hl(0, "CmpItemKindUnit", { fg = "#F5EBD9", bg = "#D4A959" })
vim.api.nvim_set_hl(0, "CmpItemKindSnippet", { fg = "#F5EBD9", bg = "#D4A959" })
vim.api.nvim_set_hl(0, "CmpItemKindFolder", { fg = "#F5EBD9", bg = "#D4A959" })
vim.api.nvim_set_hl(0, "CmpItemKindMethod", { fg = "#DDE5F5", bg = "#6C8ED4" })
vim.api.nvim_set_hl(0, "CmpItemKindValue", { fg = "#DDE5F5", bg = "#6C8ED4" })
vim.api.nvim_set_hl(0, "CmpItemKindEnumMember", { fg = "#DDE5F5", bg = "#6C8ED4" })
vim.api.nvim_set_hl(0, "CmpItemKindInterface", { fg = "#D8EEEB", bg = "#58B5A8" })
vim.api.nvim_set_hl(0, "CmpItemKindColor", { fg = "#D8EEEB", bg = "#58B5A8" })
vim.api.nvim_set_hl(0, "CmpItemKindTypeParameter", { fg = "#D8EEEB", bg = "#58B5A8" })
vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644", bg = "#181926" })

View File

@@ -1,36 +1,35 @@
local map = vim.keymap.set
local Terminal = require("toggleterm.terminal").Terminal
local lazygit = Terminal:new({ cmd = "lazygit", hidden = true })
local ipython = Terminal:new({ cmd = "ipython", hidden = true })
local notify = require("notify")
local function term_factory(cfg)
cfg["on_stderr"] = function(_, job, data, name)
notify(name .. " encountered an error on job: " .. job .. "\nData: " .. data)
end
cfg["on_stdout"] = function(_, job, data, name)
notify(name .. " output for job" .. job .. "\nData: " .. data)
end
return Terminal:new(cfg)
cfg["on_stderr"] = function(_, job, data, name)
notify(name .. " encountered an error on job: " .. job .. "\nData: " .. data)
end
cfg["on_stdout"] = function(_, job, data, name)
notify(name .. " output for job" .. job .. "\nData: " .. data)
end
return Terminal:new(cfg)
end
local function term_toggle(term)
term:toggle()
term:toggle()
end
local opts = { silent = true, noremap = true }
local notsilent = { silent = false, noremap = true }
local function ReloadConfig()
dofile(vim.fn.stdpath("config") .. "/init.lua")
dofile(vim.fn.stdpath("config") .. "/lua/core/keymaps.lua")
dofile(vim.fn.stdpath("config") .. "/lua/core/autocmds.lua")
dofile(vim.fn.stdpath("config") .. "/lua/core/options.lua")
dofile(vim.fn.stdpath("config") .. "/lua/core/plugins.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/ui/init.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/ui/toggleterm.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/ai/init.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/lsp/init.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/colorscheme/init.lua")
dofile(vim.fn.stdpath("config") .. "/init.lua")
dofile(vim.fn.stdpath("config") .. "/lua/core/keymaps.lua")
dofile(vim.fn.stdpath("config") .. "/lua/core/autocmds.lua")
dofile(vim.fn.stdpath("config") .. "/lua/core/options.lua")
dofile(vim.fn.stdpath("config") .. "/lua/core/plugins.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/ui/init.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/ui/toggleterm.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/ai/init.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/lsp/init.lua")
dofile(vim.fn.stdpath("config") .. "/lua/plugins/colorscheme/init.lua")
end
-- Leader key
@@ -48,8 +47,8 @@ vim.api.nvim_create_user_command("Keymaps", "edit ~/.config/nvim/lua/core/keymap
map("n", "<C-u>", "<C-u>zz", opts)
map("n", "n", "nzzzv", opts)
map("n", "N", "Nzzzv", opts)
map("x", "<leader>p", '"_dP', opts) -- paste without yanking
map("v", "<", "<gv", opts) -- reselect after indent
map("x", "<leader>p", '"_dP', opts) -- paste without yanking
map("v", "<", "<gv", opts) -- reselect after indent
map("v", ">", ">gv", opts)
map("v", "J", ":m '>+1<CR>gv=gv", opts) -- move lines
map("v", "K", ":m '<-2<CR>gv=gv", opts)
@@ -67,18 +66,18 @@ map("n", "<leader>bp", ":bprev<CR>", opts)
--{{{ Terminal mappings
local programs_map = {
gg = { cmd = "lazygit", display_name = "lazygit", direction = "tab", hidden = true },
op = { cmd = "ipython", display_name = "ipython", direction = "vertical", hidden = true },
oP = { cmd = "ipython", display_name = "ipython-full", direction = "tab", hidden = true },
on = { cmd = "ncmpcpp", display_name = "ncmpcpp", direction = "tab", hidden = true },
ob = { cmd = "btop", display_name = "btop", direction = "tab", hidden = true },
od = { cmd = "lazydocker", display_name = "lazydocker", direction = "tab", hidden = true },
gg = { cmd = "lazygit", display_name = "lazygit", direction = "tab", hidden = true },
op = { cmd = "ipython", display_name = "ipython", direction = "vertical", hidden = true },
oP = { cmd = "ipython", display_name = "ipython-full", direction = "tab", hidden = true },
on = { cmd = "ncmpcpp", display_name = "ncmpcpp", direction = "tab", hidden = true },
ob = { cmd = "btop", display_name = "btop", direction = "tab", hidden = true },
od = { cmd = "lazydocker", display_name = "lazydocker", direction = "tab", hidden = true },
}
for key, value in pairs(programs_map) do
map("n", "<leader>" .. key, function()
term_toggle(term_factory(value))
end, opts)
map("n", "<leader>" .. key, function()
term_toggle(term_factory(value))
end, opts)
end
map("v", "op", "<C-\\><C-N>:ToggleTerm name=ipython")
@@ -87,27 +86,22 @@ map("v", "oP", "<C-\\><C-N>:ToggleTerm name=ipython-full")
map("n", "<C-T>", ":ToggleTerm name=toggleterm<CR>", opts)
map("n", "<leader>tt", ":ToggleTerm name=toggleterm<CR>", opts)
map("n", "<leader>tT", ":ToggleTerm name=toggleterm-full direction=tab<CR>", opts)
map("n", "<leader>ot", ":ToggleTerm name=toggleterm<CR>", opts)
map("n", "<leader>oT", ":ToggleTerm name=toggleterm-full direction=tab<CR>", opts)
map("n", "<leader>ts", ":TermSelect<CR>", opts)
map("n", "<leader>tv", ":ToggleTerm direction=vertical name=toggleterm-vert<CR>", opts)
map("n", "<leader>th", ":ToggleTerm direction=horizontal name=toggleterm-hori<CR>", opts)
map("n", "<leader>ov", ":ToggleTerm direction=vertical name=toggleterm-vert<CR>", opts)
map("n", "<leader>oh", ":ToggleTerm direction=horizontal name=toggleterm-hori<CR>", opts)
map("n", "<leader>tf", ":ToggleTerm name=toggleterm<CR>", opts)
map("n", "<leader>-", "<C-\\><C-N>:ToggleTerm direction='horizontal'<CR>", opts)
map("n", "<leader>|", "<C-\\><C-N>:ToggleTerm direction='vertical'<CR>", opts)
map("n", "<leader>-", ":ToggleTerm direction='horizontal'<CR>", opts)
map("n", "<leader>|", ":ToggleTerm direction='vertical'<CR>", opts)
-- map("t", "<leader>tt", "<C-\\><C-N>:ToggleTerm<CR>", opts)
-- map("t", "<leader>tf", "<C-\\><C-N>:ToggleTerm<CR>", opts)
-- map("t", "<leader>-", "<C-\\><C-N>:ToggleTerm direction='horizontal'<CR>", opts)
-- map("t", "<leader>|", "<C-\\><C-N>:ToggleTerm direction='vertical'<CR>", opts)
-- map("t", "<leader>tv", "<C-\\><C-N>:ToggleTerm --name=toggleterm-vert<CR>", opts)
-- map("t", "<leader>th", "<C-\\><C-N>:ToggleTerm --name=toggleterm-hori<CR>", opts)
-- map("t", "<C-T>", "<C-\\><C-n>:Toggleterm<CR>", opts)
-- map("t", "<Esc>", "<C-\\><C-n>", opts)
-- map("n", "<space>", "<nop>", opts) -- fix space in terminal
function _G.set_terminal_keymaps()
local opts = { buffer = 0 }
map("t", "<esc>", [[<C-\><C-n>]], opts)
map("t", "<C-w>", [[<C-\><C-n><C-w>]], opts)
-- map("t", "<space>", "<space>", { buffer = 0, silent = true }) -- fix space in terminal
local opts = { buffer = 0 }
map("t", "<esc>", [[<C-\><C-n>]], opts)
map("t", "<C-w>", [[<C-\><C-n><C-w>]], opts)
-- map("t", "<space>", "<space>", { buffer = 0, silent = true }) -- fix space in terminal
end
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
@@ -128,56 +122,68 @@ map("n", "gl", vim.lsp.codelens.run, opts)
map("n", "gr", ":Telescope lsp_references<CR>", opts)
map("n", "gs", vim.lsp.buf.signature_help, opts)
map("n", "K", vim.lsp.buf.hover, opts)
--}}}
--{{{ Code Companion and Copilot
map("n", "<leader>oc", ":CodeCompanionChat<CR>")
map("n", "<leader>cc", ":CodeCompanionChat<CR>", opts)
map("n", "<leader>ct", ":CodeCompanionChat Toggle<CR>", opts)
map("n", "<leader>ci", ":CodeCompanion ", opts)
map("n", "<leader>cp", ":vert Copilot panel<CR>", opts)
map("n", "<leader>Ca", ":CodeCompanionActions<CR>", opts)
map("v", "<leader>Cc", ":CodeCompanionChat Add<CR>", opts)
map("v", "<leader>Ce", ":CodeCompanion /explain<CR>", opts)
map("v", "<leader>Cf", ":CodeCompanion /fix<CR>", opts)
map("v", "<leader>Cl", ":CodeCompanion /lsp<CR>", opts)
map("v", "<leader>CT", ":CodeCompanion /tests<CR>", opts)
--}}}
--{{{ Diagnostics
-- nnoremap <leader>cd :Telescope diagnostics<CR>
-- nnoremap <leader>cDn :lua vim.diagnostic.goto_next()<CR>
-- nnoremap <leader>cDp :lua vim.diagnostic.goto_prev()<CR>
-- nnoremap <leader>cl :lua vim.diagnostic.setloclist()<CR>
map("n", "<leader>cd", ":Telescope lsp_definitions<CR>")
map("n", "<leader>ca", vim.lsp.buf.code_action)
map("n", "<leader>cci", ":Telescope lsp_incoming_calls<CR>")
map("n", "<leader>cco", ":Telescope lsp_outgoing_calls<CR>")
map("n", "<leader>ch", ":lua vim.lsp.buf.signature_help()<CR>")
map("n", "<leader>ci", ":Telescope lsp_implementations<CR>")
map("n", "<leader>cr", ":Telescope lsp_references<CR>")
map("n", "<leader>cR", ":lua vim.lsp.buf.rename()<CR>")
map("n", "<leader>cs", ":Telescope lsp_document_symbols<CR>")
map("n", "<leader>ct", ":Telescope lsp_type_definitions<CR>")
map("n", "<leader>cw", ":Telescope lsp_dynamic_workspace_symbols<CR>")
map("n", "<leader>cd", ":Telescope diagnostics<CR>")
map("n", "<leader>cDs", ":Telescope diagnostics<CR>")
map("n", "<leader>cDn", ":lua vim.diagnostic.goto_next()<CR>")
map("n", "<leader>cDp", ":lua vim.diagnostic.goto_prev()<CR<CR>")
map("n", "<leader>cl", ":lua vim.diagnostic.setloclist()<CR>")
--}}}
--{{{ Code Companion and Copilot
map("n", "<leader>cp", ":vert Copilot panel<CR>", opts)
map("n", "<leader>oc", ":CodeCompanionChat Toggle<CR>")
map("n", "<leader>Cc", ":CodeCompanionChat Toggle<CR>", opts)
map("n", "<leader>Ci", ":CodeCompanion ", opts)
map("n", "<leader>CT", ":CodeCompanionChat Toggle<CR>", opts)
map("n", "<leader>Ca", ":CodeCompanionActions<CR>", opts)
map("v", "<leader>Cc", ":CodeCompanionChat Add<CR>", opts)
map("v", "<leader>Ci", ":CodeCompanion /buffer ", notsilent)
map("v", "<leader>Ce", ":CodeCompanion /explain<CR>", notsilent)
map("v", "<leader>Cf", ":CodeCompanion /fix<CR>", notsilent)
map("v", "<leader>Cl", ":CodeCompanion /lsp<CR>", notsilent)
map("v", "<leader>Ct", ":CodeCompanion /tests<CR>", notsilent)
--}}}
--{{{ Telescope mappings
-- {{{ Telescope Finders
map("n", "//", ":Telescope current_buffer_fuzzy_find<CR>", opts)
map("n", "??", ":Telescope lsp_document_symbols<CR>", opts)
map(
"n",
"<leader>fc",
':Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical<CR>',
opts
"n",
"<leader>fc",
':Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical<CR>',
opts
)
-- map('n', '<leader>ob', ':Telescope file_browser<CR>')
map("n", "<leader>ff", ":Telescope find_files<CR>", opts)
map("n", "<leader>sf", ":Telescope find_files<CR>", opts)
map(
"n",
"<leader>ff",
":Telescope find_files find_command=rg,--ignore,--follow,--hidden,--files prompt_prefix=🔍<CR>",
opts
)
map("n", "<leader>fg", ":Telescope live_grep<CR>", opts)
map(
"n",
"<leader>fG",
':Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical<CR>',
opts
"n",
"<leader>fG",
':Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical<CR>',
opts
)
map("n", "<leader>fb", ":Telescope file_browser<CR>", opts)
map("n", "<leader>fr", ":Telescope oldfiles<CR>", opts)
-- }}}
--{{{ Telescope Helper
--{{{ Telescope Help
map("n", "<leader>hc", ":Telescope commands<CR>")
map("n", "<leader>hv", ":Telescope vim_options<CR>")
map("n", "<leader>hk", ":Telescope keymaps<CR>")
@@ -186,13 +192,26 @@ map("n", "<leader>hm", ":Telescope man_pages<CR>")
--}}}
--{{{ Telescope Search
map("n", "<leader>sf", ":Telescope find_files<CR>")
map(
"n",
"<leader>sf",
":Telescope find_files find_command=rg,--ignore,--follow,--hidden,--files prompt_prefix=🔍<CR>",
opts
)
map("n", "<leader>sF", ":Telescope fidget<CR>")
map("n", "<leader>sg", ":Telescope live_grep<CR>")
map("n", "<leader>sh", ":Telescope command_history<CR>")
map("n", "<leader>sm", ":Telescope man_pages<CR>")
map("n", "<leader>s/", ":Telescope search_history<CR>")
--}}}
--{{{ Git mappings
map("n", "<leader>gc", ":Telescope git_commits<CR>", opts)
map("n", "<leader>gf", ":Telescope git_files<CR>", opts)
--}}}
map("n", "Q", ":Telescope cmdline<CR>", opts)
map("n", "<leader><leader>", ":Telescope cmdline<CR>", opts)
--}}}
--{{{ File explorer and tools
@@ -200,11 +219,6 @@ map("n", "<leader>n", ":NvimTreeToggle<CR>", opts)
map("n", "<leader>D", ":Dotenv .env<CR>", opts)
--}}}
--{{{ Git mappings
map("n", "<leader>gc", ":Telescope git_commits<CR>", opts)
map("n", "<leader>gf", ":Telescope git_files<CR>", opts)
--}}}
--{{{ Misc utilities
map("n", "<leader>x", "<cmd>!chmod +x %<CR>", opts)
map("n", "<leader>y", '"+', opts)
@@ -222,21 +236,6 @@ map("n", "gpi", ':lua require("goto-preview").goto_preview_implementation()<CR>'
map("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts)
map("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts)
map("n", "<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
--}}}
--{{{ LSP
map("n", "<leader>ld", ":Telescope lsp_definitions<CR>")
map("n", "<leader>lD", ":Telescope diagnostic<CR>")
map("n", "<leader>la", vim.lsp.buf.code_action)
map("n", "<leader>lci", ":Telescope lsp_incoming_calls<CR>")
map("n", "<leader>lco", ":Telescope lsp_outgoing_calls<CR>")
map("n", "<leader>lh", ":lua vim.lsp.buf.signature_help()<CR>")
map("n", "<leader>li", ":Telescope lsp_implementations<CR>")
map("n", "<leader>lr", ":Telescope lsp_references<CR>")
map("n", "<leader>lR", ":lua vim.lsp.buf.rename()<CR>")
map("n", "<leader>ls", ":Telescope lsp_document_symbols<CR>")
map("n", "<leader>lt", ":Telescope lsp_type_definitions<CR>")
map("n", "<leader>lw", ":Telescope lsp_dynamic_workspace_symbols<CR>")
--}}}

37
lua/core/lazy.lua Normal file
View File

@@ -0,0 +1,37 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("core.options")
require("core.autocmds")
require("core.highlights")
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
vim.cmd("colorscheme catppuccin")
require("core.keymaps")
require("core.lsp-notifications")

View File

@@ -0,0 +1,98 @@
-- Utility functions shared between progress reports for LSP and DAP
vim.notify = require("notify")
local client_notifs = {}
local function get_notif_data(client_id, token)
if not client_notifs[client_id] then
client_notifs[client_id] = {}
end
if not client_notifs[client_id][token] then
client_notifs[client_id][token] = {}
end
return client_notifs[client_id][token]
end
local spinner_frames = { "", "", "", "", "", "", "", "" }
local function update_spinner(client_id, token)
local notif_data = get_notif_data(client_id, token)
if notif_data.spinner then
local new_spinner = (notif_data.spinner + 1) % #spinner_frames
notif_data.spinner = new_spinner
notif_data.notification = vim.notify("", nil, {
hide_from_history = true,
icon = spinner_frames[new_spinner],
replace = notif_data.notification,
})
vim.defer_fn(function()
update_spinner(client_id, token)
end, 100)
end
end
local function format_title(title, client_name)
return client_name .. (#title > 0 and ": " .. title or "")
end
local function format_message(message, percentage)
return (percentage and percentage .. "%\t" or "") .. (message or "")
end
-- LSP integration
-- Make sure to also have the snippet with the common helper functions in your config!
vim.lsp.handlers["$/progress"] = function(_, result, ctx)
local client_id = ctx.client_id
local val = result.value
if not val.kind then
return
end
local notif_data = get_notif_data(client_id, result.token)
if val.kind == "begin" then
local message = format_message(val.message, val.percentage)
notif_data.notification = vim.notify(message, "info", {
title = format_title(val.title, vim.lsp.get_client_by_id(client_id).name),
icon = spinner_frames[1],
timeout = false,
hide_from_history = false,
})
notif_data.spinner = 1
update_spinner(client_id, result.token)
elseif val.kind == "report" and notif_data then
notif_data.notification = vim.notify(format_message(val.message, val.percentage), "info", {
replace = notif_data.notification,
hide_from_history = false,
})
elseif val.kind == "end" and notif_data then
notif_data.notification = vim.notify(val.message and format_message(val.message) or "Complete", "info", {
icon = "",
replace = notif_data.notification,
timeout = 3000,
})
notif_data.spinner = nil
end
end
-- table from lsp severity to vim severity.
local severity = {
"error",
"warn",
"info",
"info", -- map both hint and info to info?
}
vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id)
vim.notify(method.message, severity[params.type])
end

View File

@@ -4,19 +4,18 @@ local A = vim.api
local l = vim.lsp
g.mapleader = " "
g.maplocalleader = ','
g.fzf_command =
'fzf --height 90% --width=85% --layout=reverse --preview "bat --color=always {}"'
g.maplocalleader = ","
g.fzf_command = 'fzf --height 90% --width=85% --layout=reverse --preview "bat --color=always {}"'
o.completeopt = "menu,menuone,noselect"
o.showmode = false
o.termguicolors = true
o.background = 'dark'
o.mouse = 'a'
o.syntax = 'on'
o.background = "dark"
o.mouse = "a"
o.syntax = "on"
o.laststatus = 3
o.number = true
o.relativenumber = true
o.colorcolumn = '80'
o.colorcolumn = "80"
o.textwidth = 80
o.shiftwidth = 4
o.expandtab = true
@@ -31,33 +30,49 @@ o.splitright = true
o.cursorline = true
o.scrolloff = 8
o.sidescrolloff = 8
o.wildmenu = true
o.wildignore =
'.git,.hg,.svn,CVS,.DS_Store,.idea,.vscode,.vscode-test,node_modules'
o.wildmenu = false --cmp
o.wildmode = "" --cmp
o.wildoptions = ""
o.wildignore = ".git,.hg,.svn,CVS,.DS_Store,.idea,.vscode,.vscode-test,node_modules"
o.showmatch = true
o.list = true
o.listchars = 'tab:»·,trail:·,nbsp:·,extends:>,precedes:<'
o.encoding = 'utf-8'
o.guifont = 'JetBrainsMono Nerd Font 14'
o.listchars = "tab:»·,trail:·,nbsp:·,extends:>,precedes:<"
o.encoding = "utf-8"
o.guifont = "JetBrainsMono Nerd Font 14"
o.expandtab = true
o.hidden = true
o.cmdheight = 1
o.updatetime = 300
o.timeoutlen = 500
o.pumwidth = 35
o.foldmethod = 'marker'
-- g.colorscheme = 'catppuccin-macchiato'
o.foldmethod = "marker"
g.db_ui_use_nerd_fonts = 1
vim.cmd("colorscheme catppuccin-macchiato")
-- vim.cmd.colorscheme = 'catppuccin-macchiato'
vim.cmd.colorscheme = "catppuccin"
local border = {
{ "", "FloatBorder" }, { "", "FloatBorder" }, { "", "FloatBorder" },
{ "", "FloatBorder" }, { "", "FloatBorder" }, { "", "FloatBorder" },
{ "", "FloatBorder" }, { "", "FloatBorder" }
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
}
l.handlers["textDocument/signatureHelp"] =
vim.lsp.with(vim.lsp.handlers.signature_help, { border = border })
l.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover,
{ border = border })
l.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border })
l.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
-- lsp status
-- table from lsp severity to vim severity.
local severity = {
"error",
"warn",
"info",
"info", -- map both hint and info to info?
}
vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id)
vim.notify(method.message, severity[params.type])
end

View File

@@ -1,354 +0,0 @@
local lsp_dev = {}
vim.cmd([[packadd packer.nvim]])
require("packer").startup(function(use)
use("wbthomason/packer.nvim")
use("nvim-lua/plenary.nvim")
use({
"nvim-treesitter/nvim-treesitter",
run = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
})
use({ "nvim-treesitter/nvim-treesitter-context" })
use({
"kndndrj/nvim-dbee",
requires = {
"MunifTanjim/nui.nvim",
},
run = function()
-- Install tries to automatically detect the install method.
-- if it fails, try calling it with one of these parameters:
-- "curl", "wget", "bitsadmin", "go"
require("dbee").install()
end,
config = function()
require("dbee").setup( --[[optional config]])
end,
})
-- TELESCOPE {{{
use({ "nvim-telescope/telescope.nvim" })
use({ "nvim-telescope/telescope-file-browser.nvim" })
use("nvim-telescope/telescope-dap.nvim")
use({ "ghassan0/telescope-glyph.nvim" })
use({ "nat-418/telescope-color-names.nvim" })
use({
"nvim-telescope/telescope-fzf-native.nvim",
run = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build",
})
-- }}}
-- LSP/DEV {{{
use({
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup({
panel = {
enabled = true,
auto_refresh = false,
keymap = {
jump_prev = "[[",
jump_next = "]]",
accept = "<CR>",
refresh = "gr",
open = "<M-CR>",
},
layout = {
position = "bottom", -- | top | left | right | horizontal | vertical
ratio = 0.4,
},
},
suggestion = {
enabled = false,
auto_trigger = false,
hide_during_completion = true,
debounce = 75,
keymap = {
accept = "<M-l>",
accept_word = false,
accept_line = false,
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
},
-- filetypes = {
-- yaml = false,
-- markdown = false,
-- help = false,
-- gitcommit = false,
-- gitrebase = false,
-- hgcommit = false,
-- svn = false,
-- cvs = false,
-- ["."] = false,
-- },
copilot_node_command = "node", -- Node.js version must be > 18.x
server_opts_overrides = {
trace = "verbose",
settings = {
advanced = {
listCount = 10, -- #completions for panel
inlineSuggestCount = 3, -- #completions for getCompletions
},
},
},
})
end,
})
use({ "zbirenbaum/copilot-cmp" })
use({
"olimorris/codecompanion.nvim",
requires = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"j-hui/fidget.nvim",
},
init = function()
require("plugins.codecompanion.fidget-spinner"):init()
end,
})
use({
"iamcco/markdown-preview.nvim",
run = function()
vim.fn["mkdp#util#install"]()
end,
})
use({
"L3MON4D3/LuaSnip",
-- tag = "v2.*",
run = "make install_jsregexp",
dependencies = { "rafamadriz/friendly-snippets" },
})
use({ "folke/neodev.nvim" })
use({ "saadparwaiz1/cmp_luasnip" })
use({ "hrsh7th/cmp-buffer" })
use({ "hrsh7th/cmp-cmdline" })
use({ "hrsh7th/cmp-nvim-lsp" })
use({ "hrsh7th/cmp-nvim-lsp-document-symbol" })
use({ "hrsh7th/cmp-nvim-lsp-signature-help" })
use({ "hrsh7th/cmp-nvim-lua" })
use({ "hrsh7th/cmp-path" })
use({ "hrsh7th/nvim-cmp" })
use({ "https://git.sr.ht/~whynothugo/lsp_lines.nvim" })
-- use { 'jose-elias-alvarez/null-ls.nvim' }
use({ "nvimtools/none-ls.nvim" })
use({ "neovim/nvim-lspconfig" })
use({ "onsails/lspkind-nvim" })
use({
"https://git.sr.ht/~nedia/auto-format.nvim",
config = function()
require("auto-format").setup()
end,
})
use("mfussenegger/nvim-lint")
use("nvim-neotest/nvim-nio")
-- }}}
-- DADBOD {{{
-- use { 'tpope/vim-dadbod' }
-- use { 'kristijanhusak/vim-dadbod-ui' }
-- use { 'kristijanhusak/vim-dadbod-completion' }
-- }}}
-- UI {{{
use({ "akinsho/toggleterm.nvim", tag = "*" })
use({ "HiPhish/rainbow-delimiters.nvim" })
use({
"lukas-reineke/indent-blankline.nvim",
})
--{{{ DASHBOARD
use({
"nvimdev/dashboard-nvim",
event = "VimEnter",
config = function()
require("dashboard").setup({
theme = "hyper",
config = {
week_header = {
enable = true,
},
shortcut = {
{ desc = "󰊳 Update", group = "@property", action = "Lazy update", key = "u" },
{
icon = "",
icon_hl = "@variable",
desc = "Files",
group = "Label",
action = "Telescope find_files",
key = "f",
},
{
desc = " Apps",
group = "DiagnosticHint",
action = "Telescope app",
key = "a",
},
{
desc = " dotfiles",
group = "Number",
action = "Telescope ~/.config",
key = "d",
},
},
},
})
end,
requires = { "nvim-tree/nvim-web-devicons" },
})
--}}}
use({
"j-hui/fidget.nvim",
tag = "legacy",
config = function()
require("fidget").setup({
-- options
})
end,
})
use({
"nvim-lualine/lualine.nvim",
requires = { "kyazdani42/nvim-web-devicons", opt = true },
})
use({ "AndreM222/copilot-lualine" })
use({ "kyazdani42/nvim-web-devicons" })
use({ "norcalli/nvim-colorizer.lua" })
use({ "akinsho/nvim-bufferline.lua" })
use({ "andweeb/presence.nvim" })
use({ "folke/which-key.nvim" })
use({ "kyazdani42/nvim-tree.lua" })
use({ "lewis6991/gitsigns.nvim" })
use({ "rcarriga/nvim-notify" })
use({ "stevearc/dressing.nvim" })
use({ "echasnovski/mini.nvim" })
use({
"windwp/nvim-autopairs",
event = "InsertEnter",
config = function()
local npairs = require("nvim-autopairs")
local Rule = require("nvim-autopairs.rule")
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
npairs.setup({
disable_filetype = { "TelescopePrompt", "spectre_panel", "Terminal", "terminal" },
check_ts = true,
ts_config = {
lua = { "string" }, -- it will not add a pair on that treesitter node
javascript = { "template_string" },
java = false, -- don't check treesitter on java
},
})
local ts_conds = require("nvim-autopairs.ts-conds")
-- press % => %% only while inside a comment or string
npairs.add_rules({
Rule("%", "%", "lua"):with_pair(ts_conds.is_ts_node({ "string", "comment" })),
Rule("$", "$", "lua"):with_pair(ts_conds.is_not_ts_node({ "function" })),
})
end,
})
-- }}}
-- EXTRAS {{{
use({
"nvim-neorg/neorg",
-- tag = "*",
ft = "norg",
after = "nvim-treesitter", -- You may want to specify Telescope here as well
config = function()
require("neorg").setup({
load = {
["core.defaults"] = {}, -- Loads default behaviour
["core.concealer"] = {}, -- Adds pretty icons to your documents
["core.completion"] = { config = { engine = "nvim-cmp" } }, -- Adds completion
["core.dirman"] = { -- Manages Neorg workspaces
config = { workspaces = { notes = "~/notes" } },
},
},
})
end,
})
use("pechorin/any-jump.vim")
use("tpope/vim-commentary")
use("tpope/vim-dotenv")
use("tpope/vim-surround")
-- use 'voldikss/vim-floaterm'
use("wakatime/vim-wakatime")
use("rmagatti/goto-preview")
-- }}}
-- COLORSCHEMES {{{
use({ "Mofiqul/dracula.nvim" })
-- use({
-- 'NTBBloodbath/doom-one.nvim',
-- setup = function()
-- -- Add color to cursor
-- vim.g.doom_one_cursor_coloring = false
-- -- Set :terminal colors
-- vim.g.doom_one_terminal_colors = true
-- -- Enable italic comments
-- vim.g.doom_one_italic_comments = false
-- -- Enable TS support
-- vim.g.doom_one_enable_treesitter = true
-- -- Color whole diagnostic text or only underline
-- vim.g.doom_one_diagnostics_text_color = false
-- -- Enable transparent background
-- vim.g.doom_one_transparent_background = false
-- -- Pumblend transparency
-- vim.g.doom_one_pumblend_enable = false
-- vim.g.doom_one_pumblend_transparency = 20
-- -- Plugins integration
-- vim.g.doom_one_plugin_neorg = true
-- vim.g.doom_one_plugin_barbar = false
-- vim.g.doom_one_plugin_telescope = true
-- vim.g.doom_one_plugin_neogit = true
-- vim.g.doom_one_plugin_nvim_tree = true
-- vim.g.doom_one_plugin_dashboard = true
-- vim.g.doom_one_plugin_startify = true
-- vim.g.doom_one_plugin_whichkey = true
-- vim.g.doom_one_plugin_indent_blankline = true
-- vim.g.doom_one_plugin_vim_illuminate = false
-- vim.g.doom_one_plugin_lspsaga = false
-- end
-- config = function()
-- vim.cmd("colorscheme doom-one")
-- vim.cmd(
-- "highlight Pmenu ctermfg=white ctermbg=black gui=NONE guifg=white guibg=#282C34")
-- vim.cmd("highlight PmenuSel guifg=purple guibg=red")
-- end
-- })
use({ "olimorris/onedarkpro.nvim" })
use({
"catppuccin/nvim",
as = "catppuccin",
config = function()
vim.cmd("colorscheme catppuccin-macchiato")
end,
})
-- }}}
end)