neovim refactor

This commit is contained in:
Dmitri 2025-09-20 12:15:39 +02:00
parent 77fc1c35c7
commit 28598c5e1d
Signed by: kanopo
GPG Key ID: 759ADD40E3132AC7
29 changed files with 605 additions and 720 deletions

View File

@ -19,3 +19,5 @@
required = true required = true
[init] [init]
defaultBranch = main defaultBranch = main
[url "https://x-access-token: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@github.com/"]
insteadOf = https://github.com/

4
.zshrc
View File

@ -54,3 +54,7 @@ source ~/.cargo/env
export GOROOT="$HOME/.local/bin/go" export GOROOT="$HOME/.local/bin/go"
export GOPATH="$HOME/.go" export GOPATH="$HOME/.go"
export PATH="$GOROOT/bin:$GOPATH/bin:$PATH" export PATH="$GOROOT/bin:$GOPATH/bin:$PATH"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

View File

@ -1,3 +1,17 @@
-- vim.cmd.colorscheme("gruvbox")
-- vim.lsp.enable('lua_ls')
--
-- require("mason").setup()
-- require("mason-lspconfig").setup {
-- ensure_installed = { "lua_ls" }
-- }
-- local ls = require("luasnip")
-- ls.setup({
-- enable_autosnippets = true
-- })
require("kanopo.options") require("kanopo.options")
require("kanopo.lazy")
require("kanopo.autocmds") require("kanopo.autocmds")
require("kanopo.plugins")

View File

@ -1,21 +1,14 @@
-- autoformat on save file vim.api.nvim_create_autocmd('LspAttach', {
vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup('my.lsp', {}),
callback = function(args) callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id) local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
if not client then return end if client:supports_method('textDocument/completion') then
-- Optional: trigger autocompletion on EVERY keypress. May be slow!
if client.supports_method("textDocument/formatting") then local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end
vim.api.nvim_create_autocmd("BufWritePre", { client.server_capabilities.completionProvider.triggerCharacters = chars
buffer = args.buf, vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
callback = function()
vim.lsp.buf.format({
bufnr = args.buf,
id = client.id
})
end
})
end
end end
end,
}) })
-- Highlight yanked text -- Highlight yanked text
@ -28,7 +21,6 @@ vim.api.nvim_create_autocmd("TextYankPost", {
pattern = "*", pattern = "*",
}) })
-- Go to last cursor position when opening a file -- Go to last cursor position when opening a file
vim.api.nvim_create_autocmd("BufReadPost", { vim.api.nvim_create_autocmd("BufReadPost", {
callback = function() callback = function()

View File

@ -1,18 +0,0 @@
-- 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("lazy").setup("kanopo.plugins")

View File

@ -1,47 +1,122 @@
-- options.lua --
vim.opt.cmdheight = 0 -- vim.o.relativenumber = true
-- vim.o.wrap = false
-- Leader key for all the keymaps -- vim.o.tabstop = 4
-- vim.o.swapfile = false
-- vim.g.mapleader = " "
-- vim.g.maplocalleader = " "
-- vim.g.have_nerd_font = true
-- vim.o.termguicolors = true
-- vim.o.cursorline = true
-- vim.o.clipboard = "unnamedplus"
-- vim.o.signcolumn = "yes"
-- vim.o.colorcolumn = "100"
-- vim.o.winborder = "rounded"
-- vim.o.completeopt = "menu,menuone,noinsert,noselect"
--
-- vim.o.shortmess = vim.o.shortmess .. "c" -- reduce “match 1 of 5” messages
-- vim.opt.ignorecase = true
-- vim.opt.smartcase = true
-- vim.opt.wrap = true
-- vim.opt.breakindent = true
-- vim.opt.expandtab = true
-- vim.opt.tabstop = 2
-- vim.opt.softtabstop = 2
-- vim.opt.shiftwidth = 2
-- vim.opt.splitright = true
-- vim.opt.splitbelow = true
-- vim.opt.undofile = true
-- Leader keys (set early)
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
-------------------------------------------------------------------------------- -- UI and appearance
-- -- GENERAL EDITOR BEHAVIOR vim.o.termguicolors = true -- 24-bit colors in TUI
-------------------------------------------------------------------------------- vim.o.cursorline = true -- highlight current line
vim.opt.clipboard = "unnamedplus" -- Use system clipboard vim.o.number = true -- absolute line numbers
vim.opt.writebackup = false -- Disable backup files vim.o.relativenumber = true -- relative line numbers
vim.opt.undofile = true -- Enable persistent undo vim.o.signcolumn = "yes" -- always show signcolumn
vim.opt.wrap = false -- Do not wrap lines vim.o.colorcolumn = "100" -- visual column guide
vim.opt.conceallevel = 2 -- Hide markdown syntax, etc. vim.o.winborder = "rounded" -- default floating window border
vim.opt.signcolumn = "yes" -- Always show the sign column to avoid resizing vim.o.cmdheight = 0 -- minimal command-line height (NVIM 0.10+)
vim.opt.timeoutlen = 300 -- Time to wait for a mapped sequence to complete vim.o.conceallevel = 2 -- conceal in Markdown/jsonc when appropriate
vim.opt.updatetime = 250 -- Faster completion and CursorHold updates vim.o.foldlevel = 0 -- start with folds closed (Treesitter can open)
vim.o.winborder = "rounded"
-- Disable unused built-in providers for faster startup -- Splits
vim.o.splitright = true -- open vertical splits to the right
vim.o.splitbelow = true -- open horizontal splits below
-- Editing behavior
vim.o.wrap = false -- do not wrap lines by default
vim.o.breakindent = true -- keep indentation on wrapped lines (if wrap is enabled later)
vim.o.clipboard = "unnamedplus" -- use system clipboard
vim.o.swapfile = false -- no swapfiles
vim.o.undofile = true -- persistent undo
vim.o.writebackup = false -- do not keep backup around
-- Tabs and indentation (2-space default; override per-filetype with autocmds)
vim.o.expandtab = true
vim.o.tabstop = 2
vim.o.softtabstop = 2
vim.o.shiftwidth = 2
-- Search
vim.o.ignorecase = true -- case-insensitive
vim.o.smartcase = true -- unless uppercase is used
-- Completion UX (good defaults for omni and popup behavior)
vim.o.completeopt = "menu,menuone,noinsert,noselect"
vim.o.shortmess = (vim.o.shortmess or "") .. "c" -- reduce completion messages
-- Performance and input timing
vim.o.timeoutlen = 300 -- mapped sequence timeout
vim.o.updatetime = 250 -- faster CursorHold/diagnostic updates
vim.o.scrolloff = 10 -- context lines around cursor
-- Fonts/icons (used by statuslines/UIs)
vim.g.have_nerd_font = true
-- Providers (disable unused for faster startup)
vim.g.loaded_perl_provider = 0 vim.g.loaded_perl_provider = 0
vim.g.loaded_ruby_provider = 0 vim.g.loaded_ruby_provider = 0
vim.g.loaded_netrw = 0 -- Disable netrw, as you likely use a plugin like nvim-tree -- If you don't use Python providers via :CheckHealth, consider disabling too:
-- vim.g.loaded_python_provider = 0
-- vim.g.loaded_python3_provider = 0
-------------------------------------------------------------------------------- -- Netrw (disable if using an explorer plugin like oil.nvim; enable if you rely on netrw)
-- -- UI AND APPEARANCE vim.g.loaded_netrw = 0
-------------------------------------------------------------------------------- vim.g.loaded_netrwPlugin = 0
vim.opt.number = true -- Show line numbers -- If you need netrw again, set both back to nil or 0 and restart:
vim.opt.relativenumber = true -- Show relative line numbers -- vim.g.loaded_netrw = nil; vim.g.loaded_netrwPlugin = nil
vim.opt.cursorline = true -- Highlight the current line
vim.opt.scrolloff = 10 -- Keep 10 lines of context around the cursor
vim.opt.termguicolors = true -- Enable 24-bit RGB color in the TUI
vim.o.foldlevel = 0 -- Start with all folds closed
-------------------------------------------------------------------------------- -- Filetype-specific indentation overrides (examples)
-- -- SEARCHING local ft_augroup = vim.api.nvim_create_augroup("FileTypeSettings", { clear = true })
--------------------------------------------------------------------------------
vim.opt.ignorecase = true -- Case-insensitive searching
vim.opt.smartcase = true -- ...unless the query contains a capital letter
-------------------------------------------------------------------------------- -- C-like and web files: 2 spaces (adjust as needed)
-- -- SPELL CHECKING (currently disabled) vim.api.nvim_create_autocmd("FileType", {
-------------------------------------------------------------------------------- group = ft_augroup,
pattern = { "c", "cpp", "objc", "objcpp", "javascript", "typescript", "tsx", "jsx" },
callback = function()
vim.bo.tabstop = 2
vim.bo.shiftwidth = 2
vim.bo.expandtab = true
end,
})
-- Example: make files that often use 4 spaces actually use 4
-- Uncomment if you prefer 4 for these stacks
-- vim.api.nvim_create_autocmd("FileType", {
-- group = ft_augroup,
-- pattern = { "python", "go", "rust" },
-- callback = function()
-- vim.bo.tabstop = 4
-- vim.bo.shiftwidth = 4
-- vim.bo.softtabstop = 4
-- vim.bo.expandtab = true
-- end,
-- })
-- Spell checking (optional; example)
-- vim.opt.spell = true -- vim.opt.spell = true
-- vim.opt.spelllang = "en,it" -- vim.opt.spelllang = "en,it"
-- local spell_dir = vim.fn.stdpath("data") .. "/spell" -- local spell_dir = vim.fn.stdpath("data") .. "/spell"
@ -51,54 +126,3 @@ vim.opt.smartcase = true -- ...unless the query contains a capital letter
-- "~/.config/nvim/spell/en.proj.spl", -- "~/.config/nvim/spell/en.proj.spl",
-- "~/.config/nvim/spell/it.proj.spl", -- "~/.config/nvim/spell/it.proj.spl",
-- } -- }
--------------------------------------------------------------------------------
-- -- FILETYPE-SPECIFIC SETTINGS (AUTOCOMMANDS)
--------------------------------------------------------------------------------
-- Create an autocommand group to prevent duplicate autocommands on reload
local ft_augroup = vim.api.nvim_create_augroup("FileTypeSettings", { clear = true })
-- C, C++, etc: 4-space indentation
vim.api.nvim_create_autocmd("FileType", {
group = ft_augroup,
pattern = { "c", "cpp", "objc", "objcpp", "js", "ts", "tsx", "jsx" },
callback = function()
-- Use vim.bo for buffer-local options
vim.bo.tabstop = 2
vim.bo.shiftwidth = 2
vim.bo.expandtab = true -- Use spaces instead of tabs
end,
})
-- -- Web dev, scripting, etc: 2-space indentation
-- vim.api.nvim_create_autocmd("FileType", {
-- group = ft_augroup,
-- pattern = {
-- "lua",
-- "python",
-- "javascript",
-- "typescript",
-- "html",
-- "css",
-- "json",
-- "yaml",
-- "toml",
-- "markdown",
-- },
-- callback = function()
-- vim.bo.tabstop = 2
-- vim.bo.shiftwidth = 2
-- vim.bo.expandtab = true
-- end,
-- })
--
-- -- LaTeX: 2-space indentation (example)
-- vim.api.nvim_create_autocmd("FileType", {
-- group = ft_augroup,
-- pattern = { "tex" },
-- callback = function()
-- vim.bo.tabstop = 2
-- vim.bo.shiftwidth = 2
-- vim.bo.expandtab = true
-- end,
-- })

View File

@ -0,0 +1,17 @@
-- autopairs.lua
vim.pack.add({
{ src = "https://github.com/windwp/nvim-autopairs" },
})
-- Load packs on first InsertEnter and configure
vim.api.nvim_create_autocmd("InsertEnter", {
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
pcall(function()
require("nvim-autopairs").setup({
disable_filetype = { "TelescopePrompt", "vim" },
})
end)
end,
})

View File

@ -1,9 +0,0 @@
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
config = function()
require("nvim-autopairs").setup({
disable_filetype = { "TelescopePrompt", "vim" },
})
end,
}

View File

@ -1,12 +0,0 @@
return {
"nvim-lualine/lualine.nvim",
dependencies = {
"ellisonleao/gruvbox.nvim",
},
config = function()
local theme = require("gruvbox")
require("lualine").setup({
theme = theme,
})
end,
}

View File

@ -1,107 +0,0 @@
return {
"hrsh7th/nvim-cmp",
event = { "InsertEnter" },
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip",
{
"L3MON4D3/LuaSnip",
dependencies = {
"rafamadriz/friendly-snippets",
},
},
"onsails/lspkind-nvim",
"js-everts/cmp-tailwind-colors"
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
require("luasnip/loaders/from_vscode").lazy_load()
local lspkind = require("lspkind")
local check_backspace = function()
local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
end
-- La tua configurazione esistente per la INSERT MODE rimane invariata
cmp.setup({
performance = {
debounce = 10,
throttle = 10,
max_view_entries = 10,
async_budget = 500,
fetching_timeout = 1000,
confirm_resolve_timeout = 2000,
filtering_context_budget = 200,
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-c>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
}),
formatting = {
format = require("cmp-tailwind-colors").format
-- expandable_indicator = true,
-- fields = { "kind", "abbr", "menu" },
-- format = lspkind.cmp_format({
-- mode = "symbol",
-- maxwidth = 50,
-- ellipsis = "...",
-- show_labelDetails = true,
-- }),
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
})
end,
}

View File

@ -1,12 +0,0 @@
return {
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
signs = true,
keywords = {
TODO = { icon = "🤨", color = "info" },
WIP = { icon = "🥵", color = "warning" },
ERR = { icon = "🤬", color = "error" },
},
}
}

View File

@ -1,8 +1,19 @@
return { -- dressing.lua
"stevearc/dressing.nvim", vim.pack.add({
opts = { { src = "https://github.com/stevearc/dressing.nvim" },
inputs = { })
enable = true,
} vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
pcall(function()
require("dressing").setup({
input = {
enabled = true, -- matches your opts.inputs.enable = true
}, },
} -- You can add selector config here if desired
})
end)
end,
})

View File

@ -1,4 +1,14 @@
return { vim.pack.add({
"j-hui/fidget.nvim", { src = "https://github.com/j-hui/fidget.nvim", version = "main" },
opts = {}, })
}
-- Load packs on startup and configure fidget safely
vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
pcall(function()
require("fidget").setup({})
end)
end,
})

View File

@ -1,16 +1,37 @@
return { -- Declare plugins
"NeogitOrg/neogit", vim.pack.add({
dependencies = { { src = "https://github.com/NeogitOrg/neogit" },
"nvim-lua/plenary.nvim", { src = "https://github.com/lewis6991/gitsigns.nvim" },
"sindrets/diffview.nvim", })
"nvim-telescope/telescope.nvim",
}, -- Load packs on startup (guard for nightlies without load)
-- config = function() vim.api.nvim_create_autocmd("VimEnter", {
-- require("neogit").setup() once = true,
-- vim.keymap.set("n", "<leader>gg", "<cmd>Neogit<cr>", { desc = "Neogit" }) callback = function()
-- end, if vim.pack and vim.pack.load then pcall(vim.pack.load) end
opts = true,
keys = { -- Configure gitsigns (safe pcall)
{ "<leader>gg", "<cmd>Neogit<cr>", desc = "Neogit" }, pcall(function()
}, require("gitsigns").setup()
} end)
-- Preload neogit module if available (optional)
pcall(function()
require("neogit")
end)
end,
})
-- Keymap: open Neogit (on-demand load if needed)
vim.keymap.set("n", "<leader>gg", function()
local ok, neogit = pcall(require, "neogit")
if not ok then
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
ok, neogit = pcall(require, "neogit")
end
if ok then
neogit.open({})
else
vim.notify("neogit not available yet", vim.log.levels.WARN)
end
end, { desc = "Open Neogit" })

View File

@ -1,6 +0,0 @@
return {
"lewis6991/gitsigns.nvim",
event = "BufRead",
opts = {},
}

View File

@ -1,14 +0,0 @@
return {
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
},
config = function()
local harpoon = require('harpoon')
harpoon:setup({})
vim.keymap.set("n", "<leader>a", function() harpoon:list():add() end)
vim.keymap.set("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
end
}

View File

@ -0,0 +1,11 @@
-- require("kanopo.plugins.lazydev")
require("kanopo.plugins.oil")
require("kanopo.plugins.theme")
require("kanopo.plugins.treesitter")
require("kanopo.plugins.telescope")
require("kanopo.plugins.lsp")
require("kanopo.plugins.which-key")
require("kanopo.plugins.git")
require("kanopo.plugins.fidget")
require("kanopo.plugins.dressing")
require("kanopo.plugins.auto-pairs")

View File

@ -0,0 +1,10 @@
vim.pack.add({
"https://github.com/folke/lazydev.nvim"
})
require("lazydev").setup({
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
})

View File

@ -1,16 +0,0 @@
return {
"kawre/leetcode.nvim",
build = ":TSUpdate html", -- if you have `nvim-treesitter` installed
dependencies = {
'nvim-telescope/telescope.nvim',
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
},
opts = {
logging = false,
lang = "typescript",
picker = {
provider = "telescope"
}
},
}

View File

@ -1,3 +1,21 @@
vim.pack.add({
{ src = "https://github.com/neovim/nvim-lspconfig" },
{ src = "https://github.com/mason-org/mason.nvim" },
{ src = "https://github.com/mason-org/mason-lspconfig.nvim" },
{ src = "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" }, -- optional for tools later
{ src = "https://github.com/L3MON4D3/LuaSnip" },
{ src = "https://github.com/rafamadriz/friendly-snippets" },
})
-- Load packs early (guard API)
vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
end,
})
-- Servers you want
local lsp_servers = { local lsp_servers = {
"lua_ls", "lua_ls",
"ts_ls", "ts_ls",
@ -12,276 +30,161 @@ local lsp_servers = {
"gopls", "gopls",
} }
-- Optional: tools you might install later (kept, but not used for formatting here)
local tools = { local tools = {
"luacheck", "luacheck",
"latexindent", "latexindent",
"prettierd", "prettierd",
} }
-- DAP adapters that will be auto-installed based on your LSP servers -- Mason + mason-lspconfig
local dap_adapters = { do
} local ok, mason = pcall(require, "mason")
if ok then mason.setup() end
local on_attach = function(_, bufnr) local ok_mlsp, mlsp = pcall(require, "mason-lspconfig")
local map = function(key, func, desc) if ok_mlsp then
vim.keymap.set("n", key, func, { noremap = true, silent = true, desc = desc, buffer = bufnr }) mlsp.setup({
end
local telescope = require("telescope.builtin")
-- LSP mappings
map("<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", "[R]ename Symbol")
map("<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", "[C]ode [A]ction")
map("K", "<cmd>lua vim.lsp.buf.hover()<CR>", "[K] Hover")
map("<leader>d", "<cmd>lua vim.diagnostic.open_float()<CR>", "[E]xplain Diagnostic")
map("gd", telescope.lsp_definitions, "[G]o [D]efinition")
map("gr", telescope.lsp_references, "[G]o [R]eferences")
map("gI", telescope.lsp_implementations, "[G]o [I]mplementations")
end
-- Auto-detect project type and setup DAP configurations
local function setup_dap_configs()
local dap = require("dap")
-- Project detection patterns
local project_patterns = {
typescript = { "package.json", "tsconfig.json", "*.ts", "*.tsx" },
javascript = { "package.json", "*.js", "*.jsx" },
rust = { "Cargo.toml", "*.rs" },
cpp = { "CMakeLists.txt", "Makefile", "*.cpp", "*.c", "*.h" },
c = { "Makefile", "*.c", "*.h" },
}
local detected_languages = {}
-- Detect project types
for lang, patterns in pairs(project_patterns) do
for _, pattern in ipairs(patterns) do
if vim.fn.glob(pattern) ~= "" then
detected_languages[lang] = true
break
end
end
end
-- Setup configurations for detected languages
if detected_languages.typescript or detected_languages.javascript then
dap.configurations.typescript = {
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "attach",
name = "Attach",
processId = require("dap.utils").pick_process,
cwd = "${workspaceFolder}",
},
}
dap.configurations.javascript = dap.configurations.typescript
end
if detected_languages.rust then
dap.configurations.rust = {
{
type = "codelldb",
request = "launch",
name = "Launch file",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
},
}
end
if detected_languages.cpp or detected_languages.c then
dap.configurations.cpp = {
{
type = "codelldb",
request = "launch",
name = "Launch file",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
},
}
dap.configurations.c = dap.configurations.cpp
end
end
-- Setup DAP keymaps
local function setup_dap_keymaps()
local dap = require("dap")
local map = function(key, func, desc)
vim.keymap.set("n", key, func, { noremap = true, silent = true, desc = desc })
end
map("<F5>", dap.continue, "DAP Continue")
map("<F10>", dap.step_over, "DAP Step Over")
map("<F11>", dap.step_into, "DAP Step Into")
map("<F12>", dap.step_out, "DAP Step Out")
map("<leader>b", dap.toggle_breakpoint, "Toggle Breakpoint")
map("<leader>B", function()
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
end, "Conditional Breakpoint")
map("<leader>dr", dap.repl.open, "Open DAP REPL")
map("<leader>dl", dap.run_last, "Run Last DAP")
end
return {
"williamboman/mason.nvim",
dependencies = {
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
"hrsh7th/cmp-nvim-lsp",
"nvim-telescope/telescope.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
-- DAP dependencies
"mfussenegger/nvim-dap",
"jay-babu/mason-nvim-dap.nvim",
"rcarriga/nvim-dap-ui",
"theHamsta/nvim-dap-virtual-text",
"nvim-neotest/nvim-nio",
-- Formatting/Linting
"nvimtools/none-ls.nvim",
{
"folke/lazydev.nvim",
ft = "lua",
opts = {
library = {
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
},
config = function()
-- Mason setup
require("mason").setup()
-- Install tools and DAP adapters
require("mason-tool-installer").setup({
ensure_installed = vim.list_extend(tools, dap_adapters),
automatic_installation = true,
})
-- LSP setup
require("mason-lspconfig").setup({
ensure_installed = lsp_servers, ensure_installed = lsp_servers,
automatic_enable = true, -- v2
})
end
-- If you want mason-tool-installer to fetch tools only (no config in this file):
local ok_mti, mti = pcall(require, "mason-tool-installer")
if ok_mti then
mti.setup({
ensure_installed = tools, -- harmless to keep; you can remove if you prefer
automatic_installation = true, automatic_installation = true,
automatic_enable = true,
}) })
end
-- None-ls setup
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.prettierd,
null_ls.builtins.formatting.latexindent,
},
})
-- LSP server configurations
local capabilities = require("cmp_nvim_lsp").default_capabilities()
for _, lsp_server in pairs(lsp_servers) do
local server_config = {
on_attach = on_attach,
capabilities = capabilities,
}
if lsp_server == "texlab" then
server_config.settings = {
texlab = {
latexFormatter = "latexindent",
},
}
end end
require("lspconfig")[lsp_server].setup(server_config) -- Shared on_attach: native omni + Telescope pickers
local function on_attach(_, bufnr)
vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufnr })
vim.api.nvim_set_option_value("tagfunc", "v:lua.vim.lsp.tagfunc", { buf = bufnr })
local function map(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, noremap = true, silent = true, desc = desc })
end end
require("mason-nvim-dap").setup({ local group = vim.api.nvim_create_augroup("LspFormatOnSave_" .. bufnr, { clear = true })
ensure_installed = dap_adapters, vim.api.nvim_create_autocmd("BufWritePre", {
automatic_installation = true, group = group,
-- handlers = { buffer = bufnr,
-- return function(config) callback = function()
-- require("mason-nvim-dap").default_setup(config) -- Prefer synchronous formatting with timeout to avoid blocking too long
-- end, if vim.lsp.buf.format then
-- vim.lsp.buf.format({
-- -- -- Custom adapter configurations async = false,
-- -- ["js-debug-adapter"] = function(config) timeout_ms = 1500,
-- -- config.adapters = {
-- -- type = "server",
-- -- host = "localhost",
-- -- port = "${port}",
-- -- executable = {
-- -- command = "js-debug-adapter",
-- -- args = { "${port}" },
-- -- },
-- -- }
-- -- require("mason-nvim-dap").default_setup(config)
-- -- end,
-- },
}) })
-- DAP UI setup
local dap, dapui = require("dap"), require("dapui")
dapui.setup({
layouts = {
{
elements = {
{ id = "scopes", size = 0.25 },
{ id = "breakpoints", size = 0.25 },
{ id = "stacks", size = 0.25 },
{ id = "watches", size = 0.25 },
},
size = 40,
position = "left",
},
{
elements = { "repl", "console" },
size = 10,
position = "bottom",
},
},
})
-- Auto-open/close DAP UI
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
-- DAP Virtual Text
require("nvim-dap-virtual-text").setup({
enabled = true,
enabled_commands = true,
highlight_changed_variables = true,
highlight_new_as_changed = false,
show_stop_reason = true,
commented = false,
})
-- Setup DAP configurations and keymaps
setup_dap_configs()
setup_dap_keymaps()
-- Additional DAP UI keymap
vim.keymap.set("n", "<leader>du", dapui.toggle, { desc = "Toggle DAP UI" })
end, end,
} desc = "LSP format before save",
})
-- Telescope-powered LSP navigation (loads telescope.builtin on demand)
local function tb(fn)
return function()
local ok, builtin = pcall(require, "telescope.builtin")
if not ok then
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
ok, builtin = pcall(require, "telescope.builtin")
end
if ok and builtin[fn] then
builtin[fn]()
else
vim.notify("Telescope not available", vim.log.levels.WARN)
end
end
end
map("n", "gd", tb("lsp_definitions"), "Goto Definition (Telescope)")
map("n", "gr", tb("lsp_references"), "Goto References (Telescope)")
map("n", "gI", tb("lsp_implementations"), "Goto Implementations (Telescope)")
map("n", "gt", tb("lsp_type_definitions"), "Goto Type Definitions (Telescope)")
-- LSP basics
map("n", "K", vim.lsp.buf.hover, "Hover")
map("n", "<leader>rn", vim.lsp.buf.rename, "Rename")
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, "Code Action")
map("n", "[d", vim.diagnostic.goto_prev, "Prev Diagnostic")
map("n", "]d", vim.diagnostic.goto_next, "Next Diagnostic")
map("n", "<leader>e", vim.diagnostic.open_float, "Line Diagnostics")
pcall(vim.lsp.inlay_hint.enable, true, { bufnr = bufnr })
end
-- Global LSP defaults
vim.lsp.config("*", {
on_attach = on_attach,
capabilities = (function()
local caps = vim.lsp.protocol.make_client_capabilities()
caps.textDocument = caps.textDocument or {}
caps.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true }
return caps
end)(),
})
-- Server-specific tweaks
vim.lsp.config("lua_ls", {
settings = {
Lua = {
diagnostics = { globals = { "vim", "require" } },
completion = { callSnippet = "Replace" },
workspace = { checkThirdParty = false },
},
},
})
-- Enable servers (Neovim 0.11+)
vim.lsp.enable(lsp_servers)
-- Trigger omni (like cmp.complete)
vim.keymap.set("i", "<C-Space>", function()
if vim.bo.omnifunc == "v:lua.vim.lsp.omnifunc" then
return vim.api.nvim_replace_termcodes("<C-x><C-o>", true, true, true)
end
return ""
end, { expr = true, silent = true, desc = "Trigger omni-completion" })
-- Navigate popup menu
vim.keymap.set("i", "<C-j>", "<C-n>", { silent = true, desc = "Omni next item" })
vim.keymap.set("i", "<C-k>", "<C-p>", { silent = true, desc = "Omni prev item" })
-- Enter to confirm when pum is visible, otherwise newline
vim.keymap.set("i", "<CR>", function()
if vim.fn.pumvisible() == 1 then
-- Confirm current selection; if none selected, accept first
return vim.api.nvim_replace_termcodes("<C-y>", true, true, true)
end
return vim.api.nvim_replace_termcodes("<CR>", true, true, true)
end, { expr = true, silent = true, desc = "Confirm completion or newline" })
-- Requires your existing LuaSnip setup and mappings
local ok_ls, ls = pcall(require, "luasnip")
if ok_ls then
-- Tab: if menu visible, next item; else snippet expand/jump; else literal Tab
vim.keymap.set({ "i", "s" }, "<Tab>", function()
if vim.fn.pumvisible() == 1 then
return vim.api.nvim_replace_termcodes("<C-n>", true, true, true)
elseif ls.expand_or_jumpable() then
return "<Plug>luasnip-expand-or-jump"
else
return "<Tab>"
end
end, { expr = true, silent = true, desc = "Next item / Snippet jump / Tab" })
-- Shift-Tab: if menu visible, prev item; else snippet jump back; else literal
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
if vim.fn.pumvisible() == 1 then
return vim.api.nvim_replace_termcodes("<C-p>", true, true, true)
elseif ls.jumpable(-1) then
return "<Plug>luasnip-jump-prev"
else
return "<S-Tab>"
end
end, { expr = true, silent = true, desc = "Prev item / Snippet back / Shift-Tab" })
end

View File

@ -1,9 +1,28 @@
return { -- Declare plugins
'stevearc/oil.nvim', vim.pack.add({
opts = {}, { src = "https://github.com/nvim-lua/plenary.nvim", version = "master" },
dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons { src = "https://github.com/stevearc/oil.nvim", version = "master" },
config = function() })
require("oil").setup()
vim.keymap.set('n', '<leader>ee', "<cmd>:Oil<cr>") -- Try to load packs on startup
vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
if vim.pack.load then pcall(vim.pack.load) end
-- Configure oil (guarded)
local ok, oil = pcall(require, "oil")
if ok then
pcall(oil.setup, {})
else
-- If it wasn't on rtp yet, try once shortly after
vim.schedule(function()
local ok2, oil2 = pcall(require, "oil")
if ok2 then pcall(oil2.setup, {}) end
end)
end end
} end,
})
-- Keymap (works whether eager or lazy)
vim.keymap.set("n", "<leader>fe", "<cmd>Oil<cr>", { desc = "Open Oil" })

View File

@ -1,30 +0,0 @@
return {
"tris203/precognition.nvim",
event = "VeryLazy",
opts = {
startVisible = false,
-- showBlankVirtLine = true,
-- highlightColor = { link = "Comment" },
-- hints = {
-- Caret = { text = "^", prio = 2 },
-- Dollar = { text = "$", prio = 1 },
-- MatchingPair = { text = "%", prio = 5 },
-- Zero = { text = "0", prio = 1 },
-- w = { text = "w", prio = 10 },
-- b = { text = "b", prio = 9 },
-- e = { text = "e", prio = 8 },
-- W = { text = "W", prio = 7 },
-- B = { text = "B", prio = 6 },
-- E = { text = "E", prio = 5 },
-- },
-- gutterHints = {
-- G = { text = "G", prio = 10 },
-- gg = { text = "gg", prio = 9 },
-- PrevParagraph = { text = "{", prio = 8 },
-- NextParagraph = { text = "}", prio = 8 },
-- },
-- disabled_fts = {
-- "startify",
-- },
},
}

View File

@ -1,13 +1,45 @@
return { -- Ensure packs are added
'nvim-telescope/telescope.nvim', vim.pack.add({
tag = '0.1.8', { src = "https://github.com/nvim-lua/plenary.nvim", version = "master" },
dependencies = { { src = "https://github.com/nvim-telescope/telescope.nvim", version = "master" },
'nvim-lua/plenary.nvim', -- Optional native sorter (requires a C toolchain)
-- { 'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release' } { src = "https://github.com/nvim-telescope/telescope-fzf-native.nvim", version = "main", build = "make" },
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' } })
},
config = function() -- Helper: find fzf-native root and build/lib path if installed
require('telescope').setup { local function fzf_native_paths()
local lua_file = vim.api.nvim_get_runtime_file("lua/fzf_lib.lua", true)[1]
if not lua_file then return nil end
local root = lua_file:gsub("/lua/fzf_lib.lua$", "")
local lib = root .. "/build/libfzf.so"
return { root = root, lib = lib }
end
-- Try to build fzf-native if the .so is missing
local function ensure_fzf_native_built()
local p = fzf_native_paths()
if not p then return false end
if vim.uv.fs_stat(p.lib) then return true end
-- Attempt to run `make` in the plugin directory
vim.notify("Building telescope-fzf-native (make)...", vim.log.levels.INFO)
local ok = pcall(function()
vim.system({ "make" }, { cwd = p.root }):wait()
end)
if ok and vim.uv.fs_stat(p.lib) then
vim.notify("telescope-fzf-native built successfully", vim.log.levels.INFO)
return true
else
vim.notify("telescope-fzf-native build failed or library missing", vim.log.levels.WARN)
return false
end
end
-- Configure Telescope when available; try on VimEnter, retry once
local function telescope_setup()
local ok, telescope = pcall(require, "telescope")
if not ok then return false end
telescope.setup({
pickers = { pickers = {
find_files = { find_files = {
hidden = true, hidden = true,
@ -24,15 +56,50 @@ return {
override_generic_sorter = true, override_generic_sorter = true,
override_file_sorter = true, override_file_sorter = true,
case_mode = "ignore_case", case_mode = "ignore_case",
} },
} },
} })
require('telescope').load_extension('fzf')
-- Load fzf extension only if built; call protected to avoid hard errors
if ensure_fzf_native_built() then
pcall(telescope.load_extension, "fzf")
end
return true
end
vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
if not telescope_setup() then
vim.schedule(telescope_setup)
end
end, end,
keys = { })
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "[F]ind [F]iles" },
{ "<leader>fh", "<cmd>Telescope help_tags<cr>", desc = "[F]ind [H]elp" }, -- Always define keymaps; they load telescope on first use if needed
{ "<leader>fd", "<cmd>Telescope diagnostics<cr>", desc = "[F]ind [D]iadgnostics" }, local function map(lhs, fn, desc)
{ "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "[F]ind [G]rep" }, vim.keymap.set("n", lhs, fn, { noremap = true, silent = true, desc = desc })
} end
}
-- On-demand wrappers that require telescope.builtin when called
local function with_builtin(name)
return function()
local ok, builtin = pcall(require, "telescope.builtin")
if not ok then
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
ok, builtin = pcall(require, "telescope.builtin")
end
if ok and builtin[name] then
builtin[name]()
else
vim.notify("Telescope not available yet", vim.log.levels.WARN)
end
end
end
map("<leader>ff", with_builtin("find_files"), "Find files")
map("<leader>fg", with_builtin("live_grep"), "Live grep")
map("<leader>fb", with_builtin("buffers"), "Buffers")
map("<leader>fh", with_builtin("help_tags"), "Help tags")

View File

@ -1,9 +1,29 @@
return { vim.pack.add({
"ellisonleao/gruvbox.nvim", { src = "https://github.com/nvim-lualine/lualine.nvim" },
priority = 1000 , { src = "https://github.com/ellisonleao/gruvbox.nvim" },
config = function() })
vim.o.background = "dark" -- or "light" for light mode
vim.cmd([[colorscheme gruvbox]])
end
}
vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
pcall(function()
-- Ensure colorscheme is available; set it if you want
-- vim.cmd("colorscheme gruvbox")
-- lualine theme can be specified by name or theme table.
-- Using the built-in "gruvbox" theme name is simplest:
require("lualine").setup({
options = {
theme = "gruvbox",
icons_enabled = true,
always_divide_middle = true,
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
},
})
vim.cmd.colorscheme("gruvbox")
end)
end,
})

View File

@ -1,15 +1,41 @@
return { -- Ensure packs are added
"nvim-treesitter/nvim-treesitter", vim.pack.add({
build = ":TSUpdate", { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" },
event = { "VeryLazy" }, })
lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
opts = { -- Configure after packs are loaded (PackLoad is emitted by vim.pack.load)
highlight = { enable = true }, vim.api.nvim_create_autocmd("User", {
pattern = "PackLoad",
once = true,
callback = function()
local ok, configs = pcall(require, "nvim-treesitter.configs")
if not ok then
vim.notify("nvim-treesitter not available yet", vim.log.levels.WARN)
return
end
configs.setup({
auto_install = true,
highlight = { enable = true, additional_vim_regex_highlighting = false },
indent = { enable = true }, indent = { enable = true },
auto_install = { enable = true } })
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end, end,
} })
vim.api.nvim_create_autocmd('PackChanged', {
desc = 'Handle nvim-treesitter updates',
group = vim.api.nvim_create_augroup('nvim-treesitter-pack-changed-update-handler', { clear = true }),
callback = function(event)
if event.data.kind == 'update' and event.data.spec.name == 'nvim-treesitter' then
vim.notify('nvim-treesitter updated, running TSUpdate...', vim.log.levels.INFO)
---@diagnostic disable-next-line: param-type-mismatch
local ok = pcall(vim.cmd, 'TSUpdate')
if ok then
vim.notify('TSUpdate completed successfully!', vim.log.levels.INFO)
else
vim.notify('TSUpdate command not available yet, skipping', vim.log.levels.WARN)
end
end
end,
})

View File

@ -1,37 +0,0 @@
return {
"folke/trouble.nvim",
opts = {}, -- for default options, refer to the configuration section for custom setup.
cmd = "Trouble",
keys = {
{
"<leader>xx",
"<cmd>Trouble diagnostics toggle<cr>",
desc = "Diagnostics (Trouble)",
},
{
"<leader>xX",
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
desc = "Buffer Diagnostics (Trouble)",
},
{
"<leader>cs",
"<cmd>Trouble symbols toggle focus=false<cr>",
desc = "Symbols (Trouble)",
},
{
"<leader>cl",
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
desc = "LSP Definitions / references / ... (Trouble)",
},
{
"<leader>xL",
"<cmd>Trouble loclist toggle<cr>",
desc = "Location List (Trouble)",
},
{
"<leader>xQ",
"<cmd>Trouble qflist toggle<cr>",
desc = "Quickfix List (Trouble)",
},
},
}

View File

@ -0,0 +1,3 @@
vim.pack.add({
{ src = "https://github.com/folke/which-key.nvim"},
})

View File

@ -1,14 +0,0 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
opts = true,
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
}

6
nvim/main.ts Normal file
View File

@ -0,0 +1,6 @@
const ciao = () => {
console.log("ciao")
}
ciao()