From e9700cf5b47f0fea5412b92260f16f19ba70392c Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sat, 1 Jun 2024 23:33:52 +0200 Subject: [PATCH] Fix toggleterm + split keybinds file --- home/modules/neovim/default.nix | 493 +------------------------------ home/modules/neovim/keybinds.nix | 488 ++++++++++++++++++++++++++++++ 2 files changed, 495 insertions(+), 486 deletions(-) create mode 100644 home/modules/neovim/keybinds.nix diff --git a/home/modules/neovim/default.nix b/home/modules/neovim/default.nix index f5002a2b..6252c330 100644 --- a/home/modules/neovim/default.nix +++ b/home/modules/neovim/default.nix @@ -89,6 +89,7 @@ in { pumheight = 0; formatexpr = "v:lua.require('conform').formatexpr()"; laststatus = 3; + # winblend = 30; # Cursor ruler = true; # Show cursor position in status line @@ -145,7 +146,7 @@ in { -- Neovide if g.neovide then - require("notify").notify("Running in NeoVide") + -- require("notify").notify("Running in NeoVide") g.neovide_cursor_animate_command_line = true g.neovide_cursor_animate_in_insert_mode = true @@ -161,7 +162,7 @@ in { -- Neovide Fonts o.guifont = "JetBrainsMono Nerd Font:h13:Medium" else - require("notify").notify("Not running in NeoVide") + -- require("notify").notify("Not running in NeoVide") end ''; @@ -209,488 +210,7 @@ in { # TODO: Toggle wrapping # TODO: Toggle format on save # TODO: Toggle format on paste - keymaps = [ - # No Leader - { - mode = "n"; - key = ""; - action = "w"; - options.desc = "Save current buffer"; - } - { - mode = "n"; - key = ""; - action = "wa"; - options.desc = "Save all buffers"; - } - { - mode = "v"; - key = "<"; - action = " - { - mode = "n"; - key = "qq"; - action = "quitall"; - options.desc = "Quit"; - } - { - mode = "n"; - key = "q!"; - action = "quitall!"; - options.desc = "Forceful quit"; - } - { - mode = "n"; - key = "L"; - action = "Lazy"; - options.desc = "Show Lazy"; - } - { - mode = "n"; - key = ""; - action = "Telescope buffers"; - options.desc = "Show open buffers"; - } - { - mode = "n"; - key = "S"; - action = "wa"; - options.desc = "Save all buffers"; - } - { - mode = "n"; - key = "f"; - action = "Telescope find_files"; - options.desc = "Find file"; - } - { - mode = "n"; - key = "o"; - action = "Telescope vim_options"; - options.desc = "Show Vim options"; - } - { - mode = "n"; - key = "u"; - action = "Telescope undo"; - options.desc = "Show undo history"; - } - { - mode = "n"; - key = "/"; - action = "Telescope current_buffer_fuzzy_find"; - options.desc = "Find in current buffer"; - } - { - mode = "n"; - key = "n"; - action = "Telescope notify"; - options.desc = "Show notify history"; - } - { - mode = "n"; - key = "s"; - action = "Telescope live_grep"; - options.desc = "Find in working directory"; - } - { - mode = "n"; - key = "r"; - action = "Telescope resume"; - options.desc = "Show last telescope picker"; - } - { - mode = "n"; - key = "?"; - action = "Telescope keymaps"; - options.desc = "Show keymaps"; - } - { - mode = "n"; - key = ":"; - action = "Telescope commands"; - options.desc = "Execute command"; - } - { - mode = "n"; - key = "M"; - action = "Telescope marks"; - options.desc = "Show marks"; - } - { - mode = "n"; - key = "J"; - action = "Telescope jumplist"; - options.desc = "Show jumplist"; - } - { - mode = "n"; - key = "m"; - action = "Telescope man_pages"; - options.desc = "Show manpages"; - } - { - mode = "n"; - key = "h"; - action = "Telescope help_tags"; - options.desc = "Show help tags"; - } - - # Buffers b - { - mode = "n"; - key = "b"; - action = "+buffers"; - } - { - mode = "n"; - key = "bb"; - action = "Telescope buffers"; - options.desc = "Show open buffers"; - } - { - mode = "n"; - key = "bn"; - action = "bnext"; - options.desc = "Goto next buffer"; - } - { - mode = "n"; - key = "bp"; - action = "bprevious"; - options.desc = "Goto previous buffer"; - } - { - mode = "n"; - key = "bd"; - action = "Bdelete"; - options.desc = "Close current buffer"; - } - - # Windows w - { - mode = "n"; - key = "w"; - action = "+windows"; - } - { - mode = "n"; - key = "ws"; - action = "s"; - options.desc = "Split window horizontally"; - } - { - mode = "n"; - key = "wv"; - action = "v"; - options.desc = "Split window vertically"; - } - { - mode = "n"; - key = "wd"; - action = "c"; - options.desc = "Close current window"; - } - # { - # mode = "n"; - # key = "wh"; - # action = "s"; - # options.desc = "Split window horizontally"; - # } - { - mode = "n"; - key = "wh"; - action = "h"; - options.desc = "Goto left window"; - } - { - mode = "n"; - key = "wl"; - action = "l"; - options.desc = "Goto right window"; - } - { - mode = "n"; - key = "wj"; - action = "j"; - options.desc = "Goto bottom window"; - } - { - mode = "n"; - key = "wk"; - action = "k"; - options.desc = "Goto top window"; - } - { - mode = "n"; - key = "ww"; - action = "p"; - options.desc = "Goto other window"; - } - - # Toggles t - { - mode = "n"; - key = "t"; - action = "+toggle"; - } - # { - # mode = "n"; - # key = "tt"; - # action = "Neotree action=show toggle=true"; - # options.desc = "Toggle NeoTree"; - # } - { - mode = "n"; - key = "tt"; - action = "CHADopen --nofocus"; - options.desc = "Toggle CHADtree"; - } - { - mode = "n"; - key = "tn"; - action = "Navbuddy"; - options.desc = "Toggle NavBuddy"; - } - { - mode = "n"; - key = "td"; - action = "TroubleToggle focus=false"; - options.desc = "Toggle Trouble"; - } - # { - # mode = "n"; - # key = "tg"; - # action = "LazyGit"; - # } - # { - # mode = "n"; - # key = "tp"; - # action = "TroubleToggle"; - # } - - # Git g - { - mode = "n"; - key = "g"; - action = "+git"; - } - { - mode = "n"; - key = "gg"; - action = "LazyGit"; - options.desc = "Show LazyGit"; - } - { - mode = "n"; - key = "gm"; - action = "GitMessenger"; - options.desc = "Show GitMessenger"; - } - # { - # mode = "n"; - # key = "gs"; - # action = "Git status"; - # } - { - mode = "n"; - key = "gs"; - action = "Telescope git_status"; - options.desc = "Show Git status"; - } - { - mode = "n"; - key = "gc"; - action = "Telescope git_commits"; - options.desc = "Show Git log"; - } - { - mode = "n"; - key = "gb"; - action = "Telescope git_branches"; - options.desc = "Show Git branches"; - } - { - mode = "n"; - key = "gf"; - action = "Telescope git_bcommits"; - options.desc = "Show Git log for current file"; - } - - # LSP l - { - mode = "n"; - key = "l"; - action = "+lsp"; - } - { - mode = "n"; - key = "lr"; - action = "Telescope lsp_references"; - options.desc = "Goto references"; - } - { - mode = "n"; - key = "ld"; - action = "Telescope lsp_definitions"; - options.desc = "Goto definition"; - } - { - mode = "n"; - key = "li"; - action = "Telescope lsp_implementations"; - options.desc = "Goto implementation"; - } - { - mode = "n"; - key = "lt"; - action = "Telescope lsp_type_definitions"; - options.desc = "Goto type definition"; - } - { - mode = "n"; - key = "lI"; - action = "Telescope lsp_incoming_calls"; - options.desc = "Show incoming calls"; - } - { - mode = "n"; - key = "lO"; - action = "Telescope lsp_outgoing_calls"; - options.desc = "Show outgoing calls"; - } - - # Code c - { - mode = "n"; - key = "c"; - action = "+code"; - } - { - mode = "n"; - key = "cf"; - action = "lua require('conform').format()"; - options.desc = "Format current buffer"; - } - { - mode = "n"; - key = "cd"; - action = "Telescope diagnostics"; - options.desc = "Show diagnostics"; - } - { - mode = "n"; - key = "cr"; - action = "lua vim.lsp.buf.rename()"; - options.desc = "Rename LSP symbol"; - } - { - mode = "n"; - key = "ca"; - action = "lua vim.lsp.buf.code_action()"; - options.desc = "Show LSP code actions"; - } - { - mode = "n"; - key = "cD"; - action = "lua vim.diagnostic.open_float()"; - options.desc = "Show LSP line diagnostics"; - } - ]; + keymaps = import ./keybinds.nix {inherit lib mylib;}; ################################################################################################################################## # Lazy Plugins # @@ -720,7 +240,7 @@ in { end ''; opts = { - flavour = "latte"; # latte, frappe, macchiato, mocha + flavour = "mocha"; # latte, frappe, macchiato, mocha background = { light = "latte"; dark = "mocha"; @@ -1460,13 +980,14 @@ in { { name = "toggleterm"; pkg = pkgs.vimPlugins.toggleterm-nvim; + lazy = false; config = '' function(_, opts) require("toggleterm").setup(opts) end ''; opts = { - open_mapping = "[[]]"; # TODO: Doesn't work + open_mapping = { __raw = "[[]]"; }; hide_numbers = true; shade_terminals = true; start_in_insert = true; diff --git a/home/modules/neovim/keybinds.nix b/home/modules/neovim/keybinds.nix new file mode 100644 index 00000000..17e10705 --- /dev/null +++ b/home/modules/neovim/keybinds.nix @@ -0,0 +1,488 @@ +{ + lib, + mylib, + ... +}: [ + [ + # No Leader + { + mode = "n"; + key = ""; + action = "w"; + options.desc = "Save current buffer"; + } + { + mode = "n"; + key = ""; + action = "wa"; + options.desc = "Save all buffers"; + } + { + mode = "v"; + key = "<"; + action = " + { + mode = "n"; + key = "qq"; + action = "quitall"; + options.desc = "Quit"; + } + { + mode = "n"; + key = "q!"; + action = "quitall!"; + options.desc = "Forceful quit"; + } + { + mode = "n"; + key = "L"; + action = "Lazy"; + options.desc = "Show Lazy"; + } + { + mode = "n"; + key = ""; + action = "Telescope buffers"; + options.desc = "Show open buffers"; + } + { + mode = "n"; + key = "S"; + action = "wa"; + options.desc = "Save all buffers"; + } + { + mode = "n"; + key = "f"; + action = "Telescope find_files"; + options.desc = "Find file"; + } + { + mode = "n"; + key = "o"; + action = "Telescope vim_options"; + options.desc = "Show Vim options"; + } + { + mode = "n"; + key = "u"; + action = "Telescope undo"; + options.desc = "Show undo history"; + } + { + mode = "n"; + key = "/"; + action = "Telescope current_buffer_fuzzy_find"; + options.desc = "Find in current buffer"; + } + { + mode = "n"; + key = "n"; + action = "Telescope notify"; + options.desc = "Show notify history"; + } + { + mode = "n"; + key = "s"; + action = "Telescope live_grep"; + options.desc = "Find in working directory"; + } + { + mode = "n"; + key = "r"; + action = "Telescope resume"; + options.desc = "Show last telescope picker"; + } + { + mode = "n"; + key = "?"; + action = "Telescope keymaps"; + options.desc = "Show keymaps"; + } + { + mode = "n"; + key = ":"; + action = "Telescope commands"; + options.desc = "Execute command"; + } + { + mode = "n"; + key = "M"; + action = "Telescope marks"; + options.desc = "Show marks"; + } + { + mode = "n"; + key = "J"; + action = "Telescope jumplist"; + options.desc = "Show jumplist"; + } + { + mode = "n"; + key = "m"; + action = "Telescope man_pages"; + options.desc = "Show manpages"; + } + { + mode = "n"; + key = "h"; + action = "Telescope help_tags"; + options.desc = "Show help tags"; + } + + # Buffers b + { + mode = "n"; + key = "b"; + action = "+buffers"; + } + { + mode = "n"; + key = "bb"; + action = "Telescope buffers"; + options.desc = "Show open buffers"; + } + { + mode = "n"; + key = "bn"; + action = "bnext"; + options.desc = "Goto next buffer"; + } + { + mode = "n"; + key = "bp"; + action = "bprevious"; + options.desc = "Goto previous buffer"; + } + { + mode = "n"; + key = "bd"; + action = "Bdelete"; + options.desc = "Close current buffer"; + } + + # Windows w + { + mode = "n"; + key = "w"; + action = "+windows"; + } + { + mode = "n"; + key = "ws"; + action = "s"; + options.desc = "Split window horizontally"; + } + { + mode = "n"; + key = "wv"; + action = "v"; + options.desc = "Split window vertically"; + } + { + mode = "n"; + key = "wd"; + action = "c"; + options.desc = "Close current window"; + } + # { + # mode = "n"; + # key = "wh"; + # action = "s"; + # options.desc = "Split window horizontally"; + # } + { + mode = "n"; + key = "wh"; + action = "h"; + options.desc = "Goto left window"; + } + { + mode = "n"; + key = "wl"; + action = "l"; + options.desc = "Goto right window"; + } + { + mode = "n"; + key = "wj"; + action = "j"; + options.desc = "Goto bottom window"; + } + { + mode = "n"; + key = "wk"; + action = "k"; + options.desc = "Goto top window"; + } + { + mode = "n"; + key = "ww"; + action = "p"; + options.desc = "Goto other window"; + } + + # Toggles t + { + mode = "n"; + key = "t"; + action = "+toggle"; + } + # { + # mode = "n"; + # key = "tt"; + # action = "Neotree action=show toggle=true"; + # options.desc = "Toggle NeoTree"; + # } + { + mode = "n"; + key = "tt"; + action = "CHADopen --nofocus"; + options.desc = "Toggle CHADtree"; + } + { + mode = "n"; + key = "tn"; + action = "Navbuddy"; + options.desc = "Toggle NavBuddy"; + } + { + mode = "n"; + key = "td"; + action = "TroubleToggle focus=false"; + options.desc = "Toggle Trouble"; + } + # { + # mode = "n"; + # key = "tg"; + # action = "LazyGit"; + # } + # { + # mode = "n"; + # key = "tp"; + # action = "TroubleToggle"; + # } + + # Git g + { + mode = "n"; + key = "g"; + action = "+git"; + } + { + mode = "n"; + key = "gg"; + action = "LazyGit"; + options.desc = "Show LazyGit"; + } + { + mode = "n"; + key = "gm"; + action = "GitMessenger"; + options.desc = "Show GitMessenger"; + } + # { + # mode = "n"; + # key = "gs"; + # action = "Git status"; + # } + { + mode = "n"; + key = "gs"; + action = "Telescope git_status"; + options.desc = "Show Git status"; + } + { + mode = "n"; + key = "gc"; + action = "Telescope git_commits"; + options.desc = "Show Git log"; + } + { + mode = "n"; + key = "gb"; + action = "Telescope git_branches"; + options.desc = "Show Git branches"; + } + { + mode = "n"; + key = "gf"; + action = "Telescope git_bcommits"; + options.desc = "Show Git log for current file"; + } + + # LSP l + { + mode = "n"; + key = "l"; + action = "+lsp"; + } + { + mode = "n"; + key = "lr"; + action = "Telescope lsp_references"; + options.desc = "Goto references"; + } + { + mode = "n"; + key = "ld"; + action = "Telescope lsp_definitions"; + options.desc = "Goto definition"; + } + { + mode = "n"; + key = "li"; + action = "Telescope lsp_implementations"; + options.desc = "Goto implementation"; + } + { + mode = "n"; + key = "lt"; + action = "Telescope lsp_type_definitions"; + options.desc = "Goto type definition"; + } + { + mode = "n"; + key = "lI"; + action = "Telescope lsp_incoming_calls"; + options.desc = "Show incoming calls"; + } + { + mode = "n"; + key = "lO"; + action = "Telescope lsp_outgoing_calls"; + options.desc = "Show outgoing calls"; + } + + # Code c + { + mode = "n"; + key = "c"; + action = "+code"; + } + { + mode = "n"; + key = "cf"; + action = "lua require('conform').format()"; + options.desc = "Format current buffer"; + } + { + mode = "n"; + key = "cd"; + action = "Telescope diagnostics"; + options.desc = "Show diagnostics"; + } + { + mode = "n"; + key = "cr"; + action = "lua vim.lsp.buf.rename()"; + options.desc = "Rename LSP symbol"; + } + { + mode = "n"; + key = "ca"; + action = "lua vim.lsp.buf.code_action()"; + options.desc = "Show LSP code actions"; + } + { + mode = "n"; + key = "cD"; + action = "lua vim.diagnostic.open_float()"; + options.desc = "Show LSP line diagnostics"; + } + ] +]