fix: namespace all local packages and modules

This commit is contained in:
2025-04-16 23:16:58 +02:00
parent 0c327701a1
commit 16ccb1d107
45 changed files with 43 additions and 32 deletions
-172
View File
@@ -1,172 +0,0 @@
-- https://github.com/hrsh7th/nvim-cmp
local word_pattern = "[%w_.]"
local function has_words_before()
unpack = unpack or table.unpack
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(word_pattern)
~= nil
end
local function has_words_after()
unpack = unpack or table.unpack
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 + 1, col + 1)
:match(word_pattern)
~= nil
end
---@type LazyPluginSpec
return {
"hrsh7th/nvim-cmp",
dependencies = {
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lsp",
{
"L3MON4D3/LuaSnip",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end,
build = (require("utils").os_name ~= "Windows_NT" and "make install_jsregexp" or nil),
version = "2.*",
dependencies = { "rafamadriz/friendly-snippets" },
},
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local utils = require("utils")
local lspkind = utils.try_require("lspkind")
---@type cmp.ConfigSchema
local opts = {
-- enabled = function()
-- return has_words_before()
-- end,
preselect = 'None',
completion = {
autocomplete = { "InsertEnter", "TextChanged" },
keyword_length = 1,
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
formatting = {
format = function(entry, vim_item)
if lspkind then
vim_item = lspkind.cmp_format({
mode = "symbol",
maxwidth = 50,
ellipsis_char = "...",
before = function(_, item)
item.dup = 0 -- remove duplicates, see nvim-cmp #511
return item
end,
})(entry, vim_item)
end
return vim_item
end,
},
mapping = {
["<tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item({
behavior = cmp.SelectBehavior.Select,
})
else
fallback()
end
end),
["<S-tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item({
behavior = cmp.SelectBehavior.Select,
})
else
fallback()
end
end),
["<C-n>"] = cmp.mapping.select_next_item({
behavior = cmp.SelectBehavior.Select,
}),
["<C-p>"] = cmp.mapping.select_prev_item({
behavior = cmp.SelectBehavior.Select,
}),
["<CR>"] = cmp.mapping(function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({
select = false,
behavior = cmp.ConfirmBehavior.Replace,
})
else
fallback()
end
end),
["<C-y>"] = cmp.mapping.confirm({
select = true,
behavior = cmp.ConfirmBehavior.Replace,
}),
["<C-x><C-o>"] = cmp.mapping.complete(),
["<C-l>"] = function(fallback)
if luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end,
["<C-h>"] = function(fallback)
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "orgmode" },
{ name = "path" },
},
}
if utils.has_module("moonfly") then
local winhighlight = {
winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel",
}
opts.window = {
completion = cmp.config.window.bordered(winhighlight),
documentation = cmp.config.window.bordered(winhighlight),
}
end
cmp.setup(opts)
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = { { name = "buffer" } },
})
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ { name = "path" } }, {
{
name = "cmdline",
option = { ignore_cmds = { "Man", "!" } },
},
}),
})
end,
}
-11
View File
@@ -1,11 +0,0 @@
-- https://github.com/numToStr/Comment.nvim
---@type LazyPluginSpec
return {
"numToStr/Comment.nvim",
event = "VeryLazy",
opts = {
--ignore empty lines
ignore = "^$",
},
}
-86
View File
@@ -1,86 +0,0 @@
-- https://github.com/mfussenegger/nvim-dap
---@type LazyPluginSpec
return {
"mfussenegger/nvim-dap",
keys = {
{
"<Leader>db",
function()
require("dap").toggle_breakpoint()
end,
},
{
"<F1>",
function()
require("dap.ui.widgets").hover()
end,
},
{
"<F2>",
function()
require("dap").step_into()
end,
},
{
"<F3>",
function()
require("dap").step_over()
end,
},
{
"<F4>",
function()
require("dap").step_out()
end,
},
{
"<F5>",
function()
require("dap").continue()
end,
},
{
"<F6>",
function()
local widgets = require("dap.ui.widgets")
widgets.centered_float(widgets.scopes)
end,
},
{
"<F9>",
function()
require("dap").terminate()
end,
},
},
config = function()
local dap = require("dap")
-- https://sourceware.org/gdb/current/onlinedocs/gdb#Debugger-Adapter-Protocol
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = {
"--interpreter=dap",
"--eval-command",
"set print pretty on",
"--eval-command",
"set startup-with-shell off",
},
}
dap.configurations.cpp = {
{
name = "Launch",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
}
end,
}
-9
View File
@@ -1,9 +0,0 @@
-- https://github.com/j-hui/fidget.nvim
---@type LazyPluginSpec
return {
"j-hui/fidget.nvim",
tag = "legacy",
event = "LspAttach",
config = true,
}
-10
View File
@@ -1,10 +0,0 @@
-- https://github.com/rbong/vim-flog
---@type LazyPluginSpec
return {
"rbong/vim-flog",
---@type LazyKeysSpec[]
keys = {
{ "<leader>gl", vim.cmd.Flog, mode = "n" },
},
}
-22
View File
@@ -1,22 +0,0 @@
-- https://github.com/tpope/vim-fugitive
local function git_status_tab()
vim.cmd.tabnew()
vim.cmd("leftabove vertical G")
vim.cmd("vertical resize 40")
vim.cmd.set("wfw")
end
---@type LazyPluginSpec
return {
"tpope/vim-fugitive",
event = "VeryLazy",
---@type LazyKeysSpec[]
keys = {
{ "<leader>gd", vim.cmd.Gvdiffsplit, mode = "n" },
{ "<leader>gc", function() vim.cmd.G("commit") end, mode = "n" },
{ "<leader>ga", function() vim.cmd.G("commit --amend") end, mode = "n" },
{ "<leader>gp", function() vim.cmd.G("push") end, mode = "n" },
{ "<leader>gg", git_status_tab, mode = "n" },
},
}
-58
View File
@@ -1,58 +0,0 @@
-- https://github.com/lewis6991/gitsigns.nvim
---@type LazyPluginSpec
return {
"lewis6991/gitsigns.nvim",
event = "VeryLazy",
opts = {
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
vim.keymap.set("n", "<leader>gv", gs.select_hunk, { buffer = bufnr })
vim.keymap.set("n", "<leader>gs", gs.stage_hunk, { buffer = bufnr })
vim.keymap.set(
"x",
"<leader>gs",
function()
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end,
{ buffer = bufnr }
)
vim.keymap.set({ "n", "x" }, "<leader>gu", gs.undo_stage_hunk, { buffer = bufnr })
vim.keymap.set("n", "<leader>gr", gs.reset_hunk, { buffer = bufnr })
vim.keymap.set("x", "<leader>gr", ":Gitsigns reset_hunk<CR>", { buffer = bufnr })
vim.keymap.set("n", "<leader>g?", gs.preview_hunk, { buffer = bufnr })
vim.keymap.set(
"n",
"<leader>gb",
function()
gs.blame_line { full = true, ignore_whitespace = true }
end,
{ buffer = bufnr }
)
vim.keymap.set(
{ "n", "x" },
"]g", function()
gs.next_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end
)
vim.keymap.set(
{ "n", "x" },
"[g", function()
gs.prev_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end
)
end,
attach_to_untracked = true,
sign_priority = 100,
},
}
-12
View File
@@ -1,12 +0,0 @@
-- https://github.com/onsails/lspkind.nvim
---@type LazyPluginSpec
return {
"onsails/lspkind.nvim",
config = function()
local ok, _ = pcall(require, "nvim-cmp")
if not ok then
require("lspkind").init()
end
end,
}
-8
View File
@@ -1,8 +0,0 @@
-- https://github.com/williamboman/mason.nvim
---@type LazyPluginSpec
return {
"williamboman/mason.nvim",
event = "VeryLazy",
config = true,
}
-18
View File
@@ -1,18 +0,0 @@
-- https://github.com/bluz71/vim-moonfly-colors
---@type LazyPluginSpec
return {
"bluz71/vim-moonfly-colors",
priority = 1000,
lazy = false,
name = "moonfly",
init = function()
vim.g.moonflyNormalFloat = true
vim.g.moonflyCursorColor = true
vim.g.moonflyWinSeparator = 2
vim.g.moonflyVirtualTextColor = true
end,
config = function()
vim.cmd.colorscheme("moonfly")
end,
}
-166
View File
@@ -1,166 +0,0 @@
local function toggle_neo_tree()
require("neo-tree.command").execute({
action = "show",
position = "left",
toggle = true,
reveal = true,
})
end
local function focus_neo_tree()
require("neo-tree.command").execute({
action = "focus",
source = "last",
})
end
---@type LazyPluginSpec
return {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
},
lazy = false,
keys = {
{
"<leader>tt",
toggle_neo_tree,
},
{
"<leader>a",
focus_neo_tree,
},
},
---@type neotree.Config?
opts = {
sources = {
"filesystem",
"git_status",
},
close_if_last_window = true,
default_component_configs = {
diagnostics = {
symbols = {
hint = "H",
info = "I",
warn = "W",
error = "E",
},
},
indent = {
with_markers = false,
},
---@diagnostic disable-next-line: missing-fields
icon = {
provider = function(icon, _, _)
icon.text = ""
end,
},
modified = {
symbol = "[+] ",
highlight = "NeoTreeModified",
},
name = {
use_git_status_colors = false,
trailing_slash = true,
},
git_status = {
symbols = {
added = "A",
deleted = "D",
modified = "M",
renamed = "R",
untracked = "?",
ignored = "",
unstaged = "",
staged = "+",
conflict = "!",
},
},
},
window = {
mappings = {
["<Tab>"] = "open",
},
},
filesystem = {
check_gitignore_in_search = false,
filtered_items = {
show_hidden_count = false,
hide_dotfiles = false,
hide_gitignored = false,
hide_by_name = { ".git" },
},
follow_current_file = {
enabled = true,
},
hijack_netrw_behavior = "disabled",
use_libuv_file_watcher = true,
commands = {
-- over write default 'delete' command to 'trash'.
delete = function(state)
local inputs = require("neo-tree.ui.inputs")
local path = state.tree:get_node().path
local msg = "Send to trash?"
inputs.confirm(msg, function(confirmed)
if not confirmed then
return
end
vim.fn.system({
"gio",
"trash",
vim.fn.fnameescape(path),
})
require("neo-tree.sources.manager").refresh(state.name)
end)
end,
-- over write default 'delete_visual' command to 'trash' x n.
delete_visual = function(state, selected_nodes)
local inputs = require("neo-tree.ui.inputs")
-- get table items count
function GetTableLen(tbl)
local len = 0
for n in pairs(tbl) do
len = len + 1
end
return len
end
local count = GetTableLen(selected_nodes)
local msg = "Send " .. count .. " files to trash?"
inputs.confirm(msg, function(confirmed)
if not confirmed then
return
end
for _, node in ipairs(selected_nodes) do
vim.fn.system({
"gio",
"trash",
vim.fn.fnameescape(node.path),
})
end
require("neo-tree.sources.manager").refresh(state.name)
end)
end,
},
},
event_handlers = {
{
event = "neo_tree_window_after_open",
handler = function(event)
vim.api.nvim_set_option_value(
"signcolumn",
"no",
{ scope = "local", win = event.winid }
)
end,
},
},
},
init = toggle_neo_tree,
}
-17
View File
@@ -1,17 +0,0 @@
-- https://github.com/rcarriga/nvim-notify
---@type LazyPluginSpec
return {
"rcarriga/nvim-notify",
priority = 900,
lazy = false,
opts = {
render = "default",
stages = "static",
},
config = function(_, opts)
---@type notify
vim.notify = require("notify")
vim.notify.setup(opts)
end,
}
-18
View File
@@ -1,18 +0,0 @@
-- https://github.com/NvChad/nvim-colorizer.lua
---@type LazyPluginSpec
return {
"NvChad/nvim-colorizer.lua",
opts = {
user_default_options = {
names = false,
RGB = false,
RRGGBB = true,
RRGGBBAA = true,
AARRGGBB = true,
rgb_fn = true,
hsl_fn = true,
mode = "virtualtext",
},
},
}
-9
View File
@@ -1,9 +0,0 @@
---@type LazyPluginSpec
return {
"nvim-treesitter/nvim-treesitter-context",
opts = {
mode = 'topline',
max_lines = 3,
multiline_threshold = 1,
},
}
-47
View File
@@ -1,47 +0,0 @@
-- https://github.com/NvChad/nvim-colorizer.lua
---@type LazyPluginSpec
return {
"stevearc/oil.nvim",
keys = {
{
"<leader>fe",
function()
vim.cmd.Oil("--float")
end,
mode = "n",
},
},
opts = {
default_file_explorer = true,
columns = {
-- "icon",
"permissions",
"size",
"mtime",
},
constrain_cursor = "name",
delete_to_trash = true,
float = {
max_width = 80,
max_height = 40,
},
skip_confirm_for_simple_edits = true,
watch_for_changes = false,
keymaps = {
["<Esc>"] = "actions.close",
["q"] = "actions.close",
["<C-s>"] = false,
["<C-h>"] = "actions.parent",
["<C-l>"] = "actions.select",
["<C-r>"] = "actions.refresh",
},
view_options = {
show_hidden = true,
natural_order = false,
},
win_options = {
colorcolumn = "",
},
},
}
-36
View File
@@ -1,36 +0,0 @@
-- https://github.com/nvim-orgmode/orgmode
---@type LazyPluginSpec
return {
"nvim-orgmode/orgmode",
dependencies = {
"nvim-treesitter/nvim-treesitter",
},
opts = {
org_agenda_files = { "~/Documents/org/**/*" },
org_default_notes_file = "~/Documents/org/notes.org",
org_todo_keywords = {
"TODO(t)",
"ACTIVE(a)",
"WAITING(w)",
"|",
"DONE(d)",
"DISCARDED(c)",
},
org_todo_keyword_faces = {
ACTIVE = ":foreground dodgerblue :weight bold",
WAITING = ":foreground lightgoldenrod :weight bold",
DISCARDED = ":foreground grey :weight bold",
},
win_split_mode = "float",
win_border = "single",
org_archive_location = "~/Documents/org/archive.org::",
org_log_done = "note",
org_log_into_drawer = "LOGBOOK",
org_highlight_latex_and_related = "entities",
org_agenda_span = "week",
org_agenda_skip_scheduled_if_done = true,
org_agenda_skip_deadline_if_done = true,
},
}
-126
View File
@@ -1,126 +0,0 @@
-- https://github.com/nvim-telescope/telescope.nvim
---@type LazyPluginSpec
return {
"nvim-telescope/telescope.nvim",
event = "VeryLazy",
dependencies = {
"nvim-lua/plenary.nvim",
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
},
},
config = function()
local telescope = require("telescope")
local builtin = require("telescope.builtin")
local actions = require("telescope.actions")
telescope.setup({
defaults = {
mappings = {
n = {
q = actions.close,
["<C-c>"] = actions.close,
["<C-l>"] = actions.select_default,
},
},
},
pickers = {
oldfiles = {
initial_mode = "normal",
},
buffers = {
initial_mode = "normal",
mappings = {
n = {
["<C-d>"] = actions.delete_buffer + actions.move_to_top,
},
i = {
["<C-d>"] = actions.delete_buffer + actions.move_to_top,
},
},
},
diagnostics = {
initial_mode = "normal",
},
lsp_definitions = {
initial_mode = "normal",
},
lsp_type_definitions = {
initial_mode = "normal",
},
lsp_implementations = {
initial_mode = "normal",
},
lsp_references = {
initial_mode = "normal",
},
git_status = {
initial_mode = "normal",
},
},
})
vim.keymap.set(
"n",
"<leader>ff",
function()
builtin.find_files({
hidden = true,
no_ignore = true,
no_ignore_parent = true,
previewer = false,
})
end
)
vim.keymap.set(
"n",
"<leader>fr",
function()
builtin.oldfiles({
only_cwd = true,
hidden = true,
previewer = false,
})
end
)
vim.keymap.set(
"n",
"<leader>fg",
function()
builtin.live_grep({
additional_args = function(_)
return {
"--hidden",
"--iglob=!.venv",
"--iglob=!vendor",
"--iglob=!.git",
}
end,
previewer = true,
})
end
)
vim.keymap.set(
"n",
"<leader>fb",
function()
builtin.buffers({ previewer = false, sort_mru = true })
end
)
vim.keymap.set(
"n",
"<leader>fd",
function()
builtin.diagnostics({
bufnr = 0,
})
end
)
telescope.load_extension("fzf")
telescope.load_extension("notify")
vim.keymap.set("n", "<leader>fn", telescope.extensions.notify.notify)
end,
}
-45
View File
@@ -1,45 +0,0 @@
-- https://github.com/nvim-treesitter/nvim-treesitter
---@type LazyPluginSpec
return {
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
event = "VeryLazy",
opts = {
ensure_installed = {
"c", -- recommended default
"lua", -- recommended default
"vim", -- recommended default
"vimdoc", -- recommended default
"query", -- recommended default
"luadoc",
"phpdoc",
"comment",
},
auto_install = true,
highlight = {
enable = true,
disable = {},
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = { "org", "php", "python" },
},
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
-- Disable LSP semantic highlighting for lua comments because it will
-- otherwise override highlights from `comment`.
vim.api.nvim_set_hl(0, "@lsp.type.comment.lua", {})
-- To set the priority of semantic highlighting lower than treesitter (100),
-- uncomment the line below:
-- vim.hl.priorities.semantic_tokens = 99
end,
}