From fcc4de84ba60bab79f1f20cef8c4374b36ef1e60 Mon Sep 17 00:00:00 2001 From: uttarayan21 Date: Fri, 17 Jan 2025 14:03:48 +0530 Subject: [PATCH] feat: Expose neovim config as a package --- common/gui.nix | 9 +- common/home.nix | 3 +- flake.lock | 40 +- flake.nix | 15 + neovim/default.nix | 1422 ++++++++++++++++----------------- neovim/overlays.nix | 21 + nixos/mirai/configuration.nix | 3 +- nixos/ryu/configuration.nix | 1 + 8 files changed, 792 insertions(+), 722 deletions(-) diff --git a/common/gui.nix b/common/gui.nix index b4f15e5c..1aa469fd 100644 --- a/common/gui.nix +++ b/common/gui.nix @@ -20,6 +20,7 @@ lib.attrsets.optionalAttrs device.hasGui { WantedBy = ["graphical-session.target"]; }; }; + imports = [./kitty.nix]; programs = { # Only for checking markdown previews @@ -34,10 +35,10 @@ lib.attrsets.optionalAttrs device.hasGui { # ghostty = { # enable = true; # installBatSyntax = false; - # package = - # if pkgs.stdenv.isLinux - # then pkgs.ghostty - # else pkgs.hello; + # settings = { + # theme = "catppuccin-mocha"; + # }; + # package = pkgs.ghostty; # }; }; home.packages = with pkgs; diff --git a/common/home.nix b/common/home.nix index b9598b9e..decfc6b4 100644 --- a/common/home.nix +++ b/common/home.nix @@ -45,7 +45,7 @@ in { ./ncmpcpp.nix ./sops.nix ./tmux.nix - ../neovim + # ../neovim ] ++ lib.optionals device.isLinux [../linux] # ++ lib.optionals.device.isMac [../macos] @@ -54,6 +54,7 @@ in { home.packages = with pkgs; [ + (nixvim.makeNixvim (import ../neovim)) _1password-cli alejandra ast-grep diff --git a/flake.lock b/flake.lock index af2784c7..06064b2c 100644 --- a/flake.lock +++ b/flake.lock @@ -2263,6 +2263,8 @@ "tree-sitter-just": "tree-sitter-just", "tree-sitter-nu": "tree-sitter-nu", "tree-sitter-slint": "tree-sitter-slint", + "typr": "typr", + "volt": "volt", "zjstatus": "zjstatus" } }, @@ -2730,11 +2732,11 @@ "rust-overlay": "rust-overlay_8" }, "locked": { - "lastModified": 1735044950, - "narHash": "sha256-8Au07voKXOa70Cq874FIPLi4Cj+4GdLMketKFwwuaas=", + "lastModified": 1737007026, + "narHash": "sha256-j1EwjCV2ttZC2Sm7gGHqhtgGPpRAv2Z+C+rQIOtRYnw=", "owner": "uttarayan21", "repo": "tmux-float", - "rev": "11b2cf83ebe8478135483d9a165e828e33fee038", + "rev": "f3ae743b473d4767e31d61a209c378d88dfddd7d", "type": "github" }, "original": { @@ -2849,6 +2851,22 @@ "type": "github" } }, + "typr": { + "flake": false, + "locked": { + "lastModified": 1736915269, + "narHash": "sha256-iVLxQeQqpqohCPZAE3SxReEo3KmWAo+xGAiJJnRBbUE=", + "owner": "nvzone", + "repo": "typr", + "rev": "a60c7f237be94d4b39228a3bd2ced80fe9fe2781", + "type": "github" + }, + "original": { + "owner": "nvzone", + "repo": "typr", + "type": "github" + } + }, "utils": { "inputs": { "systems": "systems_5" @@ -2867,6 +2885,22 @@ "type": "github" } }, + "volt": { + "flake": false, + "locked": { + "lastModified": 1736777974, + "narHash": "sha256-2SO847Un74kNFGxARaebB+WCCgexnaJdjUkQLZ6ROQ8=", + "owner": "nvzone", + "repo": "volt", + "rev": "f02b065caf0327bf4d443ff6d91cb0edd6948ddb", + "type": "github" + }, + "original": { + "owner": "nvzone", + "repo": "volt", + "type": "github" + } + }, "xdph": { "inputs": { "hyprland-protocols": [ diff --git a/flake.nix b/flake.nix index 41cc0183..9134d5c0 100644 --- a/flake.nix +++ b/flake.nix @@ -146,6 +146,14 @@ ghostty = { url = "github:ghostty-org/ghostty"; }; + typr = { + url = "github:nvzone/typr"; + flake = false; + }; + volt = { + url = "github:nvzone/volt"; + flake = false; + }; }; outputs = { @@ -283,8 +291,15 @@ system: let pkgs = import nixpkgs { inherit system; + overlays = import ./overlays.nix { + inherit inputs; + }; }; in { + packages = rec { + default = neovim; + neovim = pkgs.nixvim.makeNixvim (import ./neovim); + }; devShells = { default = pkgs.mkShell { packages = with pkgs; [sops just]; diff --git a/neovim/default.nix b/neovim/default.nix index 56222b1b..e5ab2b24 100644 --- a/neovim/default.nix +++ b/neovim/default.nix @@ -1,6 +1,6 @@ { pkgs, - config, + # config, ... }: let mkMappings = mappings: @@ -24,368 +24,281 @@ ${lua} ''; }; - neovim = (pkgs.nixvim.makeNixvim nvim-config) // {config = nvim-config;}; - nvim-config = { - plugins = { - fugitive.enable = true; - gitsigns.enable = true; - neogit.enable = true; - web-devicons.enable = true; - vim-surround.enable = true; - todo-comments.enable = true; - trouble.enable = true; - ts-context-commentstring.enable = true; - which-key.enable = true; - conform-nvim = { - enable = true; - settings = { - format_on_save = - /* - lua - */ - '' - function(bufnr) - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - return { timeout_ms = 500, lsp_format = "fallback" } - end - ''; - formatters_by_ft = { - d2 = ["d2"]; - sql = ["sleek"]; - toml = ["taplo"]; - nix = ["alejandra"]; - }; - }; - }; - chatgpt = { - enable = true; - settings = { - api_key_cmd = "cat ${config.sops.secrets."openai/api_key".path}"; - }; - }; - - oil = { - enable = true; - settings.skip_confirm_for_simple_edits = true; - }; - yazi = { - enable = true; - settings = { - open_for_directories = true; - keymaps = { - show_help = ""; - open_file_in_vertical_split = ""; - open_file_in_horizontal_split = ""; - open_file_in_tab = ""; - grep_in_directory = ""; - replace_in_directory = ""; - cycle_open_buffers = ""; - copy_relative_path_to_selected_files = ""; - send_to_quickfix_list = ""; - change_working_directory = ""; - }; - }; - }; - - # navic = { - # enable = true; - # settings.lsp.auto_attach = true; - # }; - - mini = { - enable = true; - modules = { - ai = {}; - starter = {}; - }; - }; - - lualine = { - enable = true; - # settings.sections = { - # lualine_c = - # rawLua - # /* - # lua - # */ - # '' - # { - # function(bufnr) - # local opts = { highlight = true } - # return require'nvim-navic'.get_location(opts) - # end, - # cond = function() - # return require'nvim-navic'.is_available() - # end - # } - # ''; - # }; - }; - - neotest = { - enable = false; - settings = { - # adapters = [ - # ''require('rustaceanvim.neotest')'' - # ]; - }; - }; - neorg = { - enable = true; - settings.load = { - "core.defaults" = { - __empty = null; - }; - "core.completion" = { - config = { - engine = "nvim-cmp"; - name = "[Norg]"; - }; - }; - "core.concealer" = { - config = { - icon_preset = "diamond"; - }; - }; - "core.keybinds" = { - config = { - default_keybinds = true; - neorg_leader = ""; - }; - }; - "core.integrations.treesitter" = { - config.install_parsers = false; - config.configure_parsers = false; - }; - - "core.integrations.image" = { - config.tmux_show_only_in_active_window = true; - }; - - "core.dirman" = { - config = { - default_workspace = "Notes"; - workspaces = { - Notes = "~/Nextcloud/Notes"; - Work = "~/Nextcloud/Work"; - }; - }; - }; - }; - }; - - rest = { - enable = true; - enableTelescope = true; - settings.response.hooks.format = true; - }; - - comment = { - enable = true; - settings.pre_hook = +in { + plugins = { + fugitive.enable = true; + gitsigns.enable = true; + neogit.enable = true; + web-devicons.enable = true; + vim-surround.enable = true; + todo-comments.enable = true; + trouble.enable = true; + ts-context-commentstring.enable = true; + which-key.enable = true; + conform-nvim = { + enable = true; + settings = { + format_on_save = /* lua */ '' - require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook() + function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { timeout_ms = 500, lsp_format = "fallback" } + end + ''; + formatters_by_ft = { + d2 = ["d2"]; + sql = ["sleek"]; + toml = ["taplo"]; + nix = ["alejandra"]; + }; + }; + }; + chatgpt = { + enable = true; + settings = { + # api_key_cmd = "cat ${config.sops.secrets."openai/api_key".path}"; + }; + }; + + oil = { + enable = true; + settings.skip_confirm_for_simple_edits = true; + }; + yazi = { + enable = true; + settings = { + open_for_directories = true; + keymaps = { + show_help = ""; + open_file_in_vertical_split = ""; + open_file_in_horizontal_split = ""; + open_file_in_tab = ""; + grep_in_directory = ""; + replace_in_directory = ""; + cycle_open_buffers = ""; + copy_relative_path_to_selected_files = ""; + send_to_quickfix_list = ""; + change_working_directory = ""; + }; + }; + }; + + # navic = { + # enable = true; + # settings.lsp.auto_attach = true; + # }; + + mini = { + enable = true; + modules = { + ai = {}; + starter = {}; + }; + }; + + lualine = { + enable = true; + # settings.sections = { + # lualine_c = + # rawLua + # /* + # lua + # */ + # '' + # { + # function(bufnr) + # local opts = { highlight = true } + # return require'nvim-navic'.get_location(opts) + # end, + # cond = function() + # return require'nvim-navic'.is_available() + # end + # } + # ''; + # }; + }; + + neotest = { + enable = false; + settings = { + # adapters = [ + # ''require('rustaceanvim.neotest')'' + # ]; + }; + }; + neorg = { + enable = true; + settings.load = { + "core.defaults" = { + __empty = null; + }; + "core.completion" = { + config = { + engine = "nvim-cmp"; + name = "[Norg]"; + }; + }; + "core.concealer" = { + config = { + icon_preset = "diamond"; + }; + }; + "core.keybinds" = { + config = { + default_keybinds = true; + neorg_leader = ""; + }; + }; + "core.integrations.treesitter" = { + config.install_parsers = false; + config.configure_parsers = false; + }; + + "core.integrations.image" = { + config.tmux_show_only_in_active_window = true; + }; + + "core.dirman" = { + config = { + default_workspace = "Notes"; + workspaces = { + Notes = "~/Nextcloud/Notes"; + Work = "~/Nextcloud/Work"; + }; + }; + }; + }; + }; + + rest = { + enable = true; + enableTelescope = true; + settings.response.hooks.format = true; + }; + + comment = { + enable = true; + settings.pre_hook = + /* + lua + */ + '' + require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook() + ''; + }; + + molten = { + enable = true; + settings.image_provider = "image.nvim"; + }; + + markdown-preview = { + enable = true; + }; + + noice = { + enable = true; + settings = { + notify.enabled = false; + lsp.override = { + "vim.lsp.util.convert_input_to_markdown_lines" = true; + "vim.lsp.util.stylize_markdown" = true; + "cmp.entry.get_documentation" = true; + }; + presets = { + bottom_search = false; + command_palette = true; + long_message_to_split = true; + inc_rename = false; + lsp_doc_border = true; + }; + }; + }; + + treesitter = { + enable = true; + settings = { + indent.enable = true; + highlight = { + enable = true; + additional_vim_regex_highlighting = true; + }; + }; + folding = true; + grammarPackages = + (with pkgs.tree-sitter-grammars; [ + tree-sitter-norg + tree-sitter-norg-meta + tree-sitter-just + tree-sitter-nu + tree-sitter-d2 + ]) + ++ pkgs.vimPlugins.nvim-treesitter.allGrammars; + }; + + telescope = { + enable = true; + settings = { + defaults = { + layout_strategy = "horizontal"; + layout_config = { + # preview_height = 0.8; + vertical = { + size = { + width = "99%"; + height = "99%"; + }; + }; + }; + }; + }; + extensions = { + undo.enable = true; + ui-select.enable = true; + fzf-native.enable = true; + file-browser.enable = true; + }; + }; + + fidget = { + enable = true; + settings.notification.override_vim_notify = true; + }; + + dap = { + enable = true; + extensions = { + dap-ui.enable = true; + dap-virtual-text.enable = true; + }; + }; + + nvim-ufo = { + enable = true; + settings = { + close_fold_kinds = null; + provider_selector = + /* + lua + */ + '' + function(bufnr, filetype, buftype) + return {'treesitter', 'indent'} + end ''; }; - - molten = { - enable = true; - settings.image_provider = "image.nvim"; - }; - - markdown-preview = { - enable = true; - }; - - noice = { - enable = true; - settings = { - notify.enabled = false; - lsp.override = { - "vim.lsp.util.convert_input_to_markdown_lines" = true; - "vim.lsp.util.stylize_markdown" = true; - "cmp.entry.get_documentation" = true; - }; - presets = { - bottom_search = false; - command_palette = true; - long_message_to_split = true; - inc_rename = false; - lsp_doc_border = true; - }; - }; - }; - - treesitter = { - enable = true; - settings = { - indent.enable = true; - highlight = { - enable = true; - additional_vim_regex_highlighting = true; - }; - }; - folding = true; - grammarPackages = - (with pkgs.tree-sitter-grammars; [ - tree-sitter-norg - tree-sitter-norg-meta - tree-sitter-just - tree-sitter-nu - tree-sitter-d2 - ]) - ++ pkgs.vimPlugins.nvim-treesitter.allGrammars; - }; - - telescope = { - enable = true; - settings = { - defaults = { - layout_strategy = "horizontal"; - layout_config = { - # preview_height = 0.8; - vertical = { - size = { - width = "99%"; - height = "99%"; - }; - }; - }; - }; - }; - extensions = { - undo.enable = true; - ui-select.enable = true; - fzf-native.enable = true; - file-browser.enable = true; - }; - }; - - fidget = { - enable = true; - settings.notification.override_vim_notify = true; - }; - - dap = { - enable = true; - extensions = { - dap-ui.enable = true; - dap-virtual-text.enable = true; - }; - }; - - nvim-ufo = { - enable = true; - settings = { - close_fold_kinds = null; - provider_selector = - /* - lua - */ - '' - function(bufnr, filetype, buftype) - return {'treesitter', 'indent'} - end - ''; - }; - }; - rustaceanvim = { - enable = false; - settings = { - server = { - default_settings = { - rust-analyzer = { - inlayHints = { - genericParameterHints = { - lifetime.enable = true; - }; - # implicitDrops.enable = true; - }; - files = { - excludeDirs = [ - ".cargo" - ".direnv" - ".git" - ".vcpkg" - "node_modules" - "target" - ]; - }; - diagnostics = { - enable = true; - styleLints.enable = true; - }; - - checkOnSave = true; - check = { - command = "check"; - features = "all"; - }; - }; - }; - }; - dap = let - vscode-lldb = pkgs.vscode-extensions.vadimcn.vscode-lldb; - liblldb = - if pkgs.stdenv.isLinux - then "${vscode-lldb.lldb}/lib/liblldb.so" - else if pkgs.stdenv.isDarwin - then "${vscode-lldb.lldb}/lib/liblldb.dylib" - else null; - codelldb = "${vscode-lldb.adapter}/bin/codelldb"; - in { - autoload_configurations = false; - # adapter = - # /* - # lua - # */ - # '' - # require('rustaceanvim.config').get_codelldb_adapter("${codelldb}", "${liblldb}") - # ''; - }; - tools = { - float_win_config = {border = "rounded";}; - enable_clippy = false; - }; - }; - }; - - lsp = { - enable = true; - servers = { - taplo.enable = true; - gopls.enable = true; - nil_ls = { - enable = true; - settings.formatting.command = [ - "${pkgs.alejandra}/bin/alejandra" - ]; - # nix.flake.autoArchive = true; - }; - marksman.enable = true; - neocmake.enable = true; - nushell.enable = true; - clangd.enable = true; - lua_ls.enable = true; - jsonls.enable = true; - html.enable = true; - htmx.enable = true; - elixirls.enable = true; - ast_grep.enable = true; - sqls.enable = true; - pyright.enable = true; - slint_lsp.enable = true; - rust_analyzer = { - enable = true; - package = null; - installCargo = false; - installRustc = false; - settings = { + }; + rustaceanvim = { + enable = false; + settings = { + server = { + default_settings = { + rust-analyzer = { inlayHints = { genericParameterHints = { lifetime.enable = true; @@ -415,368 +328,453 @@ }; }; }; - onAttach = + dap = let + vscode-lldb = pkgs.vscode-extensions.vadimcn.vscode-lldb; + liblldb = + if pkgs.stdenv.isLinux + then "${vscode-lldb.lldb}/lib/liblldb.so" + else if pkgs.stdenv.isDarwin + then "${vscode-lldb.lldb}/lib/liblldb.dylib" + else null; + codelldb = "${vscode-lldb.adapter}/bin/codelldb"; + in { + autoload_configurations = false; + # adapter = + # /* + # lua + # */ + # '' + # require('rustaceanvim.config').get_codelldb_adapter("${codelldb}", "${liblldb}") + # ''; + }; + tools = { + float_win_config = {border = "rounded";}; + enable_clippy = false; + }; + }; + }; + + lsp = { + enable = true; + servers = { + taplo.enable = true; + gopls.enable = true; + nil_ls = { + enable = true; + settings.formatting.command = [ + "${pkgs.alejandra}/bin/alejandra" + ]; + # nix.flake.autoArchive = true; + }; + marksman.enable = true; + neocmake.enable = true; + nushell.enable = true; + clangd.enable = true; + lua_ls.enable = true; + jsonls.enable = true; + html.enable = true; + htmx.enable = true; + elixirls.enable = true; + ast_grep.enable = true; + sqls.enable = true; + pyright.enable = true; + slint_lsp.enable = true; + rust_analyzer = { + enable = true; + package = null; + installCargo = false; + installRustc = false; + settings = { + inlayHints = { + genericParameterHints = { + lifetime.enable = true; + }; + # implicitDrops.enable = true; + }; + files = { + excludeDirs = [ + ".cargo" + ".direnv" + ".git" + ".vcpkg" + "node_modules" + "target" + ]; + }; + diagnostics = { + enable = true; + styleLints.enable = true; + }; + + checkOnSave = true; + check = { + command = "check"; + features = "all"; + }; + }; + }; + }; + onAttach = + /* + lua + */ + '' + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(true) + end + ''; + }; + cmp = { + enable = true; + settings = { + autoEnableSources = true; + sources = [ + {name = "buffer";} + {name = "buffer";} + {name = "cmdline";} + {name = "cmp-clippy";} + {name = "cmp-cmdline-history";} + {name = "crates";} + {name = "dap";} + # {name = "dictionary";} + {name = "fish";} + {name = "git";} + {name = "luasnip";} + {name = "nvim_lsp";} + {name = "nvim_lua";} + {name = "nvim_lsp_signature_help";} + {name = "nvim_lsp_document_symbol";} + {name = "path";} + {name = "rg";} + {name = "spell";} + {name = "tmux";} + {name = "treesitter";} + ]; + view = { + entries = { + name = "custom"; + selection_order = "near_cursor"; + }; + }; + window = { + completion = { + inherit border; + }; + documentation = { + inherit border; + }; + }; + mapping = { + # "" = "cmp.mapping.confirm({select = true})"; + "" = "cmp.mapping.confirm()"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; + }; + snippet.expand = /* lua */ '' - if client.server_capabilities.inlayHintProvider then - vim.lsp.inlay_hint.enable(true) + function(args) + require('luasnip').lsp_expand(args.body) end ''; }; - cmp = { - enable = true; - settings = { - autoEnableSources = true; - sources = [ - {name = "buffer";} - {name = "buffer";} - {name = "cmdline";} - {name = "cmp-clippy";} - {name = "cmp-cmdline-history";} - {name = "crates";} - {name = "dap";} - # {name = "dictionary";} - {name = "fish";} - {name = "git";} - {name = "luasnip";} - {name = "nvim_lsp";} - {name = "nvim_lua";} - {name = "nvim_lsp_signature_help";} - {name = "nvim_lsp_document_symbol";} - {name = "path";} - {name = "rg";} - {name = "spell";} - {name = "tmux";} - {name = "treesitter";} - ]; - view = { - entries = { - name = "custom"; - selection_order = "near_cursor"; - }; - }; - window = { - completion = { - inherit border; - }; - documentation = { - inherit border; - }; - }; - mapping = { - # "" = "cmp.mapping.confirm({select = true})"; - "" = "cmp.mapping.confirm()"; - "" = "cmp.mapping.complete()"; - "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; - "" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; - }; - snippet.expand = - /* - lua - */ - '' - function(args) - require('luasnip').lsp_expand(args.body) - end - ''; - }; - }; }; - globals = { - mapleader = " "; - localleader = " "; - }; - colorschemes = { - catppuccin = { - enable = true; - settings.flavour = "mocha"; - }; - }; - keymaps = mkMappings { - normal = { - "" = "[[Outline]]"; - "\"" = "[[split]]"; - "%" = "[[vsplit]]"; - "gh" = "[[Octo actions]]"; - "\"" = ''[["+]]''; - "" = "[[ChatGPT]]"; - "dr" = "[[RustLsp debuggables]]"; - "ee" = "[[Rest run]]"; - "el" = "[[Rest run last]]"; - "hh" = "[[DevdocsOpen]]"; - "hl" = "[[DevdocsToggle]]"; - "" = "''"; - "n" = "[[bnext]]"; - "o" = "[[Trouble diagnostics]]"; - "p" = "[[bprev]]"; - "q" = "[[bw]]"; - "mm" = "[[Neorg]]"; - "vff" = "[[vertical Gdiffsplit]]"; - - "rr" = "vim.lsp.buf.rename"; - "" = "vim.lsp.buf.definition"; - "" = "require('FTerm').toggle"; - # "F" = "function() vim.lsp.buf.format({ async = true }) end"; - "F" = "require('conform').format"; - "gi" = "require'telescope.builtin'.lsp_references"; - "a" = "vim.lsp.buf.code_action"; - "bb" = "require'dap'.toggle_breakpoint"; - "du" = "require'dapui'.toggle"; - "fb" = "require'telescope'.extensions.file_browser.file_browser"; - "fg" = "require'yazi'.yazi"; - "ff" = "require'telescope.builtin'.find_files"; - "gg" = "require'telescope.builtin'.live_grep"; - ";" = "require'telescope.builtin'.buffers"; - "zR" = "require'ufo'.openAllFolds"; - "zM" = "require'ufo'.closeAllFolds"; - - # Emulate tmux bindings with prefix and tabs - "" = "[[g]]"; - "c" = "[[tabnew]]"; - "x" = "[[tabclose]]"; - "n" = "[[tabnext]]"; - "p" = "[[tabprevious]]"; - }; - terminal = { - "" = "require('FTerm').toggle"; - }; - insert = { - "" = "require('FTerm').toggle"; - }; - visual = { - "L" = "[[:'<,'>!sort -u]]"; - }; - }; - - autoCmd = [ - { - event = ["BufEnter" "BufWinEnter"]; - pattern = "*.norg"; - command = "set conceallevel=3"; - } - # { - # event = ["BufEnter" "BufWinEnter"]; - # pattern = "*.sql"; - # command = "nnoremap F :Sqlfmt"; - # } - { - event = ["BufWinLeave"]; - pattern = "?*"; - command = "mkview!"; - } - { - event = ["BufWinEnter"]; - pattern = "?*"; - command = "silent! loadview!"; - } - ]; - - extraConfigLua = - /* - lua - */ - '' - function catcher(callback) - do - success, output = pcall(callback) - if not success then - print("Failed to setup: " .. output) - end - end - end - - require("copilot").setup({ - suggestion = { - enabled = true, - auto_trigger = true, - keymap = { - accept = "", - } - }, - panel = { enabled = true }, - }) - - catcher(require('crates').setup) - catcher(require('outline').setup) - -- catcher(require('navigator').setup) - - require('FTerm').setup({ - border = 'single', - dimensions = { - height = 0.99, - width = 0.95, - }, - cmd = "sh -c 'tmux new -As scratch'", - blend = 10, - }) - - require('octo').setup({ - use_local_fs = false, - enable_builtin = false, - default_remote = {"upstream", "origin"}; - default_merge_method = "squash"; - }) - - if not vim.g.neovide then - require('neoscroll').setup() - require('image').setup({["backend"] = "kitty",["tmux_show_only_in_active_window"] = true}) - else - vim.o.guifont = "Hasklug Nerd Font Mono:h13" - vim.g.neovide_cursor_vfx_mode = "railgun" - end - - require('lspconfig.ui.windows').default_options.border = 'single' - - catcher(require('nvim_context_vt').setup) - - vim.api.nvim_create_user_command('Reso', - function() - pcall(vim.cmd'source ~/.config/nvim/init.lua') - end, - {}) - - vim.api.nvim_create_user_command("FormatDisable", function(args) - if args.bang then - -- FormatDisable! will disable formatting just for this buffer - vim.b.disable_autoformat = true - else - vim.g.disable_autoformat = true - end - end, { - desc = "Disable autoformat-on-save", - bang = true, - }) - vim.api.nvim_create_user_command("FormatEnable", function() - vim.b.disable_autoformat = false - vim.g.disable_autoformat = false - end, { - desc = "Re-enable autoformat-on-save", - }) - - vim.api.nvim_create_user_command('Sqlfmt', - function() - pcall(vim.cmd'%!${pkgs.sleek}/bin/sleek') - end, - {}) - - local iron = require("iron.core") - iron.setup({ - config = { - -- Whether a repl should be discarded or not - scratch_repl = true, - -- Your repl definitions come here - repl_definition = { - sh = { - -- Can be a table or a function that - -- returns a table (see below) - command = {"${pkgs.zsh}/bin/zsh"} - }, - sql = { - command = function(meta) - local db = os.getenv("DATABASE_PATH") - if db == nil then - return { '${pkgs.sqlite}/bin/sqlite3', ':memory:' } - else - return { '${pkgs.sqlite}/bin/sqlite3', db } - end - - end - }, - rust = { - command = {"${pkgs.evcxr}/bin/evcxr"} - }, - }, - -- How the repl window will be displayed - -- See below for more information - repl_open_cmd = require('iron.view').right(60), - }, - -- Iron doesn't set keymaps by default anymore. - -- You can set them here or manually add keymaps to the functions in iron.core - keymaps = { - send_motion = "sc", - visual_send = "sc", - send_file = "sf", - send_line = "sl", - send_until_cursor = "su", - send_mark = "sm", - mark_motion = "mc", - mark_visual = "mc", - remove_mark = "md", - cr = "s", - interrupt = "s", - exit = "sq", - clear = "cl", - }, - -- If the highlight is on, you can change how it looks - -- For the available options, check nvim_set_hl - highlight = { - italic = true - }, - ignore_blank_lines = true, -- ignore blank lines when sending visual select lines - }) - - vim.filetype.add({ - extension = { - slint = "slint", - }, - }) - - vim.filetype.add({ - filename = { - ['nurfile'] = "nu", - }, - }) - - ''; - # package = pkgs.neovim-unwrapped; - # pkgs.neovim; - opts = { - completeopt = "menu,menuone,popup,noselect"; - expandtab = true; - foldenable = true; - foldlevel = 99; - foldlevelstart = 99; - hidden = true; - number = true; - relativenumber = true; - shell = "sh"; - shiftwidth = 4; - signcolumn = "yes"; - smartcase = true; - softtabstop = 4; - tabstop = 4; - termguicolors = true; - undofile = true; - viewoptions = "cursor,folds"; - wrap = true; - }; - extraPlugins = with pkgs.vimPlugins; [ - FTerm-nvim - copilot-lua - crates-nvim - d2 - image-nvim - iron-nvim - luasnip - neoscroll-nvim - nvim-web-devicons - nvim_context_vt - octo-nvim - outline-nvim - plenary-nvim - vim-abolish - vim-speeddating - webapi-vim - pkgs.tree-sitter-grammars.tree-sitter-just - pkgs.tree-sitter-grammars.tree-sitter-nu - pkgs.tree-sitter-grammars.tree-sitter-norg - pkgs.tree-sitter-grammars.tree-sitter-norg-meta - ]; - extraLuaPackages = luaPkgs: with luaPkgs; [lua-utils-nvim nvim-nio pathlib-nvim]; - extraPackages = [pkgs.lldb pkgs.taplo pkgs.d2 pkgs.sleek pkgs.graphqurl]; }; -in { - home.packages = [neovim]; + globals = { + mapleader = " "; + localleader = " "; + }; + colorschemes = { + catppuccin = { + enable = true; + settings.flavour = "mocha"; + }; + }; + keymaps = mkMappings { + normal = { + "" = "[[Outline]]"; + "\"" = "[[split]]"; + "%" = "[[vsplit]]"; + "gh" = "[[Octo actions]]"; + "\"" = ''[["+]]''; + "" = "[[ChatGPT]]"; + "dr" = "[[RustLsp debuggables]]"; + "ee" = "[[Rest run]]"; + "el" = "[[Rest run last]]"; + "hh" = "[[DevdocsOpen]]"; + "hl" = "[[DevdocsToggle]]"; + "" = "''"; + "n" = "[[bnext]]"; + "o" = "[[Trouble diagnostics]]"; + "p" = "[[bprev]]"; + "q" = "[[bw]]"; + "mm" = "[[Neorg]]"; + "vff" = "[[vertical Gdiffsplit]]"; + + "rr" = "vim.lsp.buf.rename"; + "" = "vim.lsp.buf.definition"; + "" = "require('FTerm').toggle"; + # "F" = "function() vim.lsp.buf.format({ async = true }) end"; + "F" = "require('conform').format"; + "gi" = "require'telescope.builtin'.lsp_references"; + "a" = "vim.lsp.buf.code_action"; + "bb" = "require'dap'.toggle_breakpoint"; + "du" = "require'dapui'.toggle"; + "fb" = "require'telescope'.extensions.file_browser.file_browser"; + "fg" = "require'yazi'.yazi"; + "ff" = "require'telescope.builtin'.find_files"; + "gg" = "require'telescope.builtin'.live_grep"; + ";" = "require'telescope.builtin'.buffers"; + "zR" = "require'ufo'.openAllFolds"; + "zM" = "require'ufo'.closeAllFolds"; + + # Emulate tmux bindings with prefix and tabs + "" = "[[g]]"; + "c" = "[[tabnew]]"; + "x" = "[[tabclose]]"; + "n" = "[[tabnext]]"; + "p" = "[[tabprevious]]"; + }; + terminal = { + "" = "require('FTerm').toggle"; + }; + insert = { + "" = "require('FTerm').toggle"; + }; + visual = { + "L" = "[[:'<,'>!sort -u]]"; + }; + }; + + autoCmd = [ + { + event = ["BufEnter" "BufWinEnter"]; + pattern = "*.norg"; + command = "set conceallevel=3"; + } + # { + # event = ["BufEnter" "BufWinEnter"]; + # pattern = "*.sql"; + # command = "nnoremap F :Sqlfmt"; + # } + { + event = ["BufWinLeave"]; + pattern = "?*"; + command = "mkview!"; + } + { + event = ["BufWinEnter"]; + pattern = "?*"; + command = "silent! loadview!"; + } + ]; + + extraConfigLua = + /* + lua + */ + '' + function catcher(callback) + do + success, output = pcall(callback) + if not success then + print("Failed to setup: " .. output) + end + end + end + + require("copilot").setup({ + suggestion = { + enabled = true, + auto_trigger = true, + keymap = { + accept = "", + } + }, + panel = { enabled = true }, + }) + + catcher(require('crates').setup) + catcher(require('outline').setup) + -- catcher(require('navigator').setup) + + require('FTerm').setup({ + border = 'single', + dimensions = { + height = 0.99, + width = 0.95, + }, + cmd = "sh -c 'tmux new -As scratch'", + blend = 10, + }) + + require('octo').setup({ + use_local_fs = false, + enable_builtin = false, + default_remote = {"upstream", "origin"}; + default_merge_method = "squash"; + }) + + if not vim.g.neovide then + require('neoscroll').setup() + require('image').setup({["backend"] = "kitty",["tmux_show_only_in_active_window"] = true}) + else + vim.o.guifont = "Hasklug Nerd Font Mono:h13" + vim.g.neovide_cursor_vfx_mode = "railgun" + end + + require('lspconfig.ui.windows').default_options.border = 'single' + + catcher(require('nvim_context_vt').setup) + + vim.api.nvim_create_user_command('Reso', + function() + pcall(vim.cmd'source ~/.config/nvim/init.lua') + end, + {}) + + vim.api.nvim_create_user_command("FormatDisable", function(args) + if args.bang then + -- FormatDisable! will disable formatting just for this buffer + vim.b.disable_autoformat = true + else + vim.g.disable_autoformat = true + end + end, { + desc = "Disable autoformat-on-save", + bang = true, + }) + vim.api.nvim_create_user_command("FormatEnable", function() + vim.b.disable_autoformat = false + vim.g.disable_autoformat = false + end, { + desc = "Re-enable autoformat-on-save", + }) + + vim.api.nvim_create_user_command('Sqlfmt', + function() + pcall(vim.cmd'%!${pkgs.sleek}/bin/sleek') + end, + {}) + + local iron = require("iron.core") + iron.setup({ + config = { + -- Whether a repl should be discarded or not + scratch_repl = true, + -- Your repl definitions come here + repl_definition = { + sh = { + -- Can be a table or a function that + -- returns a table (see below) + command = {"${pkgs.zsh}/bin/zsh"} + }, + sql = { + command = function(meta) + local db = os.getenv("DATABASE_PATH") + if db == nil then + return { '${pkgs.sqlite}/bin/sqlite3', ':memory:' } + else + return { '${pkgs.sqlite}/bin/sqlite3', db } + end + + end + }, + rust = { + command = {"${pkgs.evcxr}/bin/evcxr"} + }, + }, + -- How the repl window will be displayed + -- See below for more information + repl_open_cmd = require('iron.view').right(60), + }, + -- Iron doesn't set keymaps by default anymore. + -- You can set them here or manually add keymaps to the functions in iron.core + keymaps = { + send_motion = "sc", + visual_send = "sc", + send_file = "sf", + send_line = "sl", + send_until_cursor = "su", + send_mark = "sm", + mark_motion = "mc", + mark_visual = "mc", + remove_mark = "md", + cr = "s", + interrupt = "s", + exit = "sq", + clear = "cl", + }, + -- If the highlight is on, you can change how it looks + -- For the available options, check nvim_set_hl + highlight = { + italic = true + }, + ignore_blank_lines = true, -- ignore blank lines when sending visual select lines + }) + + vim.filetype.add({ + extension = { + slint = "slint", + }, + }) + + vim.filetype.add({ + filename = { + ['nurfile'] = "nu", + }, + }) + + ''; + # package = pkgs.neovim-unwrapped; + # pkgs.neovim; + opts = { + completeopt = "menu,menuone,popup,noselect"; + expandtab = true; + foldenable = true; + foldlevel = 99; + foldlevelstart = 99; + hidden = true; + number = true; + relativenumber = true; + shell = "sh"; + shiftwidth = 4; + signcolumn = "yes"; + smartcase = true; + softtabstop = 4; + tabstop = 4; + termguicolors = true; + undofile = true; + viewoptions = "cursor,folds"; + wrap = true; + }; + extraPlugins = with pkgs.vimPlugins; [ + FTerm-nvim + copilot-lua + crates-nvim + d2 + image-nvim + iron-nvim + luasnip + neoscroll-nvim + nvim-web-devicons + nvim_context_vt + octo-nvim + outline-nvim + plenary-nvim + # typr + vim-abolish + vim-speeddating + webapi-vim + + pkgs.tree-sitter-grammars.tree-sitter-just + pkgs.tree-sitter-grammars.tree-sitter-norg + pkgs.tree-sitter-grammars.tree-sitter-norg-meta + pkgs.tree-sitter-grammars.tree-sitter-nu + ]; + extraLuaPackages = luaPkgs: with luaPkgs; [lua-utils-nvim nvim-nio pathlib-nvim]; + extraPackages = [pkgs.lldb pkgs.taplo pkgs.d2 pkgs.sleek pkgs.graphqurl]; } diff --git a/neovim/overlays.nix b/neovim/overlays.nix index 67038e6a..ad3d8b69 100644 --- a/neovim/overlays.nix +++ b/neovim/overlays.nix @@ -8,7 +8,28 @@ version = "1"; src = inputs.d2; }; + # typr = final.pkgs.vimUtils.buildVimPlugin { + # name = "typr"; + # version = "1"; + # src = inputs.typr; + # buildInputs = [final.pkgs.lua52Packages.volt]; + # }; }; + # volt = final.pkgs.neovimUtils.buildNeovimPlugin { + # name = "volt"; + # pname = "volt"; + # version = "1"; + # src = inputs.volt; + # }; + # lua = prev.lua.override { + # packageOverrides = luaself: luaprev: { + # volt = final.stdenv.buildLuaPackage { + # pname = "volt"; + # version = "1.0.0"; + # src = inputs.volt; + # }; + # }; + # }; }; tree-sitter-grammars = final: prev: { tree-sitter-grammars = diff --git a/nixos/mirai/configuration.nix b/nixos/mirai/configuration.nix index 1de9592c..4bb7e1ce 100644 --- a/nixos/mirai/configuration.nix +++ b/nixos/mirai/configuration.nix @@ -1,6 +1,5 @@ { config, - lib, pkgs, ... }: { @@ -8,7 +7,7 @@ # Include the results of the hardware scan. ./services ./mirai.nix - ./docker.nix + # ./docker.nix ]; security.sudo.wheelNeedsPassword = false; sops = { diff --git a/nixos/ryu/configuration.nix b/nixos/ryu/configuration.nix index 48bc695a..a5d75a83 100644 --- a/nixos/ryu/configuration.nix +++ b/nixos/ryu/configuration.nix @@ -248,6 +248,7 @@ systemPackages = with pkgs; [ # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. # wget + (nixvim.makeNixvim (import ../../neovim)) qpwgraph hyprland xorg.xhost