From fb5f5d3b884267fd0a5694065488bca07725448e Mon Sep 17 00:00:00 2001 From: ph1losof Date: Sun, 2 Nov 2025 12:24:57 +0100 Subject: [PATCH 1/2] experimental updates --- lua/config/autocmds.lua | 8 +-- lua/config/lazy.lua | 8 ++- lua/config/mappings.lua | 2 +- lua/helpers.lua | 9 ++- lua/plugins/comments.lua | 9 ++- lua/plugins/ecolog.lua | 140 +++++++++++++++++++------------------ lua/plugins/formatting.lua | 5 +- lua/plugins/lspconfig.lua | 17 ++--- lua/plugins/lspsaga.lua | 2 +- lua/plugins/lualine.lua | 2 +- lua/plugins/markdown.lua | 2 +- lua/plugins/morta.lua | 7 +- lua/plugins/oil.lua | 5 +- lua/plugins/surround.lua | 1 - lua/plugins/tailwind.lua | 2 +- lua/plugins/treesitter.lua | 1 - lua/plugins/typescript.lua | 8 +-- 17 files changed, 122 insertions(+), 106 deletions(-) diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 54cf210..2293150 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -91,15 +91,15 @@ vim.api.nvim_create_autocmd({ 'UIEnter', 'ColorScheme' }, { if not normal.bg then return end - io.write(string.format('\027Ptmux;\027\027]11;#%06x\007\027\\', normal.bg)) - io.write(string.format('\027]11;#%06x\027\\', normal.bg)) + pcall(io.write, string.format('\027Ptmux;\027\027]11;#%06x\007\027\\', normal.bg)) + pcall(io.write, string.format('\027]11;#%06x\027\\', normal.bg)) end, }) vim.api.nvim_create_autocmd('UILeave', { callback = function() - io.write '\027Ptmux;\027\027]111;\007\027\\' - io.write '\027]111\027\\' + pcall(io.write, '\027Ptmux;\027\027]111;\007\027\\') + pcall(io.write, '\027]111\027\\') end, }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 0f560df..1f20b81 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -1,6 +1,6 @@ local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.loop.fs_stat(lazypath) then - vim.fn.system { +if not vim.uv.fs_stat(lazypath) then + local output = vim.fn.system { 'git', 'clone', '--filter=blob:none', @@ -8,6 +8,10 @@ if not vim.loop.fs_stat(lazypath) then '--branch=stable', lazypath, } + if vim.v.shell_error ~= 0 then + vim.notify('Failed to clone lazy.nvim:\n' .. output, vim.log.levels.ERROR) + return + end end vim.opt.rtp:prepend(lazypath) diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua index f9b67f4..e2acc92 100644 --- a/lua/config/mappings.lua +++ b/lua/config/mappings.lua @@ -3,7 +3,7 @@ vim.keymap.set('n', '', 'nohlsearch') vim.keymap.set('n', 'nohlsearch') -- Diagnostic keymaps -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) +vim.keymap.set('n', 'd', vim.diagnostic.open_float, { desc = 'Show [D]iagnostic messages' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier diff --git a/lua/helpers.lua b/lua/helpers.lua index fbf4b2b..f7c647c 100644 --- a/lua/helpers.lua +++ b/lua/helpers.lua @@ -1,8 +1,13 @@ local M = {} ----LSPSaga helper to check for peek definition window +--- NOTE: This prevents issues like marksman LSP exiting when peek windows are created. + +--- Check if buffer is an LSPSaga peek definition window. +--- LSPSaga creates special markdown preview buffers for peeking definitions. +--- These buffers should not trigger LSP/linting as they are temporary non-editable previews. +--- See: https://github.com/nvimdev/lspsaga.nvim/issues/1352 ---@param bufnr number The buffer number to check. ----@return boolean true if the buffer should be linted, false otherwise. +---@return boolean true if buffer is an LSPSaga peek window, false otherwise. function M.is_lspsaga_peek_window(bufnr) local filetype = vim.bo[bufnr].filetype local buftype = vim.bo[bufnr].buftype diff --git a/lua/plugins/comments.lua b/lua/plugins/comments.lua index 01cadde..580bc02 100644 --- a/lua/plugins/comments.lua +++ b/lua/plugins/comments.lua @@ -20,7 +20,14 @@ return { { 'numToStr/Comment.nvim', dependencies = { 'JoosepAlviste/nvim-ts-context-commentstring' }, - lazy = false, + keys = { + { 'gcc', mode = 'n', desc = 'Comment toggle current line' }, + { 'gc', mode = { 'n', 'o' }, desc = 'Comment toggle linewise' }, + { 'gc', mode = 'x', desc = 'Comment toggle linewise (visual)' }, + { 'gbc', mode = 'n', desc = 'Comment toggle current block' }, + { 'gb', mode = { 'n', 'o' }, desc = 'Comment toggle blockwise' }, + { 'gb', mode = 'x', desc = 'Comment toggle blockwise (visual)' }, + }, config = function() require('Comment').setup { pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(), diff --git a/lua/plugins/ecolog.lua b/lua/plugins/ecolog.lua index be96d82..714f624 100644 --- a/lua/plugins/ecolog.lua +++ b/lua/plugins/ecolog.lua @@ -1,79 +1,83 @@ -return { - { - dir = '~/Projects/ecolog.nvim', - keys = { - { 'e', '', desc = '+ecolog', mode = { 'n', 'v' } }, - { 'el', 'EcologShelterLinePeek', desc = 'Peek line' }, - { 'ey', 'EcologCopy', desc = 'Copy value under cursor' }, - { 'ei', 'EcologInterpolationToggle', desc = 'Toggle interpolation' }, - { 'eh', 'EcologShellToggle', desc = 'Toggle shell variables' }, - { 'ge', 'EcologGoto', desc = 'Go to env file' }, - { 'ec', 'EcologSnacks', desc = 'Open a picker' }, - { 'eS', 'EcologSelect', desc = 'Switch env file' }, - { 'es', 'EcologShelterToggle', desc = 'Shelter toggle' }, +-- WARN: Check if local development directory exists, fallback to official repo. Can be removed, but required for my workflow +local local_ecolog = vim.fn.expand '~/Projects/ecolog.nvim' +local use_local = vim.uv.fs_stat(local_ecolog) ~= nil + +local ecolog_spec = { + [use_local and 'dir' or 'url'] = use_local and local_ecolog or 'https://github.com/ph1losof/ecolog.nvim', + keys = { + { 'e', '', desc = '+ecolog', mode = { 'n', 'v' } }, + { 'el', 'EcologShelterLinePeek', desc = 'Peek line' }, + { 'ey', 'EcologCopy', desc = 'Copy value under cursor' }, + { 'ei', 'EcologInterpolationToggle', desc = 'Toggle interpolation' }, + { 'eh', 'EcologShellToggle', desc = 'Toggle shell variables' }, + { 'ge', 'EcologGoto', desc = 'Go to env file' }, + { 'ec', 'EcologSnacks', desc = 'Open a picker' }, + { 'eS', 'EcologSelect', desc = 'Switch env file' }, + { 'es', 'EcologShelterToggle', desc = 'Shelter toggle' }, + }, + opts = { + preferred_environment = 'local', + types = true, + monorepo = { + enabled = true, + auto_switch = true, + notify_on_switch = false, }, - opts = { - preferred_environment = 'local', - types = true, - monorepo = { - enabled = true, - auto_switch = true, - notify_on_switch = false, + interpolation = { + enabled = true, + features = { + commands = false, }, - interpolation = { - enabled = true, - features = { - commands = false, - }, - }, - sort_var_fn = function(a, b) - if a.source == 'shell' and b.source ~= 'shell' then - return false - end - if a.source ~= 'shell' and b.source == 'shell' then - return true - end + }, + sort_var_fn = function(a, b) + if a.source == 'shell' and b.source ~= 'shell' then + return false + end + if a.source ~= 'shell' and b.source == 'shell' then + return true + end - return a.name < b.name - end, - integrations = { - lspsaga = true, - blink_cmp = true, - snacks = true, - statusline = { - hidden_mode = true, - icons = { enabled = true, env = 'E', shelter = 'S' }, - highlights = { - env_file = 'Directory', - vars_count = 'Number', - }, + return a.name < b.name + end, + integrations = { + lspsaga = true, + blink_cmp = true, + snacks = true, + statusline = { + hidden_mode = true, + icons = { enabled = true, env = 'E', shelter = 'S' }, + highlights = { + env_file = 'Directory', + vars_count = 'Number', }, }, - shelter = { - configuration = { - patterns = { - ['DATABASE_URL'] = 'full', - }, - sources = { - ['.env.example'] = 'none', - }, - skip_comments = false, - partial_mode = { - min_mask = 5, - show_start = 1, - show_end = 1, - }, - mask_char = '*', + }, + shelter = { + configuration = { + patterns = { + ['DATABASE_URL'] = 'full', + }, + sources = { + ['.env.example'] = 'none', }, - modules = { - files = true, - peek = false, - snacks_previewer = true, - snacks = false, - cmp = true, + skip_comments = false, + partial_mode = { + min_mask = 5, + show_start = 1, + show_end = 1, }, + mask_char = '*', + }, + modules = { + files = true, + peek = false, + snacks_previewer = true, + snacks = false, + cmp = true, }, - path = vim.fn.getcwd(), }, + path = vim.fn.getcwd(), }, } + +return { ecolog_spec } diff --git a/lua/plugins/formatting.lua b/lua/plugins/formatting.lua index a5d9dc0..b8a63ad 100644 --- a/lua/plugins/formatting.lua +++ b/lua/plugins/formatting.lua @@ -1,7 +1,8 @@ return { { 'stevearc/conform.nvim', - lazy = false, + event = 'BufWritePre', + cmd = 'ConformInfo', opts = { formatters_by_ft = { lua = { 'stylua' }, @@ -33,7 +34,7 @@ return { end, default_format_opts = { timeout_ms = 3000, - async = false, + async = true, quiet = false, lsp_format = 'fallback', }, diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 90de85e..7abe9ff 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -53,15 +53,6 @@ return { config = function() local helpers = require 'helpers' - vim.diagnostic.config { - virtual_text = true, - signs = true, - underline = true, - update_in_insert = false, - severity_sort = true, - } - vim.o.winborder = 'rounded' - vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('lsp-attach', { clear = true }), callback = function(event) @@ -91,12 +82,16 @@ return { end, }) + -- NOTE: Disables bashls for .env files vim.api.nvim_create_autocmd('FileType', { pattern = { 'sh', 'bash' }, callback = function(args) local file_name = vim.fn.expand '%:t' if string.match(file_name, '^%.env') then - vim.lsp.stop_client(vim.lsp.get_clients { bufnr = args.buf, name = 'bashls' }) + local clients = vim.lsp.get_clients { bufnr = args.buf, name = 'bashls' } + if clients and #clients > 0 then + pcall(vim.lsp.stop_client, clients) + end end end, }) @@ -133,7 +128,7 @@ return { end, }, marksman = { - -- This solves the problem of Marksman exiting when a new hover doc buffer (from Lspsaga) is created credits to FlawlessCasual17 + -- NOTE: This solves the problem of Marksman exiting when a new hover doc buffer (from Lspsaga) is created credits to FlawlessCasual17 ---@param bufnr number autostart = function(bufnr) if helpers.is_lspsaga_peek_window(bufnr) then diff --git a/lua/plugins/lspsaga.lua b/lua/plugins/lspsaga.lua index 7268303..64ed628 100644 --- a/lua/plugins/lspsaga.lua +++ b/lua/plugins/lspsaga.lua @@ -6,7 +6,7 @@ return { { 'K', 'Lspsaga hover_doc', desc = 'Hover Doc' }, { 'gd', 'Lspsaga goto_definition', desc = 'Go to definition' }, { 'rn', 'Lspsaga rename', desc = 'Rename' }, - { 'gp', 'Lspsaga peek_definition', desc = 'Preview Definition' }, + { 'gp', 'Lspsaga peek_definition', desc = 'Preview Definition' }, { 'ca', 'Lspsaga code_action', desc = 'Code Action' }, { 'ol', 'Lspsaga outline', desc = 'Outline' }, }, diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index e568e5d..959713c 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -14,7 +14,7 @@ local oil_extension = { lualine_a = { function() local ok, oil = pcall(require, 'oil') - if ok then + if ok and oil and oil.get_current_dir then return vim.fn.fnamemodify(oil.get_current_dir(), ':~') else return '' diff --git a/lua/plugins/markdown.lua b/lua/plugins/markdown.lua index 99f97ac..1a020ab 100644 --- a/lua/plugins/markdown.lua +++ b/lua/plugins/markdown.lua @@ -19,9 +19,9 @@ return { keys = { { 'mp', - ft = 'markdown', 'MarkdownPreviewToggle', desc = 'Markdown Preview', + ft = 'markdown', }, }, init = function() diff --git a/lua/plugins/morta.lua b/lua/plugins/morta.lua index 50b287a..c48f44a 100644 --- a/lua/plugins/morta.lua +++ b/lua/plugins/morta.lua @@ -1,12 +1,15 @@ return { { - 't3ntxcl3s/morta.nvim', + 'ph1losof/morta.nvim', branch = '2.0', name = 'morta', priority = 1000, opts = {}, config = function() - vim.cmd.colorscheme 'morta' + local ok = pcall(vim.cmd.colorscheme, 'morta') + if not ok then + vim.notify('Failed to load morta colorscheme, using default', vim.log.levels.WARN) + end end, }, } diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index a69a5e8..eeb38ab 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -50,7 +50,10 @@ vim.api.nvim_create_autocmd('User', { pattern = 'OilActionsPost', callback = function(event) if event.data.actions.type == 'move' then - Snacks.rename.on_rename_file(event.data.actions.src_url, event.data.actions.dest_url) + local ok, snacks = pcall(require, 'snacks') + if ok and snacks and snacks.rename then + snacks.rename.on_rename_file(event.data.actions.src_url, event.data.actions.dest_url) + end end end, }) diff --git a/lua/plugins/surround.lua b/lua/plugins/surround.lua index 22ae355..c36ddfa 100644 --- a/lua/plugins/surround.lua +++ b/lua/plugins/surround.lua @@ -1,7 +1,6 @@ return { { 'kylechui/nvim-surround', - version = '*', -- Use for stability; omit to use `main` branch for the latest features event = 'VeryLazy', config = function() require('nvim-surround').setup {} diff --git a/lua/plugins/tailwind.lua b/lua/plugins/tailwind.lua index 4253dc8..b158ef4 100644 --- a/lua/plugins/tailwind.lua +++ b/lua/plugins/tailwind.lua @@ -5,7 +5,7 @@ return { build = ':UpdateRemotePlugins', dependencies = { 'nvim-treesitter/nvim-treesitter', - { 'neovim/nvim-lspconfig', version = 'v2.4.0' }, + 'neovim/nvim-lspconfig', }, opts = { document_color = { enabled = false }, diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 34c12cc..2f236b3 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -10,7 +10,6 @@ return { { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', - dependencies = { 'windwp/nvim-ts-autotag' }, opts = { incremental_selection = { enable = true, diff --git a/lua/plugins/typescript.lua b/lua/plugins/typescript.lua index c32248f..2139477 100644 --- a/lua/plugins/typescript.lua +++ b/lua/plugins/typescript.lua @@ -1,10 +1,10 @@ return { { 'pmizio/typescript-tools.nvim', - lazy = false, + ft = { 'typescript', 'typescriptreact', 'typescript.tsx', 'javascript', 'javascriptreact' }, dependencies = { 'nvim-lua/plenary.nvim', - { 'neovim/nvim-lspconfig', version = 'v2.4.0' }, + 'neovim/nvim-lspconfig', 'saghen/blink.cmp', }, opts = {}, @@ -14,12 +14,8 @@ return { { 'ami', 'TSToolsAddMissingImports', desc = 'Add Missing Imports' }, }, config = function() - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('blink.cmp').get_lsp_capabilities({}, false)) - local api = require 'typescript-tools.api' require('typescript-tools').setup { - capabilities = capabilities, handlers = { -- NOTE: eslint handles 6133, 1109, 6192, 6196 (unused vars, imports, declarations) ['textDocument/publishDiagnostics'] = api.filter_diagnostics { 80006, 6133, 1109, 6192, 6196 }, From a4400c983cc2c5f5ca9afa7b97080eaa608de1c2 Mon Sep 17 00:00:00 2001 From: ph1losof Date: Sun, 2 Nov 2025 15:03:25 +0100 Subject: [PATCH 2/2] fix --- lua/plugins/lspconfig.lua | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 7abe9ff..d8c7032 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -82,20 +82,6 @@ return { end, }) - -- NOTE: Disables bashls for .env files - vim.api.nvim_create_autocmd('FileType', { - pattern = { 'sh', 'bash' }, - callback = function(args) - local file_name = vim.fn.expand '%:t' - if string.match(file_name, '^%.env') then - local clients = vim.lsp.get_clients { bufnr = args.buf, name = 'bashls' } - if clients and #clients > 0 then - pcall(vim.lsp.stop_client, clients) - end - end - end, - }) - local util = require 'lspconfig/util' local capabilities = vim.lsp.protocol.make_client_capabilities() @@ -112,7 +98,16 @@ return { return root_pattern(fname) end, }, - bashls = {}, + bashls = { + handlers = { + ['textDocument/publishDiagnostics'] = function(err, res, ...) + local file_name = vim.fn.fnamemodify(vim.uri_to_fname(res.uri), ':t') + if string.match(file_name, '^%.env') == nil then + return on_publish_diagnostics(err, res, ...) + end + end, + }, + }, tailwindcss = { hovers = true, suggestions = true,