diff --git a/configuration.nix b/configuration.nix index 567ceff..c562e89 100644 --- a/configuration.nix +++ b/configuration.nix @@ -131,6 +131,7 @@ unzip chawan # tui browser cha git + gcc gdb glibc.static nixfmt @@ -166,6 +167,7 @@ bottles # windows emulation + element-desktop # element 4 matrix ]; # There have been amdgpu issues in 6.10 so you maybe need to revert on the default lts kernel. diff --git a/flake.lock b/flake.lock index 630246d..5b55eaf 100644 --- a/flake.lock +++ b/flake.lock @@ -1,42 +1,5 @@ { "nodes": { - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1751685974, - "narHash": "sha256-NKw96t+BgHIYzHUjkTK95FqYRVKB8DHpVhefWSz/kTw=", - "ref": "refs/heads/main", - "rev": "549f2762aebeff29a2e5ece7a7dc0f955281a1d1", - "revCount": 92, - "type": "git", - "url": "https://git.lix.systems/lix-project/flake-compat.git" - }, - "original": { - "type": "git", - "url": "https://git.lix.systems/lix-project/flake-compat.git" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "nvf", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1768135262, - "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -57,43 +20,6 @@ "type": "github" } }, - "mnw": { - "locked": { - "lastModified": 1769981889, - "narHash": "sha256-ndI7AxL/6auelkLHngdUGVImBiHkG8w2N2fOTKZKn4k=", - "owner": "Gerg-L", - "repo": "mnw", - "rev": "332fed8f43b77149c582f1782683d6aeee1f07cf", - "type": "github" - }, - "original": { - "owner": "Gerg-L", - "repo": "mnw", - "type": "github" - } - }, - "ndg": { - "inputs": { - "nixpkgs": [ - "nvf", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1768214250, - "narHash": "sha256-hnBZDQWUxJV3KbtvyGW5BKLO/fAwydrxm5WHCWMQTbw=", - "owner": "feel-co", - "repo": "ndg", - "rev": "a6bd3c1ce2668d096e4fdaaa03ad7f03ba1fbca8", - "type": "github" - }, - "original": { - "owner": "feel-co", - "ref": "refs/tags/v2.6.0", - "repo": "ndg", - "type": "github" - } - }, "nix-flatpak": { "locked": { "lastModified": 1767983141, @@ -110,6 +36,21 @@ "type": "github" } }, + "nixcats": { + "locked": { + "lastModified": 1770584904, + "narHash": "sha256-9Zaz8lbKF2W9pwXZEnbiGsicHdBoU+dHt3Wv3mCJoZ8=", + "owner": "BirdeeHub", + "repo": "nixCats-nvim", + "rev": "538fdde784d2909700d97a8ef307783b33a86fb1", + "type": "github" + }, + "original": { + "owner": "BirdeeHub", + "repo": "nixCats-nvim", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1770197578, @@ -126,45 +67,6 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1769461804, - "narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "bfc1b8a4574108ceef22f02bafcf6611380c100d", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nvf": { - "inputs": { - "flake-compat": "flake-compat", - "flake-parts": "flake-parts", - "mnw": "mnw", - "ndg": "ndg", - "nixpkgs": "nixpkgs_2", - "systems": "systems" - }, - "locked": { - "lastModified": 1770490142, - "narHash": "sha256-EhoRszCPTjGRp5kcRqluPNrS2fzL+Rj4HMSFvX4vNqs=", - "owner": "notashelf", - "repo": "nvf", - "rev": "074fcde9b433224db5056d28b3bf596c1332642f", - "type": "github" - }, - "original": { - "owner": "notashelf", - "repo": "nvf", - "type": "github" - } - }, "plasma-manager": { "inputs": { "home-manager": [ @@ -192,25 +94,10 @@ "inputs": { "home-manager": "home-manager", "nix-flatpak": "nix-flatpak", + "nixcats": "nixcats", "nixpkgs": "nixpkgs", - "nvf": "nvf", "plasma-manager": "plasma-manager" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index f40f212..777edc9 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,8 @@ home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest"; - nvf.url = "github:notashelf/nvf"; + # nvf.url = "github:notashelf/nvf"; + nixcats.url = "github:BirdeeHub/nixCats-nvim"; plasma-manager = { url = "github:nix-community/plasma-manager"; @@ -16,9 +17,8 @@ }; outputs = - inputs@{ self, nixpkgs, ... }: + inputs@{ self, nixpkgs, nixcats, ... }: let - system = "x86_64-linux"; lib = nixpkgs.lib; commonModules = [ diff --git a/home.nix b/home.nix index 6056a89..6ddf3f4 100644 --- a/home.nix +++ b/home.nix @@ -5,7 +5,6 @@ ... }: - { # Enables nix commands + flakes nix = { @@ -36,13 +35,27 @@ ]; nixpkgs.config.allowUnfree = true; - nixpkgs.overlays = [ (import ./exprs/overlay.nix { }) ]; + nixpkgs.overlays = [ + (import ./exprs/overlay.nix { }) + (self: super: { + element-desktop = super.element-desktop.overrideAttrs ( + final: prev: { + desktopItems = [ + ((builtins.elemAt prev.desktopItems 0).override { + exec = "element-desktop %u --password-store=\"gnome-libsecret\""; + }) + ]; + } + ); + }) + ]; imports = [ ./homemanager/mpv.nix - ./homemanager/nvf.nix + # ./homemanager/nvf.nix ./hosts/sandalphon/mcsr/home.nix + ./homemanager/vim/nixcats.nix inputs.plasma-manager.homeModules.plasma-manager - inputs.nvf.homeManagerModules.default + # inputs.nvf.homeManagerModules.default ]; # dconf.settings = {}; @@ -59,7 +72,8 @@ # settings = { # add_newline = true; - # format = "$directory\n$character"; + # format = ''$directory\n + # $character''; # directory = { # truncation_length = 3; @@ -80,4 +94,4 @@ }; programs.home-manager.enable = true; -} \ No newline at end of file +} diff --git a/homemanager/vim/init.lua b/homemanager/vim/init.lua new file mode 100644 index 0000000..4a626ea --- /dev/null +++ b/homemanager/vim/init.lua @@ -0,0 +1,11 @@ +vim.g.mapleader = " " + +vim.opt.termguicolors = true -- use terminal colors +vim.opt.relativenumber = true +vim.opt.number = true +vim.opt.wrap = true +-- vim.opt.colorcolumn = "80" +vim.cmd.colorscheme("candyland") + +require("plugins") +require("lsp") diff --git a/homemanager/vim/lua/lsp/capabilities.lua b/homemanager/vim/lua/lsp/capabilities.lua new file mode 100644 index 0000000..9256965 --- /dev/null +++ b/homemanager/vim/lua/lsp/capabilities.lua @@ -0,0 +1,59 @@ +local M = {} + +function M.on_attach(_, bufnr) + -- we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + + -- NOTE: why are these functions that call the telescope builtin? + -- because otherwise they would load telescope eagerly when this is defined. + -- due to us using the on_require handler to make sure it is available. + if nixCats('general.telescope') then + nmap('gr', function() require('telescope.builtin').lsp_references() end, '[G]oto [R]eferences') + nmap('gI', function() require('telescope.builtin').lsp_implementations() end, '[G]oto [I]mplementation') + nmap('ds', function() require('telescope.builtin').lsp_document_symbols() end, '[D]ocument [S]ymbols') + nmap('ws', function() require('telescope.builtin').lsp_dynamic_workspace_symbols() end, '[W]orkspace [S]ymbols') + nmap('dd', "Telescope diagnostics bufnr=0", '[D]ocument [D]iagnostics') + nmap('wd', "Telescope diagnostics", '[W]orkspace [D]iagnostics') + end -- TODO: someone who knows the builtin versions of these to do instead help me out please. + + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('e', vim.diagnostic.open_float, 'Show [E]rror') + + -- See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, { desc = 'Format current buffer with LSP' }) + +end + +function M.get(server_name) + local capabilities = require('blink.cmp').get_lsp_capabilities() + + return capabilities +end +return M diff --git a/homemanager/vim/lua/lsp/completion.lua b/homemanager/vim/lua/lsp/completion.lua new file mode 100644 index 0000000..cdbc9db --- /dev/null +++ b/homemanager/vim/lua/lsp/completion.lua @@ -0,0 +1,88 @@ +return { + { + "friendly-snippets", + dep_of = { "blink.cmp" }, + }, + { + "blink.cmp", + event = { "InsertEnter", "CmdlineEnter" }, + on_require = "blink", + load = function (name) + vim.cmd.packadd(name) + end, + after = function(plugin) + local blink = require('blink.cmp') + + blink.setup({ + keymap = { + preset = 'default', + }, + + appearance = { + nerd_font_variant = 'mono', + }, + + sources = { + default = { 'lsp', 'path', 'snippets', 'buffer' }, + providers = { + lsp = { + name = 'LSP', + module = 'blink.cmp.sources.lsp', + enabled = true, + }, + path = { + name = 'Path', + module = 'blink.cmp.sources.path', + enabled = true, + }, + snippets = { + name = 'Snippets', + module = 'blink.cmp.sources.snippets', + enabled = true, + }, + buffer = { + name = 'Buffer', + module = 'blink.cmp.sources.buffer', + enabled = true, + }, + }, + }, + + completion = { + accept = { + auto_brackets = { + enabled = true, + }, + }, + + menu = { + border = 'rounded', + max_height = 12, + scrolloff = 2, + + draw = { + columns = { + { "kind_icon", gap = 1, }, + { "label", "label_description", gap = 1, }, + }, + }, + }, + + documentation = { + auto_show = false, + window = { + border = 'rounded', + }, + }, + }, + + signature = { + enabled = true, + window = { + border = 'rounded', + }, + }, + }) + end + }, +} diff --git a/homemanager/vim/lua/lsp/indentation.lua b/homemanager/vim/lua/lsp/indentation.lua new file mode 100644 index 0000000..df7c2a8 --- /dev/null +++ b/homemanager/vim/lua/lsp/indentation.lua @@ -0,0 +1,17 @@ +vim.api.nvim_create_autocmd("FileType", { + pattern = "lua", + callback = function() + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + vim.opt_local.expandtab = true + end, +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = "nix", + callback = function() + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + vim.opt_local.expandtab = true + end, +}) diff --git a/homemanager/vim/lua/lsp/init.lua b/homemanager/vim/lua/lsp/init.lua new file mode 100644 index 0000000..1fae8a8 --- /dev/null +++ b/homemanager/vim/lua/lsp/init.lua @@ -0,0 +1,5 @@ +require("lze").load { + { import = "lsp.completion", }, +} + +require("lsp.lsp") diff --git a/homemanager/vim/lua/lsp/lsp.lua b/homemanager/vim/lua/lsp/lsp.lua new file mode 100644 index 0000000..85615f3 --- /dev/null +++ b/homemanager/vim/lua/lsp/lsp.lua @@ -0,0 +1,97 @@ +local servers = {} + +servers.lua_ls = { + settings = { + Lua = { + formatters = { + ignoreComments = false, + }, + signatureHelp = { enable = true }, + diagnostics = { + globals = { 'nixCats', 'vim' }, + -- disable = { 'missing-fields' }, + }, + workspace = { + -- make the server aware of the neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + }, + telemetry = { enabled = false }, + }, +} + +servers.nil_ls = { + settings = {}, +} + +local rust_analyzer_cmd = os.getenv("RUST_ANALYZER_CMD") +servers.rust_analyzer = { + cmd = { rust_analyzer_cmd }, + settings = { + server = { + -- For debugging rust-analyzer, to see log location do :LspInfo in neovim + -- extraEnv = { {["RA_LOG"]="project_model=debug"} }, + }, + cargo = { + allFeatures = false, + allTargets = false, + buildScripts = { enable = true }, + target = "x86_64-unknown-linux-gnu", + }, + diagnostics = { + enable = true, + }, + }, +} + +servers.hls = { + settings = {}, +} + + +-- Taken from nixCats example: +-- If you were to comment out this autocommand +-- and instead pass the on attach function directly to +-- nvim-lspconfig, it would do the same thing. +-- come to think of it, it might be better because then lspconfig doesnt have to be called before lsp attach? +-- but you would still end up triggering on a FileType event anyway, so, it makes little difference. +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('nixCats-lsp-attach', { clear = true }), + callback = function(event) + require('lsp.capabilities').on_attach(vim.lsp.get_client_by_id(event.data.client_id), event.buf) + end +}) + +require("lze").load { + { + "nvim-lspconfig", + event = "FileType", + after = function(plugin) + -- Just register configs, don't enable yet + for server_name, cfg in pairs(servers) do + vim.lsp.config(server_name, { + capabilities = require('lsp.capabilities').get(server_name), + settings = (cfg or {}).settings, + filetypes = (cfg or {}).filetypes, + cmd = (cfg or {}).cmd, + root_pattern = (cfg or {}).root_pattern, + }) + end + + -- Enable on-demand per filetype + for server_name, cfg in pairs(servers) do + local filetypes = cfg.filetypes or vim.lsp.config[server_name].filetypes + if filetypes then + vim.api.nvim_create_autocmd('FileType', { + pattern = filetypes, + callback = function() + vim.lsp.enable(server_name) + end, + }) + end + end + end, + }, +} + diff --git a/homemanager/vim/lua/plugins/dressing.lua b/homemanager/vim/lua/plugins/dressing.lua new file mode 100644 index 0000000..bca1775 --- /dev/null +++ b/homemanager/vim/lua/plugins/dressing.lua @@ -0,0 +1,5 @@ +return { + { + "dressing.nvim" + }, +} diff --git a/homemanager/vim/lua/plugins/fyler.lua b/homemanager/vim/lua/plugins/fyler.lua new file mode 100644 index 0000000..dd2bdab --- /dev/null +++ b/homemanager/vim/lua/plugins/fyler.lua @@ -0,0 +1,15 @@ +return { + { + "fyler.nvim", + cmd = { "Fyler" }, + keys = { + { "tf", function() return require('fyler').toggle({ kind = "split_right" }) end, mode = {"n"}, desc = 'Open [F]yler' }, + }, + load = function (name) + vim.cmd.packadd(name) + end, + after = function(plugin) + local fyler = require("fyler").setup() + end, + }, +} diff --git a/homemanager/vim/lua/plugins/init.lua b/homemanager/vim/lua/plugins/init.lua new file mode 100644 index 0000000..20c38db --- /dev/null +++ b/homemanager/vim/lua/plugins/init.lua @@ -0,0 +1,8 @@ +require("lze").load { + { import = "plugins.dressing", }, + { import = "plugins.telescope", }, + { import = "plugins.treesitter", }, + { import = "plugins.fyler", }, + { import = "plugins.mini-hipatterns", }, + --{ import = "plugins.neocord", }, +} diff --git a/homemanager/vim/lua/plugins/mini-hipatterns.lua b/homemanager/vim/lua/plugins/mini-hipatterns.lua new file mode 100644 index 0000000..a7c6c2a --- /dev/null +++ b/homemanager/vim/lua/plugins/mini-hipatterns.lua @@ -0,0 +1,76 @@ +return { + { + "mini.hipatterns", + after = function(plugin) + local hipatterns = require("mini.hipatterns") + + -- Returns hex color group for matching short hex color. + -- + ---@param match string + ---@return string + local hex_color_short = function(_, match) + local style = 'fg' -- 'fg' or 'bg', for extmark_opts_inline use 'fg' + local r, g, b = match:sub(2, 2), match:sub(3, 3), match:sub(4, 4) + local hex = string.format('#%s%s%s%s%s%s', r, r, g, g, b, b) + return hipatterns.compute_hex_color_group(hex, style) + end + + -- Returns hex color group for matching alpha hex color. + -- + ---@param match string + ---@return string + local hex_color_alpha = function(_, match) + local style = 'fg' -- 'fg' or 'bg', for extmark_opts_inline use 'fg' + local r, g, b = match:sub(2, 3), match:sub(4, 5), match:sub(6, 7) + local hex = string.format('#%s%s%s', r, g, b) + return hipatterns.compute_hex_color_group(hex, style) + end + + -- Returns extmark opts for highlights with virtual inline text. + -- + ---@param data table Includes `hl_group`, `full_match` and more. + ---@return table + local extmark_opts_inline = function(_, _, data) + return { + virt_text = { { '󰧞', data.hl_group } }, + virt_text_pos = 'inline', + right_gravity = false, + } + end + + -- Returns extmark opts for highlights with virtual inline text. + -- + ---@param data table Includes `hl_group`, `full_match` and more. + ---@return table + local extmark_opts_inline_alpha = function(_, _, data) + return { + virt_text = { { '󱡓', data.hl_group } }, + virt_text_pos = 'inline', + right_gravity = false, + } + end + + hipatterns.setup({ + highlighters = { + -- #rrggbb + hex_color = hipatterns.gen_highlighter.hex_color({ + style = "inline", + inline_text = '󰧞', + }), + -- #rgb + hex_color_short = { + pattern = "#%x%x%x%f[%X]", + group = hex_color_short, + extmark_opts = extmark_opts_inline, + }, + -- #rrggbbaa + hex_color_alpha = { + pattern = "#%x%x%x%x%x%x%x%x%f[%X]", + group = hex_color_alpha, + extmark_opts = extmark_opts_inline_alpha, + }, + }, + }) + end, + }, +} diff --git a/homemanager/vim/lua/plugins/neocord.lua b/homemanager/vim/lua/plugins/neocord.lua new file mode 100644 index 0000000..5efb242 --- /dev/null +++ b/homemanager/vim/lua/plugins/neocord.lua @@ -0,0 +1,5 @@ +return { + { + "neocord", + }, +} diff --git a/homemanager/vim/lua/plugins/telescope.lua b/homemanager/vim/lua/plugins/telescope.lua new file mode 100644 index 0000000..919f3bd --- /dev/null +++ b/homemanager/vim/lua/plugins/telescope.lua @@ -0,0 +1,36 @@ +return { + { + "telescope.nvim", + cmd = { "Telescope" }, + keys = { + { "f", function() return require('telescope.builtin').find_files() end, mode = {"n"}, desc = 'Telescope search [F]iles' }, + { "tr", function() return require('telescope.builtin').oldfiles() end, mode = {"n"}, desc = '[T]elescope search [R]ecent files' }, + { "ts", function() return require('telescope.builtin').live_grep() end, mode = {"n"}, desc = '[T]elescope [S]earch cwd with grep' }, + { "tw", function() return require('telescope.builtin').grep_string() end, mode = {"n"}, desc = '[T]elescope search current [W]ord' }, + { "tk", function() return require('telescope.builtin').keymaps() end, mode = {"n"}, desc = '[T]elescope search [K]eymaps' }, + { "tb", function() return require('telescope.builtin').buffers() end, mode = {"n"}, desc = '[T]elescope search [B]uffers' }, + }, + load = function (name) + vim.cmd.packadd(name) + vim.cmd.packadd("telescope-fzf-native.nvim") + end, + after = function(plugin) + local telescope = require("telescope") + local actions = require("telescope.actions") + + telescope.setup { + defaults = { + mappings = { + i = { + [""] = actions.move_selection_previous, -- move to prev result + [""] = actions.move_selection_next, -- move to next result + [""] = actions.send_selected_to_qflist + actions.open_qflist + } + } + } + } + + pcall(telescope.load_extension, "fzf") + end, + }, +} diff --git a/homemanager/vim/lua/plugins/treesitter.lua b/homemanager/vim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..489ecf9 --- /dev/null +++ b/homemanager/vim/lua/plugins/treesitter.lua @@ -0,0 +1,95 @@ +-- to help me write this after nvim-treesitter updated, i used: +-- https://github.com/BirdeeHub/nixCats-nvim/blob/3c9bc4d7123e1b48d92f25ba505b889af541e897/templates/example/lua/myLuaConf/plugins/treesitter.lua + +return { + { + "nvim-treesitter", + lazy = false, + after = function (plugin) + --@param buf integer + --@param language string + local function treesitter_try_attach(buf, language) + --check if parser exists and load it + if not vim.treesitter.language.add(language) then + return + end + + -- enables syntax highlight and other treesitter features + vim.treesitter.start(buf, language) + + -- enables treesitter based folds + vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + + -- enables treesiter based indentation + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + + local available_parsers = require("nvim-treesitter").get_available() + vim.api.nvim_create_autocmd("FileType", { + callback = function(args) + local buf, filetype = args.buf, args.match + local language = vim.treesitter.language.get_lang(filetype) + if not language then + return + end + + local installed_parsers = require("nvim-treesitter").get_installed("parsers") + + if vim.tbl_contains(installed_parsers, language) then + -- enable the parser if it is installed + treesitter_try_attach(buf, language) + elseif vim.tbl_contains(available_parsers, language) then + -- if a parser is available in `nvim-treesitter` enable it after ensuring it is installed + require("nvim-treesitter").install(language):await(function() + treesitter_try_attach(buf, language) + end) + else + -- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` + treesitter_try_attach(buf, language) + end + end, + }) + end, + }, + { + "nvim-treesitter-textobjects", + lazy = false, + before = function(plugin) + vim.g.no_plugin_maps = true + end, + after = function(plugin) + require("nvim-treesitter-textobjects").setup { + select = { + lookahead = true, + selection_modes = { + ['@parameter.outer'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + }, + include_surrounding_whitespace = false, + }, + } + + -- keymaps + vim.keymap.set({ "x", "o" }, "am", function() + require "nvim-treesitter-textobjects.select".select_textobject("@function.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "im", function() + require "nvim-treesitter-textobjects.select".select_textobject("@function.inner", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ac", function() + require "nvim-treesitter-textobjects.select".select_textobject("@class.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ic", function() + require "nvim-treesitter-textobjects.select".select_textobject("@class.inner", "textobjects") + end) + -- You can also use captures from other query groups like `locals.scm` + vim.keymap.set({ "x", "o" }, "as", function() + require "nvim-treesitter-textobjects.select".select_textobject("@local.scope", "locals") + end) + + -- NOTE: for more textobjects options, see the following link. + -- This template is using the new `main` branch of the repo. + -- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/tree/main + end, + }, +} diff --git a/homemanager/vim/nixcats.nix b/homemanager/vim/nixcats.nix new file mode 100644 index 0000000..752cab9 --- /dev/null +++ b/homemanager/vim/nixcats.nix @@ -0,0 +1,202 @@ +{ + config, + lib, + inputs, + pkgs, + ... +}: + +let + utils = inputs.nixcats.utils; +in +{ + imports = [ + inputs.nixcats.homeModule + ]; + + config = { + # this value, nixCats is the defaultPackageName you pass to mkNixosModules + # it will be the namespace for your options. + nixCats = { + enable = true; + nixpkgs_version = inputs.nixpkgs; + # this will add the overlays from ./overlays and also, + # add any plugins in inputs named "plugins-pluginName" to pkgs.neovimPlugins + # It will not apply to overall system, just nixCats. + addOverlays = # (import ./overlays inputs) ++ + [ + (utils.standardPluginOverlay inputs) + ]; + # see the packageDefinitions below. + # This says which of those to install. + packageNames = [ "deavim" ]; + + luaPath = "${./.}"; + + # the .replace vs .merge options are for modules based on existing configurations, + # they refer to how multiple categoryDefinitions get merged together by the module. + # for useage of this section, refer to :h nixCats.flake.outputs.categories + categoryDefinitions.replace = ( + { + pkgs, + settings, + categories, + extra, + name, + mkNvimPlugin, + ... + }@packageDef: + { + lspsAndRuntimeDeps = { + general = with pkgs; [ + ripgrep + fd + ]; + treesitter = with pkgs; [ + tree-sitter + ]; + lang = with pkgs; { + lua = [ + lua-language-server + ]; + nix = [ + nil + nix-doc + ]; + rust = with pkgs; [ + cargo + rust-analyzer + ]; + haskell = with pkgs; [ + haskell-language-server + ormolu + ]; + }; + }; + + startupPlugins = { + general = with pkgs.vimPlugins; [ + lze + plenary-nvim + nvim-notify + nvim-web-devicons + base16-nvim + mini-nvim + + (pkgs.vimUtils.buildVimPlugin { + pname = "candyland-nvim"; + version = "1.0"; + src = pkgs.fetchFromGitHub { + owner = "AmberLehmann"; + repo = "candyland.nvim"; + rev = "neovim-colorscheme"; + hash = "sha256-KEHMnpyJOhdF8ZPWuKF3uP7UX5fnzE31LMe+XxHK+i8="; + }; + }) + ]; + treesitter = with pkgs.vimPlugins; [ + nvim-treesitter-textobjects + nvim-treesitter.withAllGrammars + ]; + }; + optionalPlugins = { + general = with pkgs.vimPlugins; [ + ]; + ui = with pkgs.vimPlugins; [ + dressing-nvim + ]; + qol = with pkgs.vimPlugins; [ + undotree + mini-hipatterns + ]; + telescope = with pkgs.vimPlugins; [ + telescope-nvim + telescope-fzf-native-nvim + telescope-ui-select-nvim + ]; + fyler = with pkgs.vimPlugins; [ + fyler-nvim + ]; + lsp = with pkgs.vimPlugins; [ + nvim-lspconfig + ]; + completion = with pkgs.vimPlugins; [ + blink-cmp + nvim-cmp + luasnip + friendly-snippets + cmp_luasnip + cmp-buffer + cmp-path + cmp-nvim-lua + cmp-nvim-lsp + cmp-cmdline + cmp-nvim-lsp-signature-help + cmp-cmdline-history + lspkind-nvim + ]; + lang = with pkgs.vimPlugins; { + }; + }; + + # shared libraries to be added to LD_LIBRARY_PATH + # variable available to nvim runtime + sharedLibraries = { + general = with pkgs; [ + # libgit2 + ]; + }; + environmentVariables = { + lang = { + rust = { + # it literally won't see the rust-analyzer provided to it + # if you don't use an envrionment variable to tell it + RUST_ANALYZER_CMD = "${pkgs.rust-analyzer}/bin/rust-analyzer"; + }; + }; + }; + } + ); + + # see :help nixCats.flake.outputs.packageDefinitions + packageDefinitions.replace = { + # these are the names of your packages + # you can include as many as you wish. + deavim = + { pkgs, ... }: + { + # they contain a settings set defined above + # see :help nixCats.flake.outputs.settings + settings = { + wrapRc = true; + # IMPORTANT: + # your alias may not conflict with your other packages. + aliases = [ + "dvim" + ]; + }; + # and a set of categories that you want + # (and other information to pass to lua) + categories = { + general = true; + + ui = true; + qol = true; + telescope = true; + fyler = true; + lsp = true; + completion = true; + treesitter = true; + + lang = { + lua = true; + nix = true; + rust = true; + haskell = true; + }; + }; + }; + }; + }; + }; +} diff --git a/homemanager/nvf.nix b/homemanager/vim/nvf.nix similarity index 65% rename from homemanager/nvf.nix rename to homemanager/vim/nvf.nix index ec53c52..d32510e 100644 --- a/homemanager/nvf.nix +++ b/homemanager/vim/nvf.nix @@ -22,12 +22,19 @@ in vim.viAlias = false; vim = { vimAlias = true; - lsp.enable = true; - extraPlugins.candyland-nvim = { + lsp.enable = true; + extraPlugins.candyland-nvim = { package = candyland-nvim; - setup = "vim.cmd([[colorscheme candyland]])"; - }; - theme.enable = false; + setup = "vim.cmd([[colorscheme candyland]])"; + }; + notes = { + orgmode = { + enable = true; + treesitter.enable = true; + }; + todo-comments.enable = true; + }; + theme.enable = false; }; }; }; diff --git a/hosts/sandalphon/configuration.nix b/hosts/sandalphon/configuration.nix index 2ef3bdc..f21f661 100644 --- a/hosts/sandalphon/configuration.nix +++ b/hosts/sandalphon/configuration.nix @@ -40,8 +40,6 @@ in origin = "flathub"; } ]; - update.onActivation = true; - uninstallUnmanaged = true; }; environment.systemPackages = with pkgs; [