From 28598c5e1d08226dc9ce36a0f75853e89558243c Mon Sep 17 00:00:00 2001 From: Dmitri Date: Sat, 20 Sep 2025 12:15:39 +0200 Subject: [PATCH] neovim refactor --- .gitconfig | 2 + .zshrc | 4 + nvim/init.lua | 16 +- nvim/lua/kanopo/autocmds.lua | 26 +- nvim/lua/kanopo/lazy.lua | 18 -- nvim/lua/kanopo/options.lua | 204 ++++++------ nvim/lua/kanopo/plugins/auto-pairs.lua | 17 + nvim/lua/kanopo/plugins/autopairs.lua | 9 - nvim/lua/kanopo/plugins/bottom-bar.lua | 12 - nvim/lua/kanopo/plugins/cmp.lua | 107 ------- nvim/lua/kanopo/plugins/comments.lua | 12 - nvim/lua/kanopo/plugins/dressing.lua | 27 +- nvim/lua/kanopo/plugins/fidget.lua | 18 +- nvim/lua/kanopo/plugins/git.lua | 53 +++- nvim/lua/kanopo/plugins/gitsigns.lua | 6 - nvim/lua/kanopo/plugins/harpoon.lua | 14 - nvim/lua/kanopo/plugins/init.lua | 11 + nvim/lua/kanopo/plugins/lazydev.lua | 10 + nvim/lua/kanopo/plugins/leetcode.lua | 16 - nvim/lua/kanopo/plugins/lsp.lua | 383 +++++++++-------------- nvim/lua/kanopo/plugins/oil.lua | 37 ++- nvim/lua/kanopo/plugins/precognition.lua | 30 -- nvim/lua/kanopo/plugins/telescope.lua | 141 ++++++--- nvim/lua/kanopo/plugins/theme.lua | 36 ++- nvim/lua/kanopo/plugins/treesitter.lua | 56 +++- nvim/lua/kanopo/plugins/trouble.lua | 37 --- nvim/lua/kanopo/plugins/which-key.lua | 3 + nvim/lua/kanopo/plugins/whick-key.lua | 14 - nvim/main.ts | 6 + 29 files changed, 605 insertions(+), 720 deletions(-) delete mode 100644 nvim/lua/kanopo/lazy.lua create mode 100644 nvim/lua/kanopo/plugins/auto-pairs.lua delete mode 100644 nvim/lua/kanopo/plugins/autopairs.lua delete mode 100644 nvim/lua/kanopo/plugins/bottom-bar.lua delete mode 100644 nvim/lua/kanopo/plugins/cmp.lua delete mode 100644 nvim/lua/kanopo/plugins/comments.lua delete mode 100644 nvim/lua/kanopo/plugins/gitsigns.lua delete mode 100644 nvim/lua/kanopo/plugins/harpoon.lua create mode 100644 nvim/lua/kanopo/plugins/init.lua create mode 100644 nvim/lua/kanopo/plugins/lazydev.lua delete mode 100644 nvim/lua/kanopo/plugins/leetcode.lua delete mode 100644 nvim/lua/kanopo/plugins/precognition.lua delete mode 100644 nvim/lua/kanopo/plugins/trouble.lua create mode 100644 nvim/lua/kanopo/plugins/which-key.lua delete mode 100644 nvim/lua/kanopo/plugins/whick-key.lua create mode 100644 nvim/main.ts diff --git a/.gitconfig b/.gitconfig index 4c1402f..34f2f90 100644 --- a/.gitconfig +++ b/.gitconfig @@ -19,3 +19,5 @@ required = true [init] defaultBranch = main +[url "https://x-access-token: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@github.com/"] + insteadOf = https://github.com/ diff --git a/.zshrc b/.zshrc index 4ad9372..d1f6ebc 100644 --- a/.zshrc +++ b/.zshrc @@ -54,3 +54,7 @@ source ~/.cargo/env export GOROOT="$HOME/.local/bin/go" export GOPATH="$HOME/.go" 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 diff --git a/nvim/init.lua b/nvim/init.lua index 0b28c73..abe3a63 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -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.lazy") require("kanopo.autocmds") +require("kanopo.plugins") diff --git a/nvim/lua/kanopo/autocmds.lua b/nvim/lua/kanopo/autocmds.lua index 77a11d8..2eddef4 100644 --- a/nvim/lua/kanopo/autocmds.lua +++ b/nvim/lua/kanopo/autocmds.lua @@ -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) - local client = vim.lsp.get_client_by_id(args.data.client_id) - if not client then return end - - if client.supports_method("textDocument/formatting") then - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = args.buf, - callback = function() - vim.lsp.buf.format({ - bufnr = args.buf, - id = client.id - }) - end - }) + local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) + if client:supports_method('textDocument/completion') then + -- Optional: trigger autocompletion on EVERY keypress. May be slow! + local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end + client.server_capabilities.completionProvider.triggerCharacters = chars + vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true }) end - end + end, }) -- Highlight yanked text @@ -28,7 +21,6 @@ vim.api.nvim_create_autocmd("TextYankPost", { pattern = "*", }) - -- Go to last cursor position when opening a file vim.api.nvim_create_autocmd("BufReadPost", { callback = function() diff --git a/nvim/lua/kanopo/lazy.lua b/nvim/lua/kanopo/lazy.lua deleted file mode 100644 index 0edc85a..0000000 --- a/nvim/lua/kanopo/lazy.lua +++ /dev/null @@ -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") diff --git a/nvim/lua/kanopo/options.lua b/nvim/lua/kanopo/options.lua index aec32c0..cf75a74 100644 --- a/nvim/lua/kanopo/options.lua +++ b/nvim/lua/kanopo/options.lua @@ -1,104 +1,128 @@ --- options.lua -vim.opt.cmdheight = 0 - --- Leader key for all the keymaps +-- +-- vim.o.relativenumber = true +-- vim.o.wrap = false +-- 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.maplocalleader = " " --------------------------------------------------------------------------------- --- -- GENERAL EDITOR BEHAVIOR --------------------------------------------------------------------------------- -vim.opt.clipboard = "unnamedplus" -- Use system clipboard -vim.opt.writebackup = false -- Disable backup files -vim.opt.undofile = true -- Enable persistent undo -vim.opt.wrap = false -- Do not wrap lines -vim.opt.conceallevel = 2 -- Hide markdown syntax, etc. -vim.opt.signcolumn = "yes" -- Always show the sign column to avoid resizing -vim.opt.timeoutlen = 300 -- Time to wait for a mapped sequence to complete -vim.opt.updatetime = 250 -- Faster completion and CursorHold updates -vim.o.winborder = "rounded" +-- UI and appearance +vim.o.termguicolors = true -- 24-bit colors in TUI +vim.o.cursorline = true -- highlight current line +vim.o.number = true -- absolute line numbers +vim.o.relativenumber = true -- relative line numbers +vim.o.signcolumn = "yes" -- always show signcolumn +vim.o.colorcolumn = "100" -- visual column guide +vim.o.winborder = "rounded" -- default floating window border +vim.o.cmdheight = 0 -- minimal command-line height (NVIM 0.10+) +vim.o.conceallevel = 2 -- conceal in Markdown/jsonc when appropriate +vim.o.foldlevel = 0 -- start with folds closed (Treesitter can open) --- 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_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 --------------------------------------------------------------------------------- --- -- UI AND APPEARANCE --------------------------------------------------------------------------------- -vim.opt.number = true -- Show line numbers -vim.opt.relativenumber = true -- Show relative line numbers -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 +-- Netrw (disable if using an explorer plugin like oil.nvim; enable if you rely on netrw) +vim.g.loaded_netrw = 0 +vim.g.loaded_netrwPlugin = 0 +-- If you need netrw again, set both back to nil or 0 and restart: +-- vim.g.loaded_netrw = nil; vim.g.loaded_netrwPlugin = nil --------------------------------------------------------------------------------- --- -- SEARCHING --------------------------------------------------------------------------------- -vim.opt.ignorecase = true -- Case-insensitive searching -vim.opt.smartcase = true -- ...unless the query contains a capital letter +-- Filetype-specific indentation overrides (examples) +local ft_augroup = vim.api.nvim_create_augroup("FileTypeSettings", { clear = true }) --------------------------------------------------------------------------------- --- -- SPELL CHECKING (currently disabled) --------------------------------------------------------------------------------- +-- C-like and web files: 2 spaces (adjust as needed) +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.spelllang = "en,it" -- local spell_dir = vim.fn.stdpath("data") .. "/spell" -- vim.opt.spellfile = { --- spell_dir .. "/en.utf-8.add", --- spell_dir .. "/it.utf-8.add", --- "~/.config/nvim/spell/en.proj.spl", --- "~/.config/nvim/spell/it.proj.spl", +-- spell_dir .. "/en.utf-8.add", +-- spell_dir .. "/it.utf-8.add", +-- "~/.config/nvim/spell/en.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, --- }) diff --git a/nvim/lua/kanopo/plugins/auto-pairs.lua b/nvim/lua/kanopo/plugins/auto-pairs.lua new file mode 100644 index 0000000..20d3c58 --- /dev/null +++ b/nvim/lua/kanopo/plugins/auto-pairs.lua @@ -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, +}) diff --git a/nvim/lua/kanopo/plugins/autopairs.lua b/nvim/lua/kanopo/plugins/autopairs.lua deleted file mode 100644 index fbdf5ef..0000000 --- a/nvim/lua/kanopo/plugins/autopairs.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - "windwp/nvim-autopairs", - event = "InsertEnter", - config = function() - require("nvim-autopairs").setup({ - disable_filetype = { "TelescopePrompt", "vim" }, - }) - end, -} diff --git a/nvim/lua/kanopo/plugins/bottom-bar.lua b/nvim/lua/kanopo/plugins/bottom-bar.lua deleted file mode 100644 index 080683e..0000000 --- a/nvim/lua/kanopo/plugins/bottom-bar.lua +++ /dev/null @@ -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, -} diff --git a/nvim/lua/kanopo/plugins/cmp.lua b/nvim/lua/kanopo/plugins/cmp.lua deleted file mode 100644 index 939c9b3..0000000 --- a/nvim/lua/kanopo/plugins/cmp.lua +++ /dev/null @@ -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({ - [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [""] = cmp.mapping.confirm({ select = true }), - [""] = 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", - }), - [""] = 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, -} diff --git a/nvim/lua/kanopo/plugins/comments.lua b/nvim/lua/kanopo/plugins/comments.lua deleted file mode 100644 index 20243a9..0000000 --- a/nvim/lua/kanopo/plugins/comments.lua +++ /dev/null @@ -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" }, - }, - } -} diff --git a/nvim/lua/kanopo/plugins/dressing.lua b/nvim/lua/kanopo/plugins/dressing.lua index 6ce1646..a29ee5c 100644 --- a/nvim/lua/kanopo/plugins/dressing.lua +++ b/nvim/lua/kanopo/plugins/dressing.lua @@ -1,8 +1,19 @@ -return { - "stevearc/dressing.nvim", - opts = { - inputs = { - enable = true, - } - }, -} +-- dressing.lua +vim.pack.add({ + { src = "https://github.com/stevearc/dressing.nvim" }, +}) + +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, +}) diff --git a/nvim/lua/kanopo/plugins/fidget.lua b/nvim/lua/kanopo/plugins/fidget.lua index 5450252..7cccd47 100644 --- a/nvim/lua/kanopo/plugins/fidget.lua +++ b/nvim/lua/kanopo/plugins/fidget.lua @@ -1,4 +1,14 @@ -return { - "j-hui/fidget.nvim", - opts = {}, -} +vim.pack.add({ + { src = "https://github.com/j-hui/fidget.nvim", version = "main" }, +}) + +-- 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, +}) diff --git a/nvim/lua/kanopo/plugins/git.lua b/nvim/lua/kanopo/plugins/git.lua index 24a6eab..c2674d6 100644 --- a/nvim/lua/kanopo/plugins/git.lua +++ b/nvim/lua/kanopo/plugins/git.lua @@ -1,16 +1,37 @@ -return { - "NeogitOrg/neogit", - dependencies = { - "nvim-lua/plenary.nvim", - "sindrets/diffview.nvim", - "nvim-telescope/telescope.nvim", - }, - -- config = function() - -- require("neogit").setup() - -- vim.keymap.set("n", "gg", "Neogit", { desc = "Neogit" }) - -- end, - opts = true, - keys = { - { "gg", "Neogit", desc = "Neogit" }, - }, -} +-- Declare plugins +vim.pack.add({ + { src = "https://github.com/NeogitOrg/neogit" }, + { src = "https://github.com/lewis6991/gitsigns.nvim" }, +}) + +-- Load packs on startup (guard for nightlies without load) +vim.api.nvim_create_autocmd("VimEnter", { + once = true, + callback = function() + if vim.pack and vim.pack.load then pcall(vim.pack.load) end + + -- Configure gitsigns (safe pcall) + 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", "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" }) diff --git a/nvim/lua/kanopo/plugins/gitsigns.lua b/nvim/lua/kanopo/plugins/gitsigns.lua deleted file mode 100644 index f6c7690..0000000 --- a/nvim/lua/kanopo/plugins/gitsigns.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - "lewis6991/gitsigns.nvim", - event = "BufRead", - opts = {}, -} - diff --git a/nvim/lua/kanopo/plugins/harpoon.lua b/nvim/lua/kanopo/plugins/harpoon.lua deleted file mode 100644 index 019cdc2..0000000 --- a/nvim/lua/kanopo/plugins/harpoon.lua +++ /dev/null @@ -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", "a", function() harpoon:list():add() end) - vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) - end -} diff --git a/nvim/lua/kanopo/plugins/init.lua b/nvim/lua/kanopo/plugins/init.lua new file mode 100644 index 0000000..f7a00e2 --- /dev/null +++ b/nvim/lua/kanopo/plugins/init.lua @@ -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") diff --git a/nvim/lua/kanopo/plugins/lazydev.lua b/nvim/lua/kanopo/plugins/lazydev.lua new file mode 100644 index 0000000..e5b6d99 --- /dev/null +++ b/nvim/lua/kanopo/plugins/lazydev.lua @@ -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" } }, + }, +}) diff --git a/nvim/lua/kanopo/plugins/leetcode.lua b/nvim/lua/kanopo/plugins/leetcode.lua deleted file mode 100644 index dd5c63e..0000000 --- a/nvim/lua/kanopo/plugins/leetcode.lua +++ /dev/null @@ -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" - } - }, -} diff --git a/nvim/lua/kanopo/plugins/lsp.lua b/nvim/lua/kanopo/plugins/lsp.lua index b3b07c4..a659aa4 100644 --- a/nvim/lua/kanopo/plugins/lsp.lua +++ b/nvim/lua/kanopo/plugins/lsp.lua @@ -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 = { "lua_ls", "ts_ls", @@ -12,276 +30,161 @@ local lsp_servers = { "gopls", } +-- Optional: tools you might install later (kept, but not used for formatting here) local tools = { "luacheck", "latexindent", "prettierd", } --- DAP adapters that will be auto-installed based on your LSP servers -local dap_adapters = { -} +-- Mason + mason-lspconfig +do + local ok, mason = pcall(require, "mason") + if ok then mason.setup() end -local on_attach = function(_, bufnr) - local map = function(key, func, desc) - vim.keymap.set("n", key, func, { noremap = true, silent = true, desc = desc, buffer = bufnr }) + local ok_mlsp, mlsp = pcall(require, "mason-lspconfig") + if ok_mlsp then + mlsp.setup({ + ensure_installed = lsp_servers, + automatic_enable = true, -- v2 + }) end - local telescope = require("telescope.builtin") - - -- LSP mappings - map("rn", "lua vim.lsp.buf.rename()", "[R]ename Symbol") - map("ca", "lua vim.lsp.buf.code_action()", "[C]ode [A]ction") - map("K", "lua vim.lsp.buf.hover()", "[K] Hover") - map("d", "lua vim.diagnostic.open_float()", "[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") + -- 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, + }) + end end --- Auto-detect project type and setup DAP configurations -local function setup_dap_configs() - local dap = require("dap") +-- 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 }) - -- 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 function map(mode, lhs, rhs, desc) + vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, noremap = true, silent = true, desc = desc }) + end - local detected_languages = {} + local group = vim.api.nvim_create_augroup("LspFormatOnSave_" .. bufnr, { clear = true }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = group, + buffer = bufnr, + callback = function() + -- Prefer synchronous formatting with timeout to avoid blocking too long + if vim.lsp.buf.format then + vim.lsp.buf.format({ + async = false, + timeout_ms = 1500, + }) + end + end, + desc = "LSP format before save", + }) - -- 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 + -- 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 - -- 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 + 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)") - 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 + -- LSP basics + map("n", "K", vim.lsp.buf.hover, "Hover") + map("n", "rn", vim.lsp.buf.rename, "Rename") + map({ "n", "v" }, "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", "e", vim.diagnostic.open_float, "Line Diagnostics") - 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 + pcall(vim.lsp.inlay_hint.enable, true, { bufnr = bufnr }) 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 +-- 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)(), +}) - map("", dap.continue, "DAP Continue") - map("", dap.step_over, "DAP Step Over") - map("", dap.step_into, "DAP Step Into") - map("", dap.step_out, "DAP Step Out") - map("b", dap.toggle_breakpoint, "Toggle Breakpoint") - map("B", function() - dap.set_breakpoint(vim.fn.input("Breakpoint condition: ")) - end, "Conditional Breakpoint") - map("dr", dap.repl.open, "Open DAP REPL") - map("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" } }, - }, - }, +-- Server-specific tweaks +vim.lsp.config("lua_ls", { + settings = { + Lua = { + diagnostics = { globals = { "vim", "require" } }, + completion = { callSnippet = "Replace" }, + workspace = { checkThirdParty = false }, }, }, - 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, - }) +-- Enable servers (Neovim 0.11+) +vim.lsp.enable(lsp_servers) - -- LSP setup - require("mason-lspconfig").setup({ - ensure_installed = lsp_servers, - automatic_installation = true, - automatic_enable = true, - }) +-- Trigger omni (like cmp.complete) +vim.keymap.set("i", "", function() + if vim.bo.omnifunc == "v:lua.vim.lsp.omnifunc" then + return vim.api.nvim_replace_termcodes("", true, true, true) + end + return "" +end, { expr = true, silent = true, desc = "Trigger omni-completion" }) - -- None-ls setup - local null_ls = require("null-ls") - null_ls.setup({ - sources = { - null_ls.builtins.formatting.prettierd, - null_ls.builtins.formatting.latexindent, - }, - }) +-- Navigate popup menu +vim.keymap.set("i", "", "", { silent = true, desc = "Omni next item" }) +vim.keymap.set("i", "", "", { silent = true, desc = "Omni prev item" }) - -- LSP server configurations - local capabilities = require("cmp_nvim_lsp").default_capabilities() +-- Enter to confirm when pum is visible, otherwise newline +vim.keymap.set("i", "", function() + if vim.fn.pumvisible() == 1 then + -- Confirm current selection; if none selected, accept first + return vim.api.nvim_replace_termcodes("", true, true, true) + end + return vim.api.nvim_replace_termcodes("", true, true, true) +end, { expr = true, silent = true, desc = "Confirm completion or newline" }) - 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 - - require("lspconfig")[lsp_server].setup(server_config) +-- 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" }, "", function() + if vim.fn.pumvisible() == 1 then + return vim.api.nvim_replace_termcodes("", true, true, true) + elseif ls.expand_or_jumpable() then + return "luasnip-expand-or-jump" + else + return "" end + end, { expr = true, silent = true, desc = "Next item / Snippet jump / Tab" }) - require("mason-nvim-dap").setup({ - ensure_installed = dap_adapters, - automatic_installation = true, - -- handlers = { - -- return function(config) - -- require("mason-nvim-dap").default_setup(config) - -- end, - -- - -- -- -- Custom adapter configurations - -- -- ["js-debug-adapter"] = function(config) - -- -- 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() + -- Shift-Tab: if menu visible, prev item; else snippet jump back; else literal + vim.keymap.set({ "i", "s" }, "", function() + if vim.fn.pumvisible() == 1 then + return vim.api.nvim_replace_termcodes("", true, true, true) + elseif ls.jumpable(-1) then + return "luasnip-jump-prev" + else + return "" 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", "du", dapui.toggle, { desc = "Toggle DAP UI" }) - end, -} + end, { expr = true, silent = true, desc = "Prev item / Snippet back / Shift-Tab" }) +end diff --git a/nvim/lua/kanopo/plugins/oil.lua b/nvim/lua/kanopo/plugins/oil.lua index ab865e6..aca5fdc 100644 --- a/nvim/lua/kanopo/plugins/oil.lua +++ b/nvim/lua/kanopo/plugins/oil.lua @@ -1,9 +1,28 @@ -return { - 'stevearc/oil.nvim', - opts = {}, - dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons - config = function() - require("oil").setup() - vim.keymap.set('n', 'ee', ":Oil") - end -} +-- Declare plugins +vim.pack.add({ + { src = "https://github.com/nvim-lua/plenary.nvim", version = "master" }, + { src = "https://github.com/stevearc/oil.nvim", version = "master" }, +}) + +-- 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, +}) + +-- Keymap (works whether eager or lazy) +vim.keymap.set("n", "fe", "Oil", { desc = "Open Oil" }) diff --git a/nvim/lua/kanopo/plugins/precognition.lua b/nvim/lua/kanopo/plugins/precognition.lua deleted file mode 100644 index ead2fa5..0000000 --- a/nvim/lua/kanopo/plugins/precognition.lua +++ /dev/null @@ -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", - -- }, - }, -} diff --git a/nvim/lua/kanopo/plugins/telescope.lua b/nvim/lua/kanopo/plugins/telescope.lua index d5c3c14..1c1c356 100644 --- a/nvim/lua/kanopo/plugins/telescope.lua +++ b/nvim/lua/kanopo/plugins/telescope.lua @@ -1,38 +1,105 @@ -return { - 'nvim-telescope/telescope.nvim', - tag = '0.1.8', - dependencies = { - 'nvim-lua/plenary.nvim', - -- { 'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release' } - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' } +-- Ensure packs are added +vim.pack.add({ + { src = "https://github.com/nvim-lua/plenary.nvim", version = "master" }, + { src = "https://github.com/nvim-telescope/telescope.nvim", version = "master" }, + -- Optional native sorter (requires a C toolchain) + { src = "https://github.com/nvim-telescope/telescope-fzf-native.nvim", version = "main", build = "make" }, +}) + +-- Helper: find fzf-native root and build/lib path if installed +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 = { + find_files = { + hidden = true, + prompt_prefix = "πŸ” ", + }, + live_grep = { + hidden = true, + prompt_prefix = "πŸ” ", + }, }, - config = function() - require('telescope').setup { - pickers = { - find_files = { - hidden = true, - prompt_prefix = "πŸ” ", - }, - live_grep = { - hidden = true, - prompt_prefix = "πŸ” ", - }, - }, - extensions = { - fzf = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = "ignore_case", - } - } - } - require('telescope').load_extension('fzf') - end, - keys = { - { "ff", "Telescope find_files", desc = "[F]ind [F]iles" }, - { "fh", "Telescope help_tags", desc = "[F]ind [H]elp" }, - { "fd", "Telescope diagnostics", desc = "[F]ind [D]iadgnostics" }, - { "fg", "Telescope live_grep", desc = "[F]ind [G]rep" }, - } -} + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "ignore_case", + }, + }, + }) + + -- 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, +}) + +-- Always define keymaps; they load telescope on first use if needed +local function map(lhs, fn, desc) + 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("ff", with_builtin("find_files"), "Find files") +map("fg", with_builtin("live_grep"), "Live grep") +map("fb", with_builtin("buffers"), "Buffers") +map("fh", with_builtin("help_tags"), "Help tags") diff --git a/nvim/lua/kanopo/plugins/theme.lua b/nvim/lua/kanopo/plugins/theme.lua index f8c6599..46e12e8 100644 --- a/nvim/lua/kanopo/plugins/theme.lua +++ b/nvim/lua/kanopo/plugins/theme.lua @@ -1,9 +1,29 @@ -return { - "ellisonleao/gruvbox.nvim", - priority = 1000 , - config = function() - vim.o.background = "dark" -- or "light" for light mode - vim.cmd([[colorscheme gruvbox]]) - end -} +vim.pack.add({ + { src = "https://github.com/nvim-lualine/lualine.nvim" }, + { src = "https://github.com/ellisonleao/gruvbox.nvim" }, +}) +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, +}) diff --git a/nvim/lua/kanopo/plugins/treesitter.lua b/nvim/lua/kanopo/plugins/treesitter.lua index 44436c9..e3bcc88 100644 --- a/nvim/lua/kanopo/plugins/treesitter.lua +++ b/nvim/lua/kanopo/plugins/treesitter.lua @@ -1,15 +1,41 @@ -return { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - event = { "VeryLazy" }, - lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline - cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, - opts = { - highlight = { enable = true }, - indent = { enable = true }, - auto_install = { enable = true } - }, - config = function(_, opts) - require("nvim-treesitter.configs").setup(opts) - end, -} +-- Ensure packs are added +vim.pack.add({ + { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" }, +}) + + +-- Configure after packs are loaded (PackLoad is emitted by vim.pack.load) +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 }, + }) + 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, +}) + diff --git a/nvim/lua/kanopo/plugins/trouble.lua b/nvim/lua/kanopo/plugins/trouble.lua deleted file mode 100644 index e3ae746..0000000 --- a/nvim/lua/kanopo/plugins/trouble.lua +++ /dev/null @@ -1,37 +0,0 @@ -return { - "folke/trouble.nvim", - opts = {}, -- for default options, refer to the configuration section for custom setup. - cmd = "Trouble", - keys = { - { - "xx", - "Trouble diagnostics toggle", - desc = "Diagnostics (Trouble)", - }, - { - "xX", - "Trouble diagnostics toggle filter.buf=0", - desc = "Buffer Diagnostics (Trouble)", - }, - { - "cs", - "Trouble symbols toggle focus=false", - desc = "Symbols (Trouble)", - }, - { - "cl", - "Trouble lsp toggle focus=false win.position=right", - desc = "LSP Definitions / references / ... (Trouble)", - }, - { - "xL", - "Trouble loclist toggle", - desc = "Location List (Trouble)", - }, - { - "xQ", - "Trouble qflist toggle", - desc = "Quickfix List (Trouble)", - }, - }, -} diff --git a/nvim/lua/kanopo/plugins/which-key.lua b/nvim/lua/kanopo/plugins/which-key.lua new file mode 100644 index 0000000..558c613 --- /dev/null +++ b/nvim/lua/kanopo/plugins/which-key.lua @@ -0,0 +1,3 @@ +vim.pack.add({ + { src = "https://github.com/folke/which-key.nvim"}, +}) diff --git a/nvim/lua/kanopo/plugins/whick-key.lua b/nvim/lua/kanopo/plugins/whick-key.lua deleted file mode 100644 index c5f0a63..0000000 --- a/nvim/lua/kanopo/plugins/whick-key.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - "folke/which-key.nvim", - event = "VeryLazy", - opts = true, - keys = { - { - "?", - function() - require("which-key").show({ global = false }) - end, - desc = "Buffer Local Keymaps (which-key)", - }, - }, -} diff --git a/nvim/main.ts b/nvim/main.ts new file mode 100644 index 0000000..a4fc83b --- /dev/null +++ b/nvim/main.ts @@ -0,0 +1,6 @@ + +const ciao = () => { + console.log("ciao") +} + +ciao()