diff --git a/lazy-lock.json b/lazy-lock.json deleted file mode 100644 index f403e7c..0000000 --- a/lazy-lock.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "LuaSnip": { "branch": "master", "commit": "642b0c595e11608b4c18219e93b88d7637af27bc" }, - "autoclose.nvim": { "branch": "main", "commit": "bafd0368716216fa6a7bb2a43ecd889b44efdb46" }, - "base16-vim": { "branch": "master", "commit": "3be3cd82cd31acfcab9a41bad853d9c68d30478d" }, - "bitcoin-script-hints.nvim": { "branch": "main", "commit": "628badbb09a230e3838d863b21dcc07cdd2429bc" }, - "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "gitsigns.nvim": { "branch": "main", "commit": "6d808f99bd63303646794406e270bd553ad7792e" }, - "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, - "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "log-highlight.nvim": { "branch": "main", "commit": "ca88628f6dd3b9bb46f9a7401669e24cf7de47a4" }, - "lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "0c2823e0418f3d9230ff8b201c976e84de1cb401" }, - "mason.nvim": { "branch": "main", "commit": "cb8445f8ce85d957416c106b780efd51c6298f89" }, - "neo-tree.nvim": { "branch": "main", "commit": "19d20a99bf0061a5ecc4343d2f09fa713306c965" }, - "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, - "nvim-lspconfig": { "branch": "master", "commit": "f7e89f3d19fb436e1fbeff3bf4291eef35da94e3" }, - "nvim-navic": { "branch": "master", "commit": "f5eba192f39b453675d115351808bd51276d9de5" }, - "nvim-treesitter": { "branch": "main", "commit": "df7489eeea351bece7fd0f9c825be5cb6a1438f0" }, - "nvim-web-devicons": { "branch": "master", "commit": "4fc505ac7bd7692824a142e96e5f529c133862f8" }, - "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, - "treesitter-parser-registry": { "branch": "main", "commit": "6eb15358bb9fc88f0d3401d8538d56652e9bdf3c" }, - "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } -} diff --git a/lua/plugins/disabled.lua b/lua/plugins/disabled.lua index 0b7a483..64e75ec 100644 --- a/lua/plugins/disabled.lua +++ b/lua/plugins/disabled.lua @@ -1,3 +1,5 @@ return { + { "williamboman/mason.nvim", enabled = false }, + { "williamboman/mason-lspconfig.nvim", enabled = false }, { "jay-babu/mason-nvim-dap.nvim", enabled = false }, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 3372cff..c31339b 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,7 +1,11 @@ -- Neovim 0.11+ LSP configuration -- Uses nvim-lspconfig for server definitions + vim.lsp.enable() API --- Servers to ensure are installed via Mason. +-- Detect NixOS (Mason doesn't work on NixOS due to FHS issues) +local is_nixos = vim.fn.filereadable("/etc/NIXOS") == 1 + +-- Servers to ensure are installed via Mason (non-NixOS only) +-- On NixOS, install these via extraPackages or per-project devShells local mason_ensure_installed = { "lua_ls", -- Neovim config "nil_ls", -- Nix (nixd not available in Mason) @@ -14,43 +18,13 @@ local mason_ensure_installed = { "yamlls", -- YAML } -local treesitter_parsers = { - "lua", - "c", - "cpp", - "python", - "nix", - "rust", - "bash", - "markdown", - "html", - "html_tags", - "javascript", - "ecma", - "jsx", - "css", - "vim", - "git_config", - "git_rebase", - "gitattributes", - "gitcommit", - "gitignore", -} - return { { - "neovim-treesitter/nvim-treesitter", - name = "nvim-treesitter", - dependencies = { - "neovim-treesitter/treesitter-parser-registry", - "williamboman/mason.nvim", - }, - lazy = false, + "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", - init = function() - vim.api.nvim_create_autocmd("FileType", { - group = vim.api.nvim_create_augroup("config_treesitter", { clear = true }), - pattern = { + config = function() + require('nvim-treesitter.configs').setup({ + ensure_installed = { "lua", "c", "cpp", @@ -61,133 +35,22 @@ return { "markdown", "html", "javascript", - "javascriptreact", "css", + "vim", - "gitconfig", - "gitrebase", + + "git_config", + "git_rebase", "gitattributes", "gitcommit", - "gitignore", + "gitignore" }, - callback = function(event) - if pcall(vim.treesitter.start, event.buf) then - vim.bo[event.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" - end - end, + auto_install = true, + sync_install = true, + highlight = { + enable = true, + } }) - end, - config = function() - require("nvim-treesitter").setup() - - local function has_c_compiler() - return vim.fn.executable("cc") == 1 - or vim.fn.executable("gcc") == 1 - or vim.fn.executable("clang") == 1 - end - - local function install_missing_parsers(missing) - if not has_c_compiler() then - vim.notify_once( - "A C compiler is required to install or update Treesitter parsers", - vim.log.levels.WARN - ) - return - end - - require("nvim-treesitter").install(missing) - end - - local function tree_sitter_cli_works() - if vim.fn.executable("tree-sitter") == 0 then - return false - end - - local result = vim.system({ "tree-sitter", "--version" }, { text = true }):wait() - if result.code == 0 then - return true - end - - vim.notify_once( - "tree-sitter CLI is installed but cannot run. On NixOS, enable nix-ld so Mason-installed binaries can execute.", - vim.log.levels.WARN - ) - return false - end - - local function ensure_treesitter_cli(callback) - if tree_sitter_cli_works() then - callback() - return - end - - if #vim.api.nvim_list_uis() == 0 then - return - end - - local mason_ok, mason = pcall(require, "mason") - local registry_ok, registry = pcall(require, "mason-registry") - if not mason_ok or not registry_ok then - vim.notify_once( - "tree-sitter CLI is required to install or update parsers; install tree-sitter-cli or enable mason.nvim", - vim.log.levels.WARN - ) - return - end - - mason.setup() - registry.refresh(function() - local package_ok, package = pcall(registry.get_package, "tree-sitter-cli") - if not package_ok then - vim.notify_once( - "Mason registry does not include tree-sitter-cli; install tree-sitter-cli before running :TSUpdate", - vim.log.levels.WARN - ) - return - end - - if package:is_installed() then - if tree_sitter_cli_works() then - callback() - end - return - end - - if package:is_installing() then - vim.notify_once("tree-sitter-cli is already being installed by Mason", vim.log.levels.INFO) - return - end - - vim.notify_once("Installing tree-sitter-cli with Mason for Treesitter parser updates", vim.log.levels.INFO) - package:install({}, function(success, error) - if success and tree_sitter_cli_works() then - callback() - else - vim.notify( - "Failed to install tree-sitter-cli with Mason: " .. tostring(error), - vim.log.levels.WARN - ) - end - end) - end) - end - - local installed = require("nvim-treesitter.config").get_installed() - local missing = vim.iter(treesitter_parsers) - :filter(function(parser) - return not vim.tbl_contains(installed, parser) - end) - :totable() - - if #missing == 0 and #vim.api.nvim_list_uis() == 0 then - return - end - - ensure_treesitter_cli(function() - if #missing > 0 then - install_missing_parsers(missing) - end - end) end }, @@ -250,16 +113,17 @@ return { end }, - -- Mason: portable LSP installer. On NixOS this requires nix-ld for - -- downloaded Linux binaries to run. + -- Mason: portable LSP installer (disabled on NixOS where it doesn't work) { "williamboman/mason.nvim", + enabled = not is_nixos, config = function() require("mason").setup() end }, { "williamboman/mason-lspconfig.nvim", + enabled = not is_nixos, dependencies = { "williamboman/mason.nvim" }, config = function() require("mason-lspconfig").setup({ @@ -438,7 +302,7 @@ return { { "taproot-wizards/bitcoin-script-hints.nvim", - dependencies = { "nvim-treesitter" }, + dependencies = { "nvim-treesitter/nvim-treesitter" }, config = function() require("bitcoin-script-hints").setup() end