From 264654140666b3bae433bf78b1a083677a51fdff Mon Sep 17 00:00:00 2001 From: mace Date: Thu, 27 Aug 2026 22:27:26 +0200 Subject: [PATCH] Clean up config: fix broken plugin specs, dedupe options/keymaps, drop dead code - lspsaga: custom keys lived outside config(), so setup({}) ran empty and they never worked; moved into setup() and updated to the plugin's current option schema (finder_action_keys/definition_action_keys/move_in_saga are stale names in the installed version) - catppuccin: fixed a stray `as = "catppuccin"` key left outside the plugin table; wrapped as { "catppuccin/nvim", name = "catppuccin" } - options: consolidated the three competing sources (vimrc, init.lua, custom/options.lua) into custom/options.lua alone; hlsearch/wrap were silently landing opposite to what init.lua's own comments said, purely from require-order. custom/options.lua now loads first in the require chain since colorizer.lua and others need termguicolors set before their own setup() runs - removed duplicate keymaps that were dead on arrival due to load order (rn, sf/sg/sh, jj, y, mapleader x3, manual C-h/j/k/l vs vim-tmux-navigator) - removed dead code: smart_format, root_dir/fallback_root_dir, toggleterm's unused _LAZYGIT_TOGGLE/_NODE_TOGGLE/_PYTHON_TOGGLE globals, unused local cmp, stale commented blocks, lua/custom/startup.lua - removed unused plugins: mini.icons, telescope-dap.nvim, startup-nvim/startup.nvim (malformed spec, never actually required), plus leftover ALE globals with no ALE plugin installed - vim.loop.* -> vim.uv.*, vim.diagnostic.goto_prev/next -> vim.diagnostic.jump({count=...}) for 0.12.5 - guard vim.treesitter.start() at the top of init.lua: the system's bundled Lua highlight query is currently ahead of the available tree-sitter-lua grammar (a packaging skew, confirmed nvim-treesitter is fully up to date), which was throwing on every Lua buffer and taking omnifunc/foldexpr down with it; now falls back to regex highlighting with a single notify instead Verified end-to-end against a real Neovim 0.12.5 headless instance with a fresh plugin install: no load errors, lspsaga's custom keys now actually apply, and the treesitter guard was confirmed against the real environment. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_013jVh2Lhn386JAvjSFCHUhn --- init.lua | 123 +++++++++++++----------------------- lua/custom/catppuccin.lua | 3 +- lua/custom/keymaps.lua | 8 --- lua/custom/kulala.lua | 9 --- lua/custom/lspconfig.lua | 34 +--------- lua/custom/none-ls.lua | 4 +- lua/custom/options.lua | 11 +++- lua/custom/plugins/init.lua | 28 ++++---- lua/custom/startup.lua | 10 --- lua/custom/telescope.lua | 3 - lua/custom/toggleterm.lua | 18 ------ lua/custom/vimrc | 26 -------- 12 files changed, 70 insertions(+), 207 deletions(-) delete mode 100644 lua/custom/startup.lua diff --git a/init.lua b/init.lua index 759b288..a1dd633 100644 --- a/init.lua +++ b/init.lua @@ -44,11 +44,31 @@ vim.cmd([[source ~/repos/nvim-kickstart/lua/custom/vimrc]]) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' +---------- treesitter.start guard >------------------------------ +-- Neovim's own bundled ftplugin/.lua calls vim.treesitter.start() +-- unconditionally. When the system's bundled highlight queries are ahead of +-- the currently available parser/grammar (a packaging/version skew, not a +-- config issue), that call throws and takes down the whole FileType autocmd +-- chain for the buffer (breaking omnifunc/foldexpr along with it). Guard it +-- here, before any buffer can trigger it, so a mismatch just falls back to +-- regex syntax highlighting instead of erroring. +do + local orig_start = vim.treesitter.start + vim.treesitter.start = function(...) + local ok, err = pcall(orig_start, ...) + if not ok then + vim.notify_once('treesitter.start failed, falling back to regex highlighting: ' .. tostring(err), + vim.log.levels.WARN) + end + end +end +---------- q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) - --- Setup neovim lua configuration --- require('neodev').setup() - -- [[ Configure nvim-cmp ]] -- See `:help cmp` -local cmp = require 'cmp' local luasnip = require 'luasnip' require('luasnip.loaders.from_vscode').lazy_load() luasnip.config.setup {} @@ -296,8 +260,10 @@ end -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +-- options.lua sets vim.opt.termguicolors, which colorizer.lua (and others) need +-- already set by the time they run their setup() calls, so it loads first +require('custom.options') require('custom.catppuccin') --- require('custom.startup') require('custom.lua-line') require('custom.telescope') require('custom.lspconfig') @@ -305,7 +271,6 @@ require('custom.nvim-cmp') require('custom.toggleterm') require('custom.autopairs') require('custom.colorizer') -require('custom.options') require('custom.keymaps') require('custom.harpoon') require('custom.mason') diff --git a/lua/custom/catppuccin.lua b/lua/custom/catppuccin.lua index 760961e..4d6df19 100644 --- a/lua/custom/catppuccin.lua +++ b/lua/custom/catppuccin.lua @@ -47,5 +47,4 @@ require("catppuccin").setup({ }, }) --- setup must be called before loading -vim.cmd.colorscheme "catppuccin" +-- colorscheme is applied in custom/colortheme.lua, loaded after this file diff --git a/lua/custom/keymaps.lua b/lua/custom/keymaps.lua index df13108..6a922e2 100644 --- a/lua/custom/keymaps.lua +++ b/lua/custom/keymaps.lua @@ -1,5 +1,3 @@ -vim.g.mapleader = ' ' - local keymap = vim.keymap keymap.set('i', 'jj', '') @@ -56,12 +54,6 @@ keymap.set('n', 'gh', ':DiffviewFileHistory %', { silent = true }) -- toggleterm keymap.set('n', '', 'ToggleTerm direction=horizontal', { silent = true }) --- vim-sneak --- keymap.set('n', 'f', 'Sneak_s', { silent = true }) --- keymap.set('n', 'F', 'Sneak_S', { silent = true }) --- keymap.set('n', 's', 's', { silent = true }) - - -- easymotion keymap.set('n', 'f', '(easymotion-prefix)', { silent = true }) keymap.set('n', 'fs', '(easymotion-sn)', { silent = true }) diff --git a/lua/custom/kulala.lua b/lua/custom/kulala.lua index 6309c24..49fc488 100644 --- a/lua/custom/kulala.lua +++ b/lua/custom/kulala.lua @@ -33,15 +33,6 @@ vim.filetype.add({ }) --- vim.api.nvim_set_keymap("n", "", ":lua require('kulala').jump_prev()", { noremap = true, silent = true }) --- vim.api.nvim_set_keymap("n", "", ":lua require('kulala').jump_next()", { noremap = true, silent = true }) --- vim.api.nvim_set_keymap("n", "", ":lua require('kulala').run()", { noremap = true, silent = true }) --- vim.api.nvim_set_keymap("n", "", ":lua require('kulala').toggle_view()", { noremap = true, silent = true }) --- vim.api.nvim_set_keymap("n", "", ":lua require('kulala').set_selected_env()", --- { noremap = true, silent = true }) - --- vim.api.nvim_set_keymap("n", "", ":lua require('kulala').jump_prev()", { noremap = true, silent = true }) --- vim.api.nvim_set_keymap("n", "", ":lua require('kulala').jump_next()", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "rr", ":lua require('kulala').run()", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "rv", ":lua require('kulala').toggle_view()", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "re", ":lua require('kulala').set_selected_env()", diff --git a/lua/custom/lspconfig.lua b/lua/custom/lspconfig.lua index e140889..5fe97c8 100644 --- a/lua/custom/lspconfig.lua +++ b/lua/custom/lspconfig.lua @@ -7,24 +7,6 @@ local keymap = vim.keymap -- for conciseness --- smart format with null-ls if available -local function smart_format() - vim.lsp.buf.format({ - filter = function(client) - local ft = vim.bo.filetype - if ft == "rust" then - return client.name == "rust_analyzer" - end - -- Prefer null-ls for all non-Rust, otherwise allow anything - if vim.tbl_contains({ "null-ls", "lua_ls", "jsonls", "tsserver" }, client.name) then - return true - end - return false - end, - timeout_ms = 3000, - }) -end - ---------- border >------------------------------ do local orig_floating_preview = vim.lsp.util.open_floating_preview @@ -55,11 +37,9 @@ local on_attach = function(_, bufnr) keymap.set("n", "g0", "lua vim.lsp.buf.document_symbol()", opts) keymap.set("n", "gd", "lua vim.lsp.buf.definition()", opts) keymap.set("n", "gi", "lua vim.lsp.buf.implementation()", opts) - -- keymap.set("n", "l", smart_format, opts) keymap.set("n", "l", function() vim.lsp.buf.format() end, { desc = "Format code function" }) - keymap.set("n", "rn", "lua vim.lsp.buf.rename()", opts) keymap.set( "n", "cbf", @@ -121,15 +101,6 @@ setup_server("rust_analyzer", { -- PHP LSPs -local util = vim.lsp.util -local root_dir = function(fname) - return util.root_pattern("composer.json", ".git")(fname) - or util.path.dirname(fname) -end - -local fallback_root_dir = function(fname) - return util.root_pattern("composer.json", ".git")(fname) or util.path.dirname(fname) -end -- start it manually :LspStart phpactor -- setup_server("phpactor", { @@ -186,13 +157,12 @@ setup_server("intelephense", { -- phpcs / phpstan configs vim.g.nvim_phpcs_config_phpcs_path = 'phpcs' vim.g.nvim_phpcs_config_phpcbf_path = 'phpcbf' -vim.g.ale_php_phpstan_executable = '~/.config/composer/vendor/bin/phpstan' local phpcs_config = "~/repos/configs/phpcs.xml" local phpcs_config_new = "~/repos/dotfiles/phpcs.xml" -if vim.loop.fs_stat(phpcs_config_new) then +if vim.uv.fs_stat(phpcs_config_new) then vim.g.nvim_phpcs_config_phpcs_standard = phpcs_config_new -elseif vim.loop.fs_stat(phpcs_config) then +elseif vim.uv.fs_stat(phpcs_config) then vim.g.nvim_phpcs_config_phpcs_standard = phpcs_config end diff --git a/lua/custom/none-ls.lua b/lua/custom/none-ls.lua index 55e71db..89d288f 100644 --- a/lua/custom/none-ls.lua +++ b/lua/custom/none-ls.lua @@ -8,7 +8,7 @@ local phpstan_global_config = vim.fn.expand("~/repos/dotfiles/php/phpstan-global -- local config itself (that also picks up its `includes:`, e.g. a baseline) local function phpstan_config_arg(root) for _, name in ipairs({ "phpstan.neon", "phpstan.neon.dist" }) do - if vim.loop.fs_stat(root .. "/" .. name) then + if vim.uv.fs_stat(root .. "/" .. name) then return nil end end @@ -47,7 +47,7 @@ null_ls.setup({ timeout = 60000, -- a cold run easily exceeds null-ls' 5s default condition = function(utils) return utils.root_has_file({ "phpstan.neon", "phpstan.neon.dist" }) - or vim.loop.fs_stat(phpstan_global_config) ~= nil + or vim.uv.fs_stat(phpstan_global_config) ~= nil end, }), null_ls.builtins.diagnostics.phpcs.with({ diff --git a/lua/custom/options.lua b/lua/custom/options.lua index b352c4d..0151de6 100644 --- a/lua/custom/options.lua +++ b/lua/custom/options.lua @@ -15,9 +15,10 @@ opt.expandtab = true opt.autoindent = true opt.wrap = false +opt.breakindent = true -- scroll offset -vim.opt.scrolloff = 8 +opt.scrolloff = 8 -- search settings opt.smartcase = true @@ -29,6 +30,9 @@ opt.termguicolors = true opt.background = 'dark' opt.signcolumn = 'yes' +-- mouse +opt.mouse = 'a' + -- clipboard opt.clipboard:append 'unnamedplus' @@ -37,3 +41,8 @@ opt.splitright = true opt.splitbelow = true opt.iskeyword:append '-' + +-- undo & responsiveness +opt.undofile = true +opt.updatetime = 250 +opt.timeoutlen = 300 diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 48ce489..a922d0a 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -22,29 +22,26 @@ return { -- vs-code like icons for autocompletion "onsails/lspkind.nvim", - "catppuccin/nvim", - as = "catppuccin", - { "startup-nvim/startup.nvim", dependencies = "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }, + { "catppuccin/nvim", name = "catppuccin" }, { 'nvimdev/lspsaga.nvim', config = function() - require('lspsaga').setup({}) + require('lspsaga').setup({ + -- use enter to open file from the finder + finder = { + keys = { toggle_or_open = "" }, + }, + -- use enter to open file with definition preview + definition = { + keys = { edit = "" }, + }, + }) end, dependencies = { 'nvim-treesitter/nvim-treesitter', -- optional 'nvim-tree/nvim-web-devicons', -- optional }, - - move_in_saga = { prev = "", next = "" }, - -- use enter to open file with finder - finder_action_keys = { - open = "", - }, - -- use enter to open file with definition preview - definition_action_keys = { - edit = "", - }, }, -- Debugger @@ -60,7 +57,6 @@ return { "theHamsta/nvim-dap-virtual-text", dependencies = "mfussenegger/nvim-dap", }, - "nvim-telescope/telescope-dap.nvim", -- autoclose parens, brackets, quotes, etc... "windwp/nvim-autopairs", @@ -102,8 +98,6 @@ return { } }, - { 'echasnovski/mini.icons', version = false }, - { -- HTTP REST-Client Interface 'mistweaverco/kulala.nvim', diff --git a/lua/custom/startup.lua b/lua/custom/startup.lua deleted file mode 100644 index 42398ed..0000000 --- a/lua/custom/startup.lua +++ /dev/null @@ -1,10 +0,0 @@ --- import comment plugin safely -local setup, startup = pcall(require, "startup") -if not setup then - return -end - --- enable startup -startup.setup({ - theme = "dashboard" -}) diff --git a/lua/custom/telescope.lua b/lua/custom/telescope.lua index 1d5dc2a..cf89b12 100644 --- a/lua/custom/telescope.lua +++ b/lua/custom/telescope.lua @@ -60,9 +60,6 @@ vim.keymap.set('n', '/', function() end, { desc = '[/] Fuzzily search in current buffer' }) vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) diff --git a/lua/custom/toggleterm.lua b/lua/custom/toggleterm.lua index 593db59..90f9c95 100644 --- a/lua/custom/toggleterm.lua +++ b/lua/custom/toggleterm.lua @@ -43,21 +43,3 @@ end -- if you only want these mappings for toggle term use term://*toggleterm#* instead vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') -local Terminal = require("toggleterm.terminal").Terminal -local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) - -function _LAZYGIT_TOGGLE() - lazygit:toggle() -end - -local node = Terminal:new({ cmd = "node", hidden = true }) - -function _NODE_TOGGLE() - node:toggle() -end - -local python = Terminal:new({ cmd = "python3", hidden = true }) - -function _PYTHON_TOGGLE() - python:toggle() -end diff --git a/lua/custom/vimrc b/lua/custom/vimrc index f094c85..3dea922 100644 --- a/lua/custom/vimrc +++ b/lua/custom/vimrc @@ -1,26 +1,6 @@ -set number -set hlsearch -set incsearch -set smartcase -set ignorecase -set wrap -set linebreak -set smartindent -set tabstop=4 -set shiftwidth=4 -set expandtab -set splitright splitbelow -set timeoutlen=1000 -set number -set relativenumber -set scrolloff=10 - syntax on filetype indent on -set smartindent -let mapleader = " " -imap jj imap nnoremap ΓΌ "+p @@ -41,7 +21,6 @@ nnoremap a ggVG nnoremap ,b :buffers " nnoremap t :Explorer " use leader e instead -nnoremap y "+yy vnoremap y "+y ":nnoremap s :%s/\<\>/ @@ -51,11 +30,6 @@ vnoremap y "+y vnoremap "hy:%s/h//gc let g:python3_host_prog="/usr/bin/python3" -nnoremap -nnoremap -nnoremap -nnoremap - " nnoremap zz " nnoremap zz