From 78fc3d5aea28e77f1ecd0bcd55c1b78ab6ef1164 Mon Sep 17 00:00:00 2001 From: Adam Poniatowski Date: Sat, 4 Jul 2026 14:26:18 +0200 Subject: [PATCH] some further fixes and modifications --- lua/core/keymaps/init.lua | 3 - lua/core/keymaps/plugins.lua | 15 +---- lua/plugins/coding.lua | 1 - lua/plugins/coding/elixir.lua | 38 ------------- lua/plugins/lsp/servers.lua | 24 ++++---- lua/plugins/lsp/setup.lua | 7 +-- lua/plugins/null-ls/setup.lua | 67 +++++++++++----------- lua/plugins/nvim-lspconfig.lua | 7 ++- lua/plugins/nvim-treesitter.lua | 99 ++++++++++++++++----------------- 9 files changed, 102 insertions(+), 159 deletions(-) delete mode 100644 lua/plugins/coding/elixir.lua diff --git a/lua/core/keymaps/init.lua b/lua/core/keymaps/init.lua index 06a117fd..773b0463 100644 --- a/lua/core/keymaps/init.lua +++ b/lua/core/keymaps/init.lua @@ -24,14 +24,12 @@ M.session_keymaps = plugins.session M.scratch_keymaps = plugins.scratch M.snacks_keymaps = plugins.snacks M.leap_keymaps = plugins.leap -M.elixir_keymaps = plugins.elixir M.mini_surround_keymaps = plugins.mini_surround -- Setup functions M.setup_gitsigns_keymaps = git.setup M.setup_dadbod_keymaps = plugins.setup_dadbod M.setup_session_keymaps = plugins.setup_session -M.setup_elixir_keymaps = plugins.setup_elixir M.setup_leap_keymaps = plugins.setup_leap -- Default on_attach for LSP (used by lsp/setup.lua) @@ -107,7 +105,6 @@ local function init_keymaps() plugins.setup_dadbod() plugins.setup_session() plugins.setup_leap() - plugins.setup_elixir() git.setup() -- Tab navigation diff --git a/lua/core/keymaps/plugins.lua b/lua/core/keymaps/plugins.lua index 800c2db4..278d1bf7 100644 --- a/lua/core/keymaps/plugins.lua +++ b/lua/core/keymaps/plugins.lua @@ -1,5 +1,5 @@ ---@diagnostic disable: undefined-global --- Plugin keymaps (dadbod, session, scratch, snacks, leap, elixir, mini-surround) +-- Plugin keymaps (dadbod, session, scratch, snacks, leap, mini-surround) local M = {} @@ -58,13 +58,6 @@ M.leap = { end, opts = { desc = 'Leap: Search across windows' } }, } --- Elixir keymaps -M.elixir = { - { mode = 'n', lhs = 'xt', rhs = function() require('elixir').run_test_file() end, opts = { desc = 'Elixir: Test file' } }, - { mode = 'n', lhs = 'xn', rhs = function() require('elixir').run_nearest_test() end, opts = { desc = 'Elixir: Test nearest' } }, - { mode = 'n', lhs = 'xm', rhs = function() vim.cmd('Telescope elixir mix') end, opts = { desc = 'Elixir: Mix tasks' } }, -} - -- Mini-surround keymaps (used by mini.surround config) M.mini_surround = { add = 'sa', @@ -111,10 +104,4 @@ function M.setup_leap() end end -function M.setup_elixir() - for _, mapping in ipairs(M.elixir) do - vim.keymap.set(mapping.mode, mapping.lhs, mapping.rhs, mapping.opts) - end -end - return M diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua index 1e0c8bb1..3b4e3809 100644 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -4,5 +4,4 @@ return { require('plugins.coding.zig'), require('plugins.coding.clangd'), require('plugins.coding.dap'), - require('plugins.coding.elixir'), } diff --git a/lua/plugins/coding/elixir.lua b/lua/plugins/coding/elixir.lua deleted file mode 100644 index 3b0651b6..00000000 --- a/lua/plugins/coding/elixir.lua +++ /dev/null @@ -1,38 +0,0 @@ -return { - { - 'elixir-tools/elixir-tools.nvim', - version = '*', - ft = { 'ex', 'exs', 'heex', 'eex', 'elixir' }, - dependencies = { - 'neovim/nvim-lspconfig', - 'nvim-lua/plenary.nvim', - }, - config = function() - local elixir = require('elixir') - - -- Configure elixir-tools with LSP disabled (handled by lspconfig) - elixir.setup({ - -- Disable the built-in LSP client to avoid conflicts - elixirls = { enable = false }, - - -- Enable non-LSP features - credo = { enable = true }, - projectionist = { enable = true }, - - -- Configure the test runner - test_runner = { - enabled = true, - runner = 'exunit', -- or 'exunit_individual' for individual test runs - }, - - -- Enable mix integration - mix = { - enabled = true, - format_on_save = false, -- Disabled to prevent file changed warnings - }, - }) - - -- Keymaps are now in core/keymaps.lua with lx prefix - end, - }, -} diff --git a/lua/plugins/lsp/servers.lua b/lua/plugins/lsp/servers.lua index 89327ed1..d498272d 100644 --- a/lua/plugins/lsp/servers.lua +++ b/lua/plugins/lsp/servers.lua @@ -8,6 +8,17 @@ local gopls_build_flags = go_flags ~= '' and { '-tags=' .. go_flags } or {} return { -- Python pyright = {}, + + -- Bash/Shell + bashls = { + filetypes = { 'sh', 'bash', 'zsh' }, + settings = { + bashIde = { + globPattern = '*@(.sh|.inc|.bash|.command)', + shellcheckPath = 'shellcheck', + }, + }, + }, -- Go gopls = { settings = { @@ -131,17 +142,4 @@ return { }, }, }, - - -- Elixir - elixirls = { - cmd = { 'elixir-ls' }, - settings = { - elixirLS = { - dialyzerEnabled = true, - fetchDeps = true, - enableTestLenses = true, - suggestSpecs = true, - } - } - } } diff --git a/lua/plugins/lsp/setup.lua b/lua/plugins/lsp/setup.lua index c5014867..40db6b09 100644 --- a/lua/plugins/lsp/setup.lua +++ b/lua/plugins/lsp/setup.lua @@ -63,11 +63,8 @@ function M.setup() M.default_on_attach = function(client, bufnr) require('core.keymaps').setup_lsp_keymaps(bufnr) - -- Only attach navic if: - -- 1. The client supports document symbols - -- 2. The client isn't elixirls (handled by elixir-tools.nvim) - if client.server_capabilities.documentSymbolProvider - and client.name ~= 'elixirls' then + -- Attach navic if client supports document symbols + if client.server_capabilities.documentSymbolProvider then local status_ok, _ = pcall(require, 'nvim-navic') if status_ok then require('nvim-navic').attach(client, bufnr) diff --git a/lua/plugins/null-ls/setup.lua b/lua/plugins/null-ls/setup.lua index 2159d2d3..fcc220ab 100644 --- a/lua/plugins/null-ls/setup.lua +++ b/lua/plugins/null-ls/setup.lua @@ -8,44 +8,45 @@ function M.setup() local formatting = null_ls.builtins.formatting local diagnostics = null_ls.builtins.diagnostics - null_ls.setup { + local sources = { + formatting.gofumpt.with({ extra_args = { "-extra" } }), + formatting.goimports.with({ args = { "-local", "", "-w", "$FILENAME" } }), + diagnostics.golangci_lint.with({ + diagnostics_format = '#{m}', + extra_args = { + '--fast', + '--max-issues-per-linter', '30', + '--max-same-issues', '4', + '--max-same-issues-per-linter', '0', + '--fix=false', + '--tests=false', + '--print-issued-lines=false', + '--timeout=10s', + '--out-format=json', + }, + method = null_ls.methods.DIAGNOSTICS_ON_SAVE, + timeout = 10000, + }), + formatting.prettier.with { + filetypes = { 'css', 'scss', 'html', 'markdown', 'yaml', 'yml' }, + extra_args = { + '--bracket-same-line', + '--trailing-comma', 'all', + '--tab-width', '2', + '--semi', + '--single-quote', + }, + }, + formatting.shfmt.with { extra_args = { '-i', '2', '-ci', '-bn' } }, + formatting.sqlfluff.with { extra_args = { '--dialect', 'tsql' } }, + } + null_ls.setup { root_dir = null_ls_utils.root_pattern('.null-ls-root', 'Makefile', '.git'), timeout = 10000, debounce = 250, update_in_insert = false, - sources = { - formatting.gofumpt.with({ extra_args = { "-extra" } }), - formatting.goimports.with({ args = { "-local", "", "-w", "$FILENAME" } }), - diagnostics.golangci_lint.with({ - diagnostics_format = '#{m}', - extra_args = { - '--fast', - '--max-issues-per-linter', '30', - '--max-same-issues', '4', - '--max-same-issues-per-linter', '0', - '--fix=false', - '--tests=false', - '--print-issued-lines=false', - '--timeout=10s', - '--out-format=json', - }, - method = null_ls.methods.DIAGNOSTICS_ON_SAVE, - timeout = 10000, - }), - formatting.prettier.with { - filetypes = { 'css', 'scss', 'html', 'markdown', 'yaml', 'yml' }, - extra_args = { - '--bracket-same-line', - '--trailing-comma', 'all', - '--tab-width', '2', - '--semi', - '--single-quote', - }, - }, - formatting.shfmt.with { extra_args = { '-i', '2', '-ci', '-bn' } }, - formatting.sqlfluff.with { extra_args = { '--dialect', 'tsql' } }, - }, + sources = sources, } end diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua index 88ae0cf2..8926b656 100644 --- a/lua/plugins/nvim-lspconfig.lua +++ b/lua/plugins/nvim-lspconfig.lua @@ -44,6 +44,7 @@ return { require('mason-tool-installer').setup { ensure_installed = { 'lua-language-server', + 'stylua', -- Lua formatter 'marksman', -- Go tools 'gopls', -- Go LSP @@ -64,8 +65,10 @@ return { 'debugpy', -- Python debugger -- SQL tools 'sqls', -- Advanced SQL LSP - -- Elixir - 'elixir-ls' -- Elixir LSP + -- Shell tools + 'bash-language-server', -- Bash LSP + 'shellcheck', -- Shell linter + 'shfmt', -- Shell formatter }, auto_update = true, run_on_start = true, diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua index 0a38e72d..0e7f0b0a 100644 --- a/lua/plugins/nvim-treesitter.lua +++ b/lua/plugins/nvim-treesitter.lua @@ -1,54 +1,53 @@ return { - -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, - build = function() - local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) - ts_update() - -- Install C++ parser explicitly to avoid tarball issues - vim.cmd('silent! TSInstall cpp') - end, - main = 'nvim-treesitter.configs', -- Sets main module to use for opts - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - opts = { - -- List of languages to ensure are installed - ensure_installed = { - 'bash', 'c', 'cpp', 'diff', 'html', 'lua', 'luadoc', - 'markdown', 'markdown_inline', 'python', 'rust', - 'javascript', 'typescript', 'json', 'yaml', 'query', - 'vim', 'vimdoc', 'comment', 'regex' - }, - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - -- Automatically install missing parsers when entering buffer - auto_install = true, - -- List of parsers to ignore installing (for "all") - ignore_install = { 'phpdoc' }, + { + 'nvim-treesitter/nvim-treesitter', + branch = 'main', + lazy = false, + build = ':TSUpdate', + config = function() + local parsers = { + 'bash', 'c', 'cpp', 'diff', 'html', 'lua', 'luadoc', + 'markdown', 'markdown_inline', 'python', 'rust', + 'javascript', 'typescript', 'tsx', 'json', 'yaml', 'query', + 'vim', 'vimdoc', 'comment', 'regex', 'go', 'gomod', 'gosum', + } - highlight = { - enable = true, - -- Additional filetypes to enable highlighting for - additional_vim_regex_highlighting = { 'ruby' }, - -- Disable for large files - disable = function(_, buf) - local max_filesize = 100 * 1024 -- 100 KB - local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) - if ok and stats and stats.size > max_filesize then - return true - end - end, - }, - indent = { - enable = true, - disable = { 'ruby', 'yaml' } - }, + local nts = require('nvim-treesitter') + local installed = nts.get_installed and nts.get_installed('parsers') or {} + local have = {} + for _, p in ipairs(installed) do have[p] = true end + local missing = {} + for _, p in ipairs(parsers) do + if not have[p] then table.insert(missing, p) end + end + if #missing > 0 then nts.install(missing) end + + local max_filesize = 100 * 1024 + vim.api.nvim_create_autocmd('FileType', { + callback = function(args) + local buf = args.buf + local lang = vim.treesitter.language.get_lang(vim.bo[buf].filetype) + if not lang then return end + local ok_p = pcall(vim.treesitter.language.add, lang) + if not ok_p then return end + + local fname = vim.api.nvim_buf_get_name(buf) + local ok, stats = pcall(vim.loop.fs_stat, fname) + if ok and stats and stats.size > max_filesize then return end + + pcall(vim.treesitter.start, buf, lang) + + if lang ~= 'yaml' then + vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + end, + }) + end, + }, + { + 'nvim-treesitter/nvim-treesitter-textobjects', + branch = 'main', + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + event = 'VeryLazy', }, - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects }