From f513c80d48fa103e11e0ec19b8cffb7365e5fd30 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 19:57:49 -0300 Subject: [PATCH 01/20] refactor: make bufferline modular --- config/bufferlines/bufferline.nix | 232 +++++++++++++++--------------- config/bufferlines/default.nix | 17 +++ 2 files changed, 136 insertions(+), 113 deletions(-) create mode 100644 config/bufferlines/default.nix diff --git a/config/bufferlines/bufferline.nix b/config/bufferlines/bufferline.nix index d523ad8..d139ac9 100644 --- a/config/bufferlines/bufferline.nix +++ b/config/bufferlines/bufferline.nix @@ -1,129 +1,135 @@ +{ lib, config, ... }: { - plugins = { - bufferline = { - enable = true; - settings = { - options = { - separatorStyle = "thick"; # “slant”, “padded_slant”, “slope”, “padded_slope”, “thick”, “thin“ - offsets = [ - { - filetype = "neo-tree"; - text = "Neo-tree"; - highlight = "Directory"; - text_align = "left"; - } - ]; + options = { + bufferline.enable = lib.mkEnableOption "Enable bufferline module"; + }; + config = lib.mkIf config.bufferline.enable { + plugins = { + bufferline = { + enable = true; + settings = { + options = { + separatorStyle = "thick"; # “slant”, “padded_slant”, “slope”, “padded_slope”, “thick”, “thin“ + offsets = [ + { + filetype = "neo-tree"; + text = "Neo-tree"; + highlight = "Directory"; + text_align = "left"; + } + ]; + }; }; }; }; - }; - keymaps = [ - { - mode = "n"; - key = ""; - action = "BufferLineCycleNext"; - options = { - desc = "Cycle to next buffer"; - }; - } + keymaps = [ + { + mode = "n"; + key = ""; + action = "BufferLineCycleNext"; + options = { + desc = "Cycle to next buffer"; + }; + } - { - mode = "n"; - key = ""; - action = "BufferLineCyclePrev"; - options = { - desc = "Cycle to previous buffer"; - }; - } + { + mode = "n"; + key = ""; + action = "BufferLineCyclePrev"; + options = { + desc = "Cycle to previous buffer"; + }; + } - { - mode = "n"; - key = ""; - action = "BufferLineCycleNext"; - options = { - desc = "Cycle to next buffer"; - }; - } + { + mode = "n"; + key = ""; + action = "BufferLineCycleNext"; + options = { + desc = "Cycle to next buffer"; + }; + } - { - mode = "n"; - key = ""; - action = "BufferLineCyclePrev"; - options = { - desc = "Cycle to previous buffer"; - }; - } + { + mode = "n"; + key = ""; + action = "BufferLineCyclePrev"; + options = { + desc = "Cycle to previous buffer"; + }; + } - { - mode = "n"; - key = "bd"; - action = "bdelete"; - options = { - desc = "Delete buffer"; - }; - } + { + mode = "n"; + key = "bd"; + action = "bdelete"; + options = { + desc = "Delete buffer"; + }; + } - { - mode = "n"; - key = "bb"; - action = "e #"; - options = { - desc = "Switch to Other Buffer"; - }; - } + { + mode = "n"; + key = "bb"; + action = "e #"; + options = { + desc = "Switch to Other Buffer"; + }; + } - # { - # mode = "n"; - # key = "`"; - # action = "e #"; - # options = { - # desc = "Switch to Other Buffer"; - # }; - # } + # { + # mode = "n"; + # key = "`"; + # action = "e #"; + # options = { + # desc = "Switch to Other Buffer"; + # }; + # } - { - mode = "n"; - key = "br"; - action = "BufferLineCloseRight"; - options = { - desc = "Delete buffers to the right"; - }; - } + { + mode = "n"; + key = "br"; + action = "BufferLineCloseRight"; + options = { + desc = "Delete buffers to the right"; + }; + } - { - mode = "n"; - key = "bl"; - action = "BufferLineCloseLeft"; - options = { - desc = "Delete buffers to the left"; - }; - } + { + mode = "n"; + key = "bl"; + action = "BufferLineCloseLeft"; + options = { + desc = "Delete buffers to the left"; + }; + } - { - mode = "n"; - key = "bo"; - action = "BufferLineCloseOthers"; - options = { - desc = "Delete other buffers"; - }; - } + { + mode = "n"; + key = "bo"; + action = "BufferLineCloseOthers"; + options = { + desc = "Delete other buffers"; + }; + } - { - mode = "n"; - key = "bp"; - action = "BufferLineTogglePin"; - options = { - desc = "Toggle pin"; - }; - } + { + mode = "n"; + key = "bp"; + action = "BufferLineTogglePin"; + options = { + desc = "Toggle pin"; + }; + } - { - mode = "n"; - key = "bP"; - action = "BufferLineGroupClose ungrouped"; - options = { - desc = "Delete non-pinned buffers"; - }; - } - ]; + { + mode = "n"; + key = "bP"; + action = "BufferLineGroupClose ungrouped"; + options = { + desc = "Delete non-pinned buffers"; + }; + } + ]; + }; } diff --git a/config/bufferlines/default.nix b/config/bufferlines/default.nix new file mode 100644 index 0000000..399edc2 --- /dev/null +++ b/config/bufferlines/default.nix @@ -0,0 +1,17 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./bufferline.nix + ]; + + options = { + bufferlines.enable = lib.mkEnableOption "Enable bufferlines module"; + }; + config = lib.mkIf config.bufferlines.enable { + bufferline.enable = lib.mkDefault true; + }; +} From 3c4f93e884922897988a6fd0125b8082b320dde8 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 19:58:07 -0300 Subject: [PATCH 02/20] refactor: make colorschemes directory modular --- config/colorschemes/base16.nix | 14 +++-- config/colorschemes/catppuccin.nix | 82 ++++++++++++++++-------------- config/colorschemes/default.nix | 21 ++++++++ config/colorschemes/rose-pine.nix | 22 +++++--- 4 files changed, 89 insertions(+), 50 deletions(-) create mode 100644 config/colorschemes/default.nix diff --git a/config/colorschemes/base16.nix b/config/colorschemes/base16.nix index ffea1b3..2bc7490 100644 --- a/config/colorschemes/base16.nix +++ b/config/colorschemes/base16.nix @@ -1,8 +1,14 @@ +{ lib, config, ... }: { - colorschemes = { - base16 = { - enable = false; - colorscheme = "mountain"; + options = { + base16.enable = lib.mkEnableOption "Enable base16 module"; + }; + config = lib.mkIf config.base16.enable { + colorschemes = { + base16 = { + enable = false; + colorscheme = "mountain"; + }; }; }; } diff --git a/config/colorschemes/catppuccin.nix b/config/colorschemes/catppuccin.nix index 312d28a..1a600f2 100644 --- a/config/colorschemes/catppuccin.nix +++ b/config/colorschemes/catppuccin.nix @@ -1,44 +1,50 @@ +{ lib, config, ... }: { - colorschemes = { - catppuccin = { - enable = true; - settings = { - background = { - light = "macchiato"; - dark = "mocha"; - }; - flavour = "mocha"; # "latte", "mocha", "frappe", "macchiato" or raw lua code - disable_bold = false; - disable_italic = false; - disable_underline = false; - transparent_background = true; - term_colors = true; - integrations = { - cmp = true; - noice = true; - notify = true; - neotree = true; - harpoon = true; - gitsigns = true; - which_key = true; - illuminate = { - enabled = true; + options = { + catppuccin.enable = lib.mkEnableOption "Enable catppuccin module"; + }; + config = lib.mkIf config.catppuccin.enable { + colorschemes = { + catppuccin = { + enable = true; + settings = { + background = { + light = "macchiato"; + dark = "mocha"; }; - treesitter = true; - treesitter_context = true; - telescope.enabled = true; - indent_blankline.enabled = true; - mini.enabled = true; - native_lsp = { - enabled = true; - inlay_hints = { - background = true; + flavour = "mocha"; # "latte", "mocha", "frappe", "macchiato" or raw lua code + disable_bold = false; + disable_italic = false; + disable_underline = false; + transparent_background = true; + term_colors = true; + integrations = { + cmp = true; + noice = true; + notify = true; + neotree = true; + harpoon = true; + gitsigns = true; + which_key = true; + illuminate = { + enabled = true; }; - underlines = { - errors = ["underline"]; - hints = ["underline"]; - information = ["underline"]; - warnings = ["underline"]; + treesitter = true; + treesitter_context = true; + telescope.enabled = true; + indent_blankline.enabled = true; + mini.enabled = true; + native_lsp = { + enabled = true; + inlay_hints = { + background = true; + }; + underlines = { + errors = [ "underline" ]; + hints = [ "underline" ]; + information = [ "underline" ]; + warnings = [ "underline" ]; + }; }; }; }; diff --git a/config/colorschemes/default.nix b/config/colorschemes/default.nix new file mode 100644 index 0000000..7a62ff5 --- /dev/null +++ b/config/colorschemes/default.nix @@ -0,0 +1,21 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./base16.nix + ./catppuccin.nix + ./rose-pine.nix + ]; + + options = { + colorschemes.enable = lib.mkEnableOption "Enable colorschemes module"; + }; + config = lib.mkIf config.colorschemes.enable { + base16.enable = lib.mkDefault false; + catppuccin.enable = lib.mkDefault true; + rose-pine.enable = lib.mkDefault false; + }; +} diff --git a/config/colorschemes/rose-pine.nix b/config/colorschemes/rose-pine.nix index 2077010..5f479cc 100644 --- a/config/colorschemes/rose-pine.nix +++ b/config/colorschemes/rose-pine.nix @@ -1,12 +1,18 @@ +{ lib, config, ... }: { - colorschemes = { - rose-pine = { - enable = false; - settings = { - styles = { - italic = true; - bold = true; - transparency = false; + options = { + rose-pine.enable = lib.mkEnableOption "Enable rose-pine module"; + }; + config = lib.mkIf config.rose-pine.enable { + colorschemes = { + rose-pine = { + enable = true; + settings = { + styles = { + italic = true; + bold = true; + transparency = false; + }; }; }; }; From 9d53c5715c2cb28fdc61c2d49dfe9419a7eb3fec Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 19:58:34 -0300 Subject: [PATCH 03/20] refactor: modularize completion dir --- config/completion/cmp.nix | 218 +++++++++++++++++----------------- config/completion/copilot.nix | 84 +++++++------ config/completion/default.nix | 21 ++++ config/completion/lspkind.nix | 23 ++-- 4 files changed, 193 insertions(+), 153 deletions(-) create mode 100644 config/completion/default.nix diff --git a/config/completion/cmp.nix b/config/completion/cmp.nix index 7adf5a3..82ab3f8 100644 --- a/config/completion/cmp.nix +++ b/config/completion/cmp.nix @@ -1,63 +1,53 @@ +{ lib, config, ... }: { - plugins = { - cmp-nvim-lsp = {enable = true;}; # lsp - cmp-buffer = {enable = true;}; - copilot-cmp = {enable = true;}; # copilot suggestions - cmp-path = {enable = true;}; # file system paths - cmp_luasnip = {enable = true;}; # snippets - cmp-cmdline = {enable = false;}; # autocomplete for cmdline - cmp = { - enable = true; - autoEnableSources = false; - settings = { - experimental = { - ghost_text = true; - }; + options = { + cmp.enable = lib.mkEnableOption "Enable cmp module"; + }; + config = lib.mkIf config.cmp.enable { + plugins = { + cmp-nvim-lsp = { + enable = true; + }; # lsp + cmp-buffer = { + enable = true; }; - settings = { - mapping = { - __raw = '' - cmp.mapping.preset.insert({ - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.abort(), - - [''] = cmp.mapping.scroll_docs(-4), - - [''] = cmp.mapping.scroll_docs(4), - - [''] = cmp.mapping.complete(), - - [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), - - -- Taken from https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip - -- to stop interference between cmp and luasnip - - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - if luasnip.expandable() then - luasnip.expand() - else - cmp.confirm({ - select = true, - }) - end - else - fallback() - end - end), + cmp-path = { + enable = true; + }; # file system paths + cmp-cmdline = { + enable = true; + }; # autocomplete for cmdline + cmp_luasnip = { + enable = true; + }; # snippets + copilot-cmp = { + enable = true; + }; # copilot suggestions + cmp = { + enable = true; + autoEnableSources = false; + settings = { + experimental = { + ghost_text = true; + }; + mapping = { + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; - [""] = cmp.mapping(function(fallback) + "" = '' + cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.locally_jumpable(1) then - luasnip.jump(1) + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() else fallback() end - end, { "i", "s" }), + end, { "i", "s" }) + ''; - [""] = cmp.mapping(function(fallback) + "" = '' + cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.locally_jumpable(-1) then @@ -65,48 +55,62 @@ else fallback() end - end, { "i", "s" }), - }) - ''; - }; - snippet = { - expand = "function(args) require('luasnip').lsp_expand(args.body) end"; - }; - sources = { - __raw = '' - cmp.config.sources({ - {name = 'nvim_lsp'}, - {name = 'copilot'}, - {name = 'path'}, - {name = 'luasnip'}, - {name = 'cmdline'}, - }, { - {name = 'buffer'}, - }) - ''; - }; - performance = { - debounce = 60; - fetching_timeout = 200; - max_view_entries = 30; - }; - window = { - completion = { - border = "rounded"; - winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None"; + end, { "i", "s" }) + ''; + + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.confirm({ select = false })"; # Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })"; }; - documentation = { - border = "rounded"; + sources = [ + { + name = "nvim_lsp"; + } + { + name = "buffer"; + keyword_length = 5; + } + { name = "copilot"; } + { + name = "path"; + keyword_length = 3; + } + { + name = "luasnip"; + keyword_length = 3; + } + ]; + + # Enable pictogram icons for lsp/autocompletion + formatting = { + fields = [ + "kind" + "abbr" + "menu" + ]; + expandable_indicator = true; + }; + performance = { + debounce = 60; + fetching_timeout = 200; + max_view_entries = 30; + }; + window = { + completion = { + border = "rounded"; + winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None"; + }; + documentation = { + border = "rounded"; + }; }; - }; - formatting = { - fields = ["kind" "abbr" "menu"]; - expandable_indicator = true; }; }; }; - }; - extraConfigLua = '' + extraConfigLua = '' luasnip = require("luasnip") kind_icons = { Text = "󰊄", @@ -136,30 +140,32 @@ TypeParameter = "", } - local cmp = require'cmp' + local cmp = require'cmp' -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline({'/', "?" }, { - sources = { + sources = { { name = 'buffer' } - } - }) + } + }) - -- Set configuration for specific filetype. + -- Set configuration for specific filetype. cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. - }, { - { name = 'buffer' }, - }) - }) + sources = cmp.config.sources({ + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = 'buffer' }, + }) + }) - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }), - }) ''; + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + }) + ''; + }; } diff --git a/config/completion/copilot.nix b/config/completion/copilot.nix index 4f8be48..6dce903 100644 --- a/config/completion/copilot.nix +++ b/config/completion/copilot.nix @@ -1,46 +1,52 @@ +{ lib, config, ... }: { - plugins.copilot-lua = { - enable = true; - panel = { - enabled = false; - autoRefresh = true; - keymap = { - jumpPrev = "[["; - jumpNext = "]]"; - accept = ""; - refresh = "gr"; - open = ""; + options = { + copilot.enable = lib.mkEnableOption "Enable copilot module"; + }; + config = lib.mkIf config.copilot.enable { + plugins.copilot-lua = { + enable = true; + panel = { + enabled = false; + autoRefresh = true; + keymap = { + jumpPrev = "[["; + jumpNext = "]]"; + accept = ""; + refresh = "gr"; + open = ""; + }; + layout = { + position = "bottom"; # | top | left | right + ratio = 0.4; + }; }; - layout = { - position = "bottom"; # | top | left | right - ratio = 0.4; + suggestion = { + enabled = false; + autoTrigger = true; + debounce = 75; + keymap = { + accept = ""; + acceptWord = false; + acceptLine = false; + next = ""; + prev = ""; + dismiss = ""; + }; }; - }; - suggestion = { - enabled = false; - autoTrigger = true; - debounce = 75; - keymap = { - accept = ""; - acceptWord = false; - acceptLine = false; - next = ""; - prev = ""; - dismiss = ""; + filetypes = { + yaml = false; + markdown = false; + help = false; + gitcommit = false; + gitrebase = false; + hgcommit = false; + svn = false; + cvs = false; + "." = false; }; + copilotNodeCommand = "node"; # Node.js version must be > 18.x + serverOptsOverrides = { }; }; - filetypes = { - yaml = false; - markdown = false; - help = false; - gitcommit = false; - gitrebase = false; - hgcommit = false; - svn = false; - cvs = false; - "." = false; - }; - copilotNodeCommand = "node"; # Node.js version must be > 18.x - serverOptsOverrides = {}; }; } diff --git a/config/completion/default.nix b/config/completion/default.nix new file mode 100644 index 0000000..57bed0d --- /dev/null +++ b/config/completion/default.nix @@ -0,0 +1,21 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./cmp.nix + ./copilot.nix + ./lspkind.nix + ]; + + options = { + completion.enable = lib.mkEnableOption "Enable completion module"; + }; + config = lib.mkIf config.completion.enable { + cmp.enable = lib.mkDefault true; + copilot.enable = lib.mkDefault false; + lspkind.enable = lib.mkDefault true; + }; +} diff --git a/config/completion/lspkind.nix b/config/completion/lspkind.nix index 69e8f78..a02a11f 100644 --- a/config/completion/lspkind.nix +++ b/config/completion/lspkind.nix @@ -1,12 +1,19 @@ +{ lib, config, ... }: { - plugins.lspkind = { - enable = true; - symbolMap = { - Copilot = ""; - }; - extraOptions = { - maxwidth = 50; - ellipsis_char = "..."; + options = { + lspkind.enable = lib.mkEnableOption "Enable lspkind module"; + }; + config = lib.mkIf config.lspkind.enable { + + plugins.lspkind = { + enable = true; + symbolMap = { + Copilot = ""; + }; + extraOptions = { + maxwidth = 50; + ellipsis_char = "..."; + }; }; }; } From cdd3342b011396ac0dc0a54ce76c28907422fa26 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 19:58:46 -0300 Subject: [PATCH 04/20] refactor: modularize dap --- config/dap/dap.nix | 222 -------------------------------------- config/dap/default.nix | 17 +++ config/dap/nvim-dap.nix | 234 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 251 insertions(+), 222 deletions(-) delete mode 100644 config/dap/dap.nix create mode 100644 config/dap/default.nix create mode 100644 config/dap/nvim-dap.nix diff --git a/config/dap/dap.nix b/config/dap/dap.nix deleted file mode 100644 index 20fe615..0000000 --- a/config/dap/dap.nix +++ /dev/null @@ -1,222 +0,0 @@ -{ - plugins.dap = { - enable = true; - signs = { - dapBreakpoint = { - text = "●"; - texthl = "DapBreakpoint"; - }; - dapBreakpointCondition = { - text = "●"; - texthl = "DapBreakpointCondition"; - }; - dapLogPoint = { - text = "◆"; - texthl = "DapLogPoint"; - }; - }; - extensions = { - dap-python = { - enable = true; - }; - dap-ui = { - enable = true; - floating.mappings = { - close = ["" "q"]; - }; - }; - dap-virtual-text = { - enable = true; - }; - }; - configurations = { - java = [ - { - type = "java"; - request = "launch"; - name = "Debug (Attach) - Remote"; - hostName = "127.0.0.1"; - port = 5005; - } - ]; - }; - }; - - keymaps = [ - { - mode = "n"; - key = "dB"; - action = " - lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) - "; - options = { - silent = true; - desc = "Breakpoint Condition"; - }; - } - { - mode = "n"; - key = "db"; - action = ":DapToggleBreakpoint"; - options = { - silent = true; - desc = "Toggle Breakpoint"; - }; - } - { - mode = "n"; - key = "dc"; - action = ":DapContinue"; - options = { - silent = true; - desc = "Continue"; - }; - } - { - mode = "n"; - key = "da"; - action = "lua require('dap').continue({ before = get_args })"; - options = { - silent = true; - desc = "Run with Args"; - }; - } - { - mode = "n"; - key = "dC"; - action = "lua require('dap').run_to_cursor()"; - options = { - silent = true; - desc = "Run to cursor"; - }; - } - { - mode = "n"; - key = "dg"; - action = "lua require('dap').goto_()"; - options = { - silent = true; - desc = "Go to line (no execute)"; - }; - } - { - mode = "n"; - key = "di"; - action = ":DapStepInto"; - options = { - silent = true; - desc = "Step into"; - }; - } - { - mode = "n"; - key = "dj"; - action = " - lua require('dap').down() - "; - options = { - silent = true; - desc = "Down"; - }; - } - { - mode = "n"; - key = "dk"; - action = "lua require('dap').up()"; - options = { - silent = true; - desc = "Up"; - }; - } - { - mode = "n"; - key = "dl"; - action = "lua require('dap').run_last()"; - options = { - silent = true; - desc = "Run Last"; - }; - } - { - mode = "n"; - key = "do"; - action = ":DapStepOut"; - options = { - silent = true; - desc = "Step Out"; - }; - } - { - mode = "n"; - key = "dO"; - action = ":DapStepOver"; - options = { - silent = true; - desc = "Step Over"; - }; - } - { - mode = "n"; - key = "dp"; - action = "lua require('dap').pause()"; - options = { - silent = true; - desc = "Pause"; - }; - } - { - mode = "n"; - key = "dr"; - action = ":DapToggleRepl"; - options = { - silent = true; - desc = "Toggle REPL"; - }; - } - { - mode = "n"; - key = "ds"; - action = "lua require('dap').session()"; - options = { - silent = true; - desc = "Session"; - }; - } - { - mode = "n"; - key = "dt"; - action = ":DapTerminate"; - options = { - silent = true; - desc = "Terminate"; - }; - } - { - mode = "n"; - key = "du"; - action = "lua require('dapui').toggle()"; - options = { - silent = true; - desc = "Dap UI"; - }; - } - { - mode = "n"; - key = "dw"; - action = "lua require('dap.ui.widgets').hover()"; - options = { - silent = true; - desc = "Widgets"; - }; - } - { - mode = ["n" "v"]; - key = "de"; - action = "lua require('dapui').eval()"; - options = { - silent = true; - desc = "Eval"; - }; - } - ]; -} diff --git a/config/dap/default.nix b/config/dap/default.nix new file mode 100644 index 0000000..8489c34 --- /dev/null +++ b/config/dap/default.nix @@ -0,0 +1,17 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./nvim-dap.nix + ]; + + options = { + dap.enable = lib.mkEnableOption "Enable dap module"; + }; + config = lib.mkIf config.dap.enable { + nvim-dap.enable = lib.mkDefault true; + }; +} diff --git a/config/dap/nvim-dap.nix b/config/dap/nvim-dap.nix new file mode 100644 index 0000000..08fb1b0 --- /dev/null +++ b/config/dap/nvim-dap.nix @@ -0,0 +1,234 @@ +{ lib, config, ... }: +{ + options = { + nvim-dap.enable = lib.mkEnableOption "Enable Debug Adapter Protocol module"; + }; + config = lib.mkIf config.nvim-dap.enable { + plugins.dap = { + enable = true; + signs = { + dapBreakpoint = { + text = "●"; + texthl = "DapBreakpoint"; + }; + dapBreakpointCondition = { + text = "●"; + texthl = "DapBreakpointCondition"; + }; + dapLogPoint = { + text = "◆"; + texthl = "DapLogPoint"; + }; + }; + extensions = { + dap-python = { + enable = true; + }; + dap-ui = { + enable = true; + floating.mappings = { + close = [ + "" + "q" + ]; + }; + }; + dap-virtual-text = { + enable = true; + }; + }; + configurations = { + java = [ + { + type = "java"; + request = "launch"; + name = "Debug (Attach) - Remote"; + hostName = "127.0.0.1"; + port = 5005; + } + ]; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "dB"; + action = " + lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) + "; + options = { + silent = true; + desc = "Breakpoint Condition"; + }; + } + { + mode = "n"; + key = "db"; + action = ":DapToggleBreakpoint"; + options = { + silent = true; + desc = "Toggle Breakpoint"; + }; + } + { + mode = "n"; + key = "dc"; + action = ":DapContinue"; + options = { + silent = true; + desc = "Continue"; + }; + } + { + mode = "n"; + key = "da"; + action = "lua require('dap').continue({ before = get_args })"; + options = { + silent = true; + desc = "Run with Args"; + }; + } + { + mode = "n"; + key = "dC"; + action = "lua require('dap').run_to_cursor()"; + options = { + silent = true; + desc = "Run to cursor"; + }; + } + { + mode = "n"; + key = "dg"; + action = "lua require('dap').goto_()"; + options = { + silent = true; + desc = "Go to line (no execute)"; + }; + } + { + mode = "n"; + key = "di"; + action = ":DapStepInto"; + options = { + silent = true; + desc = "Step into"; + }; + } + { + mode = "n"; + key = "dj"; + action = " + lua require('dap').down() + "; + options = { + silent = true; + desc = "Down"; + }; + } + { + mode = "n"; + key = "dk"; + action = "lua require('dap').up()"; + options = { + silent = true; + desc = "Up"; + }; + } + { + mode = "n"; + key = "dl"; + action = "lua require('dap').run_last()"; + options = { + silent = true; + desc = "Run Last"; + }; + } + { + mode = "n"; + key = "do"; + action = ":DapStepOut"; + options = { + silent = true; + desc = "Step Out"; + }; + } + { + mode = "n"; + key = "dO"; + action = ":DapStepOver"; + options = { + silent = true; + desc = "Step Over"; + }; + } + { + mode = "n"; + key = "dp"; + action = "lua require('dap').pause()"; + options = { + silent = true; + desc = "Pause"; + }; + } + { + mode = "n"; + key = "dr"; + action = ":DapToggleRepl"; + options = { + silent = true; + desc = "Toggle REPL"; + }; + } + { + mode = "n"; + key = "ds"; + action = "lua require('dap').session()"; + options = { + silent = true; + desc = "Session"; + }; + } + { + mode = "n"; + key = "dt"; + action = ":DapTerminate"; + options = { + silent = true; + desc = "Terminate"; + }; + } + { + mode = "n"; + key = "du"; + action = "lua require('dapui').toggle()"; + options = { + silent = true; + desc = "Dap UI"; + }; + } + { + mode = "n"; + key = "dw"; + action = "lua require('dap.ui.widgets').hover()"; + options = { + silent = true; + desc = "Widgets"; + }; + } + { + mode = [ + "n" + "v" + ]; + key = "de"; + action = "lua require('dapui').eval()"; + options = { + silent = true; + desc = "Eval"; + }; + } + ]; + }; +} From ae13fb2736d88f0f14d2c63a9e5afd406b658283 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 19:59:28 -0300 Subject: [PATCH 05/20] refactor: make neo-tree modular --- config/filetrees/default.nix | 17 +++++ config/filetrees/neo-tree.nix | 123 ++++++++++++++++++---------------- 2 files changed, 82 insertions(+), 58 deletions(-) create mode 100644 config/filetrees/default.nix diff --git a/config/filetrees/default.nix b/config/filetrees/default.nix new file mode 100644 index 0000000..c56fd8b --- /dev/null +++ b/config/filetrees/default.nix @@ -0,0 +1,17 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./neo-tree.nix + ]; + + options = { + filetrees.enable = lib.mkEnableOption "Enable filetrees module"; + }; + config = lib.mkIf config.filetrees.enable { + neo-tree.enable = lib.mkDefault false; + }; +} diff --git a/config/filetrees/neo-tree.nix b/config/filetrees/neo-tree.nix index c83589e..542d932 100644 --- a/config/filetrees/neo-tree.nix +++ b/config/filetrees/neo-tree.nix @@ -1,64 +1,71 @@ +{ lib, config, ... }: { - plugins.neo-tree = { - enable = false; - enableDiagnostics = true; - enableGitStatus = true; - enableModifiedMarkers = true; - enableRefreshOnWrite = true; - closeIfLastWindow = true; - popupBorderStyle = "rounded"; # Type: null or one of “NC”, “double”, “none”, “rounded”, “shadow”, “single”, “solid” or raw lua code - buffers = { - bindToCwd = false; - followCurrentFile = { - enabled = true; + options = { + neo-tree.enable = lib.mkEnableOption "Enable neo-tree module"; + }; + config = lib.mkIf config.neo-tree.enable { + + plugins.neo-tree = { + enable = true; + enableDiagnostics = true; + enableGitStatus = true; + enableModifiedMarkers = true; + enableRefreshOnWrite = true; + closeIfLastWindow = true; + popupBorderStyle = "rounded"; # Type: null or one of “NC”, “double”, “none”, “rounded”, “shadow”, “single”, “solid” or raw lua code + buffers = { + bindToCwd = false; + followCurrentFile = { + enabled = true; + }; }; - }; - window = { - width = 40; - height = 15; - autoExpandWidth = false; - mappings = { - "" = "none"; + window = { + width = 40; + height = 15; + autoExpandWidth = false; + mappings = { + "" = "none"; + }; }; }; - }; - # keymaps = [ - # { - # mode = "n"; - # key = "e"; - # action = ":Neotree toggle reveal_force_cwd"; - # options = { - # silent = true; - # desc = "Explorer NeoTree (root dir)"; - # }; - # } - # { - # mode = "n"; - # key = "E"; - # action = "Neotree toggle"; - # options = { - # silent = true; - # desc = "Explorer NeoTree (cwd)"; - # }; - # } - # { - # mode = "n"; - # key = "be"; - # action = ":Neotree buffers"; - # options = { - # silent = true; - # desc = "Buffer explorer"; - # }; - # } - # { - # mode = "n"; - # key = "ge"; - # action = ":Neotree git_status"; - # options = { - # silent = true; - # desc = "Git explorer"; - # }; - # } - # ]; + # keymaps = [ + # { + # mode = "n"; + # key = "e"; + # action = ":Neotree toggle reveal_force_cwd"; + # options = { + # silent = true; + # desc = "Explorer NeoTree (root dir)"; + # }; + # } + # { + # mode = "n"; + # key = "E"; + # action = "Neotree toggle"; + # options = { + # silent = true; + # desc = "Explorer NeoTree (cwd)"; + # }; + # } + # { + # mode = "n"; + # key = "be"; + # action = ":Neotree buffers"; + # options = { + # silent = true; + # desc = "Buffer explorer"; + # }; + # } + # { + # mode = "n"; + # key = "ge"; + # action = ":Neotree git_status"; + # options = { + # silent = true; + # desc = "Git explorer"; + # }; + # } + # ]; + }; } From 9b7e7e9122cda79f58ba2918eb70f4b7936cc806 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 19:59:36 -0300 Subject: [PATCH 06/20] refactor: make git dir modular --- config/git/default.nix | 23 +++++ config/git/diffview.nix | 11 ++- config/git/gitsigns.nix | 191 ++++++++++++++++++++++------------------ config/git/lazygit.nix | 37 ++++---- config/git/neogit.nix | 24 +++-- 5 files changed, 172 insertions(+), 114 deletions(-) create mode 100644 config/git/default.nix diff --git a/config/git/default.nix b/config/git/default.nix new file mode 100644 index 0000000..f6c026f --- /dev/null +++ b/config/git/default.nix @@ -0,0 +1,23 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./diffview.nix + ./gitsigns.nix + ./lazygit.nix + ./neogit.nix + ]; + + options = { + git.enable = lib.mkEnableOption "Enable git module"; + }; + config = lib.mkIf config.git.enable { + diffview.enable = lib.mkDefault true; + gitsigns.enable = lib.mkDefault true; + lazygit.enable = lib.mkDefault true; + neogit.enable = lib.mkDefault false; + }; +} diff --git a/config/git/diffview.nix b/config/git/diffview.nix index fa672d0..4ab4244 100644 --- a/config/git/diffview.nix +++ b/config/git/diffview.nix @@ -1,5 +1,12 @@ +{ lib, config, ... }: { - plugins.diffview = { - enable = true; + options = { + diffview.enable = lib.mkEnableOption "Enable diffview module"; + }; + config = lib.mkIf config.diffview.enable { + + plugins.diffview = { + enable = true; + }; }; } diff --git a/config/git/gitsigns.nix b/config/git/gitsigns.nix index 67814df..851aca8 100644 --- a/config/git/gitsigns.nix +++ b/config/git/gitsigns.nix @@ -1,92 +1,107 @@ +{ lib, config, ... }: { - plugins.gitsigns = { - enable = true; - settings = { - trouble = true; - current_line_blame = false; - }; + options = { + gitsigns.enable = lib.mkEnableOption "Enable gitsigns module"; }; - keymaps = [ - { - mode = ["n" "v"]; - key = "gh"; - action = "gitsigns"; - options = { - silent = true; - desc = "+hunks"; - }; - } - { - mode = "n"; - key = "ghb"; - action = ":Gitsigns blame_line"; - options = { - silent = true; - desc = "Blame line"; - }; - } - { - mode = "n"; - key = "ghd"; - action = ":Gitsigns diffthis"; - options = { - silent = true; - desc = "Diff This"; - }; - } - { - mode = "n"; - key = "ghp"; - action = ":Gitsigns preview_hunk"; - options = { - silent = true; - desc = "Preview hunk"; - }; - } - { - mode = "n"; - key = "ghR"; - action = ":Gitsigns reset_buffer"; - options = { - silent = true; - desc = "Reset Buffer"; - }; - } - { - mode = ["n" "v"]; - key = "ghr"; - action = ":Gitsigns reset_hunk"; - options = { - silent = true; - desc = "Reset Hunk"; + config = lib.mkIf config.gitsigns.enable { + plugins.gitsigns = { + enable = true; + settings = { + trouble = true; + current_line_blame = false; }; - } - { - mode = ["n" "v"]; - key = "ghs"; - action = ":Gitsigns stage_hunk"; - options = { - silent = true; - desc = "Stage Hunk"; - }; - } - { - mode = "n"; - key = "ghS"; - action = ":Gitsigns stage_buffer"; - options = { - silent = true; - desc = "Stage Buffer"; - }; - } - { - mode = "n"; - key = "ghu"; - action = ":Gitsigns undo_stage_hunk"; - options = { - silent = true; - desc = "Undo Stage Hunk"; - }; - } - ]; + }; + keymaps = [ + { + mode = [ + "n" + "v" + ]; + key = "gh"; + action = "gitsigns"; + options = { + silent = true; + desc = "+hunks"; + }; + } + { + mode = "n"; + key = "ghb"; + action = ":Gitsigns blame_line"; + options = { + silent = true; + desc = "Blame line"; + }; + } + { + mode = "n"; + key = "ghd"; + action = ":Gitsigns diffthis"; + options = { + silent = true; + desc = "Diff This"; + }; + } + { + mode = "n"; + key = "ghp"; + action = ":Gitsigns preview_hunk"; + options = { + silent = true; + desc = "Preview hunk"; + }; + } + { + mode = "n"; + key = "ghR"; + action = ":Gitsigns reset_buffer"; + options = { + silent = true; + desc = "Reset Buffer"; + }; + } + { + mode = [ + "n" + "v" + ]; + key = "ghr"; + action = ":Gitsigns reset_hunk"; + options = { + silent = true; + desc = "Reset Hunk"; + }; + } + { + mode = [ + "n" + "v" + ]; + key = "ghs"; + action = ":Gitsigns stage_hunk"; + options = { + silent = true; + desc = "Stage Hunk"; + }; + } + { + mode = "n"; + key = "ghS"; + action = ":Gitsigns stage_buffer"; + options = { + silent = true; + desc = "Stage Buffer"; + }; + } + { + mode = "n"; + key = "ghu"; + action = ":Gitsigns undo_stage_hunk"; + options = { + silent = true; + desc = "Undo Stage Hunk"; + }; + } + ]; + }; } diff --git a/config/git/lazygit.nix b/config/git/lazygit.nix index 0563fcd..a17ce5b 100644 --- a/config/git/lazygit.nix +++ b/config/git/lazygit.nix @@ -1,20 +1,27 @@ +{ lib, config, ... }: { - plugins.lazygit = { - enable = true; + options = { + lazygit.enable = lib.mkEnableOption "Enable lazygit module"; }; + config = lib.mkIf config.lazygit.enable { - extraConfigLua = '' - require("telescope").load_extension("lazygit") - ''; + plugins.lazygit = { + enable = true; + }; - keymaps = [ - { - mode = "n"; - key = "gg"; - action = "LazyGit"; - options = { - desc = "LazyGit (root dir)"; - }; - } - ]; + extraConfigLua = '' + require("telescope").load_extension("lazygit") + ''; + + keymaps = [ + { + mode = "n"; + key = "gg"; + action = "LazyGit"; + options = { + desc = "LazyGit (root dir)"; + }; + } + ]; + }; } diff --git a/config/git/neogit.nix b/config/git/neogit.nix index a16b7a1..36e5566 100644 --- a/config/git/neogit.nix +++ b/config/git/neogit.nix @@ -1,12 +1,18 @@ +{ lib, config, ... }: { - plugins.neogit = { - enable = false; + options = { + neogit.enable = lib.mkEnableOption "Enable neogit module"; + }; + config = lib.mkIf config.neogit.enable { + plugins.neogit = { + enable = false; + }; + keymaps = [ + { + mode = "n"; + key = "gg"; + action = "Neogit"; + } + ]; }; - keymaps = [ - { - mode = "n"; - key = "gg"; - action = "Neogit"; - } - ]; } From 60bbc45c44ea7c5d144ee88bd391be5a4bd70c80 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 19:59:59 -0300 Subject: [PATCH 07/20] refactor: make treesitter modular + squash all in a single file --- config/languages/default.nix | 21 ++++ config/languages/nvim-jdtls.nix | 44 +++++---- config/languages/nvim-lint.nix | 40 ++++---- config/languages/treesitter-nvim.nix | 98 +++++++++++++++++++ .../treesitter/treesitter-context.nix | 5 - .../treesitter/treesitter-textobjects.nix | 50 ---------- config/languages/treesitter/treesitter.nix | 10 -- config/languages/treesitter/ts-autotag.nix | 5 - .../treesitter/ts-context-commentstring.nix | 6 -- 9 files changed, 167 insertions(+), 112 deletions(-) create mode 100644 config/languages/default.nix create mode 100644 config/languages/treesitter-nvim.nix delete mode 100644 config/languages/treesitter/treesitter-context.nix delete mode 100644 config/languages/treesitter/treesitter-textobjects.nix delete mode 100644 config/languages/treesitter/treesitter.nix delete mode 100644 config/languages/treesitter/ts-autotag.nix delete mode 100644 config/languages/treesitter/ts-context-commentstring.nix diff --git a/config/languages/default.nix b/config/languages/default.nix new file mode 100644 index 0000000..b166477 --- /dev/null +++ b/config/languages/default.nix @@ -0,0 +1,21 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./treesitter-nvim.nix + ./nvim-jdtls.nix + ./nvim-lint.nix + ]; + + options = { + languages.enable = lib.mkEnableOption "Enable languages module"; + }; + config = lib.mkIf config.languages.enable { + treesitter-nvim.enable = lib.mkDefault true; + nvim-jdtls.enable = lib.mkDefault true; + nvim-lint.enable = lib.mkDefault true; + }; +} diff --git a/config/languages/nvim-jdtls.nix b/config/languages/nvim-jdtls.nix index b3d4d0a..0742e7f 100644 --- a/config/languages/nvim-jdtls.nix +++ b/config/languages/nvim-jdtls.nix @@ -1,25 +1,32 @@ +{ lib, config, ... }: let javaTestPath = "/nix/store/j3nvmhvj2pmnykw5pbm51dn0bz4cv6j3-vscode-extension-vscjava-vscode-java-test-0.38.2023032402/share/vscode/extensions/vscjava.vscode-java-test/server/com.microsoft.java.test.plugin-0.38.2.jar "; -in { - plugins.nvim-jdtls = { - enable = true; - cmd = [ - "/nix/store/20h2hjjm94gbskqhbwikbgxbblv1xpf2-jdt-language-server-1.31.0/bin/jdtls" - ]; - # configuration = "/path/to/configuration"; - data = "~/.cache/jdtls/workspace"; - settings = { - java = { - signatureHelp = true; - completion = true; - }; - }; - initOptions = { - bundles = [ - "/nix/store/b9ib40q36wxjl4xs5lng263lflz1fsi7-vscode-extension-vscjava-vscode-java-debug-0.49.2023032407/share/vscode/extensions/vscjava.vscode-java-debug/server/com.microsoft.java.debug.plugin-0.44.0.jar" - "${javaTestPath}" +in +{ + options = { + nvim-jdtls.enable = lib.mkEnableOption "Enable nvim-jdtls module"; + }; + config = lib.mkIf config.nvim-jdtls.enable { + plugins.nvim-jdtls = { + enable = true; + cmd = [ + "/nix/store/20h2hjjm94gbskqhbwikbgxbblv1xpf2-jdt-language-server-1.31.0/bin/jdtls" ]; + # configuration = "/path/to/configuration"; + data = "~/.cache/jdtls/workspace"; + settings = { + java = { + signatureHelp = true; + completion = true; + }; + }; + initOptions = { + bundles = [ + "/nix/store/b9ib40q36wxjl4xs5lng263lflz1fsi7-vscode-extension-vscjava-vscode-java-debug-0.49.2023032407/share/vscode/extensions/vscjava.vscode-java-debug/server/com.microsoft.java.debug.plugin-0.44.0.jar" + "${javaTestPath}" + ]; + }; }; }; } @@ -78,4 +85,3 @@ in { # # jdtls.start_or_attach(config) # ''; - diff --git a/config/languages/nvim-lint.nix b/config/languages/nvim-lint.nix index 7428bbe..06633d0 100644 --- a/config/languages/nvim-lint.nix +++ b/config/languages/nvim-lint.nix @@ -1,21 +1,27 @@ +{ lib, config, ... }: { - plugins.lint = { - enable = true; - lintersByFt = { - c = [ "cpplint" ]; - cpp = [ "cpplint" ]; - go = [ "golangci-lint" ]; - nix = [ "statix" ]; - lua = [ "selene" ]; - python = [ "flake8" ]; - javascript = [ "eslint_d" ]; - javascriptreact = [ "eslint_d" ]; - typescript = [ "eslint_d" ]; - typescriptreact = [ "eslint_d" ]; - json = [ "jsonlint" ]; - java = [ "checkstyle" ]; - haskell = [ "hlint" ]; - bash = [ "shellcheck" ]; + options = { + nvim-lint.enable = lib.mkEnableOption "Enable nvim-lint module"; + }; + config = lib.mkIf config.nvim-lint.enable { + plugins.lint = { + enable = true; + lintersByFt = { + c = [ "cpplint" ]; + cpp = [ "cpplint" ]; + go = [ "golangci-lint" ]; + nix = [ "statix" ]; + lua = [ "selene" ]; + python = [ "flake8" ]; + javascript = [ "eslint_d" ]; + javascriptreact = [ "eslint_d" ]; + typescript = [ "eslint_d" ]; + typescriptreact = [ "eslint_d" ]; + json = [ "jsonlint" ]; + java = [ "checkstyle" ]; + haskell = [ "hlint" ]; + bash = [ "shellcheck" ]; + }; }; }; } diff --git a/config/languages/treesitter-nvim.nix b/config/languages/treesitter-nvim.nix new file mode 100644 index 0000000..cf6e471 --- /dev/null +++ b/config/languages/treesitter-nvim.nix @@ -0,0 +1,98 @@ +{ lib, config, ... }: +{ + options = { + treesitter-nvim.enable = lib.mkEnableOption "Enable treesitter-nvim module"; + }; + config = lib.mkIf config.treesitter-nvim.enable { + plugins.treesitter = { + enable = true; + settings = { + auto_install = true; + folding = { + enable = true; + }; + highlight = { + enable = true; + }; + indent = { + enable = true; + }; + autopairs = { + enable = true; + }; + incremental_selection = { + enable = true; + keymaps = { + init_selection = ""; + node_incremental = ""; + scope_incremental = false; + node_decremental = ""; + }; + }; + }; + nixvimInjections = true; + }; + + plugins.treesitter-textobjects = { + enable = true; + select = { + enable = true; + lookahead = true; + keymaps = { + "aa" = "@parameter.outer"; + "ia" = "@parameter.inner"; + "af" = "@function.outer"; + "if" = "@function.inner"; + "ac" = "@class.outer"; + "ic" = "@class.inner"; + "ii" = "@conditional.inner"; + "ai" = "@conditional.outer"; + "il" = "@loop.inner"; + "al" = "@loop.outer"; + "at" = "@comment.outer"; + }; + }; + move = { + enable = true; + gotoNextStart = { + "]m" = "@function.outer"; + "]]" = "@class.outer"; + }; + gotoNextEnd = { + "]M" = "@function.outer"; + "][" = "@class.outer"; + }; + gotoPreviousStart = { + "[m" = "@function.outer"; + "[[" = "@class.outer"; + }; + gotoPreviousEnd = { + "[M" = "@function.outer"; + "[]" = "@class.outer"; + }; + }; + swap = { + enable = true; + swapNext = { + "a" = "@parameters.inner"; + }; + swapPrevious = { + "A" = "@parameter.outer"; + }; + }; + }; + + plugins.ts-autotag = { + enable = true; + }; + + plugins.treesitter-context = { + enable = true; + }; + + plugins.ts-context-commentstring = { + enable = true; + disableAutoInitialization = false; + }; + }; +} diff --git a/config/languages/treesitter/treesitter-context.nix b/config/languages/treesitter/treesitter-context.nix deleted file mode 100644 index b588c8f..0000000 --- a/config/languages/treesitter/treesitter-context.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - plugins.treesitter-context = { - enable = true; - }; -} diff --git a/config/languages/treesitter/treesitter-textobjects.nix b/config/languages/treesitter/treesitter-textobjects.nix deleted file mode 100644 index 29820cf..0000000 --- a/config/languages/treesitter/treesitter-textobjects.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ - plugins.treesitter-textobjects = { - enable = false; - select = { - enable = true; - lookahead = true; - keymaps = { - "aa" = "@parameter.outer"; - "ia" = "@parameter.inner"; - "af" = "@function.outer"; - "if" = "@function.inner"; - "ac" = "@class.outer"; - "ic" = "@class.inner"; - "ii" = "@conditional.inner"; - "ai" = "@conditional.outer"; - "il" = "@loop.inner"; - "al" = "@loop.outer"; - "at" = "@comment.outer"; - }; - }; - move = { - enable = true; - gotoNextStart = { - "]m" = "@function.outer"; - "]]" = "@class.outer"; - }; - gotoNextEnd = { - "]M" = "@function.outer"; - "][" = "@class.outer"; - }; - gotoPreviousStart = { - "[m" = "@function.outer"; - "[[" = "@class.outer"; - }; - gotoPreviousEnd = { - "[M" = "@function.outer"; - "[]" = "@class.outer"; - }; - }; - swap = { - enable = true; - swapNext = { - "a" = "@parameters.inner"; - }; - swapPrevious = { - "A" = "@parameter.outer"; - }; - }; - }; -} diff --git a/config/languages/treesitter/treesitter.nix b/config/languages/treesitter/treesitter.nix deleted file mode 100644 index 4ad6af2..0000000 --- a/config/languages/treesitter/treesitter.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - plugins.treesitter = { - enable = true; - settings = { - indent = {enable = true;}; - }; - folding = true; - nixvimInjections = true; - }; -} diff --git a/config/languages/treesitter/ts-autotag.nix b/config/languages/treesitter/ts-autotag.nix deleted file mode 100644 index 9fa6d84..0000000 --- a/config/languages/treesitter/ts-autotag.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - plugins.ts-autotag = { - enable = true; - }; -} diff --git a/config/languages/treesitter/ts-context-commentstring.nix b/config/languages/treesitter/ts-context-commentstring.nix deleted file mode 100644 index aad1ce0..0000000 --- a/config/languages/treesitter/ts-context-commentstring.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - plugins.ts-context-commentstring = { - enable = true; - disableAutoInitialization = false; - }; -} From 50fdbc3a7c7c395198fdcc6b6db43c948be80736 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:00:12 -0300 Subject: [PATCH 08/20] refactor: make lsp dir modular --- config/lsp/conform.nix | 189 ++++++++++---------- config/lsp/default.nix | 25 +++ config/lsp/fidget.nix | 187 ++++++++++---------- config/lsp/lsp-nvim.nix | 247 +++++++++++++++++++++++++++ config/lsp/lsp.nix | 225 ------------------------ config/lsp/lspsaga.nix | 370 +++++++++++++++++++++------------------- config/lsp/trouble.nix | 102 +++++------ 7 files changed, 712 insertions(+), 633 deletions(-) create mode 100644 config/lsp/default.nix create mode 100644 config/lsp/lsp-nvim.nix delete mode 100644 config/lsp/lsp.nix diff --git a/config/lsp/conform.nix b/config/lsp/conform.nix index 044450d..e297433 100644 --- a/config/lsp/conform.nix +++ b/config/lsp/conform.nix @@ -1,100 +1,107 @@ +{ lib, config, ... }: { - plugins.conform-nvim = { - enable = true; - settings = { - notify_on_error = true; - # default_format_opts = { - # lsp_format = "fallback"; - # }; - # format_after_save = { - # lsp_format = "fallback"; - # }; - format_on_save = { - timeoutMs = 500; - lspFallback = true; - }; - formatters_by_ft = { - html = { - __unkeyed-1 = "prettierd"; - __unkeyed-2 = "prettier"; - stop_after_first = true; - }; - css = { - __unkeyed-1 = "prettierd"; - __unkeyed-2 = "prettier"; - stop_after_first = true; + options = { + conform.enable = lib.mkEnableOption "Enable conform module"; + }; + config = lib.mkIf config.conform.enable { + + plugins.conform-nvim = { + enable = true; + settings = { + notify_on_error = true; + # default_format_opts = { + # lsp_format = "fallback"; + # }; + # format_after_save = { + # lsp_format = "fallback"; + # }; + format_on_save = { + timeoutMs = 500; + lspFallback = true; }; - javascript = { - __unkeyed-1 = "prettierd"; - __unkeyed-2 = "prettier"; - stop_after_first = true; + formatters_by_ft = { + html = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + css = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + javascript = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + javascriptreact = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + typescript = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + typescriptreact = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + java = [ "google-java-format" ]; + python = [ "black" ]; + lua = [ "stylua" ]; + nix = [ "nixfmt" ]; + markdown = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + rust = [ "rustfmt" ]; }; - javascriptreact = { - __unkeyed-1 = "prettierd"; - __unkeyed-2 = "prettier"; - stop_after_first = true; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "uf"; + action = ":FormatToggle"; + options = { + desc = "Toggle Format Globally"; + silent = true; }; - typescript = { - __unkeyed-1 = "prettierd"; - __unkeyed-2 = "prettier"; - stop_after_first = true; + } + { + mode = "n"; + key = "uF"; + action = ":FormatToggle!"; + options = { + desc = "Toggle Format Locally"; + silent = true; }; - typescriptreact = { - __unkeyed-1 = "prettierd"; - __unkeyed-2 = "prettier"; - stop_after_first = true; + } + { + mode = "n"; + key = "cf"; + action = "lua require('conform').format()"; + options = { + silent = true; + desc = "Format Buffer"; }; - java = [ "google-java-format" ]; - python = [ "black" ]; - lua = [ "stylua" ]; - nix = [ "nixfmt" ]; - markdown = { - __unkeyed-1 = "prettierd"; - __unkeyed-2 = "prettier"; - stop_after_first = true; + } + + { + mode = "v"; + key = "cF"; + action = "lua require('conform').format()"; + options = { + silent = true; + desc = "Format Lines"; }; - rust = [ "rustfmt" ]; - }; - }; + } + ]; }; - - keymaps = [ - { - mode = "n"; - key = "uf"; - action = ":FormatToggle"; - options = { - desc = "Toggle Format Globally"; - silent = true; - }; - } - { - mode = "n"; - key = "uF"; - action = ":FormatToggle!"; - options = { - desc = "Toggle Format Locally"; - silent = true; - }; - } - { - mode = "n"; - key = "cf"; - action = "lua require('conform').format()"; - options = { - silent = true; - desc = "Format Buffer"; - }; - } - - { - mode = "v"; - key = "cF"; - action = "lua require('conform').format()"; - options = { - silent = true; - desc = "Format Lines"; - }; - } - ]; } diff --git a/config/lsp/default.nix b/config/lsp/default.nix new file mode 100644 index 0000000..9d3ad2e --- /dev/null +++ b/config/lsp/default.nix @@ -0,0 +1,25 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./conform.nix + ./fidget.nix + ./lsp-nvim.nix + ./lspsaga.nix + ./trouble.nix + ]; + + options = { + lsp.enable = lib.mkEnableOption "Enable lsp module"; + }; + config = lib.mkIf config.dap.enable { + conform.enable = lib.mkDefault true; + fidget.enable = lib.mkDefault true; + lsp-nvim.enable = lib.mkDefault true; + lspsaga.enable = lib.mkDefault true; + trouble.enable = lib.mkDefault true; + }; +} diff --git a/config/lsp/fidget.nix b/config/lsp/fidget.nix index 868f386..30184e0 100644 --- a/config/lsp/fidget.nix +++ b/config/lsp/fidget.nix @@ -1,98 +1,105 @@ +{ lib, config, ... }: { - plugins.fidget = { - enable = true; - logger = { - level = "warn"; # “off”, “error”, “warn”, “info”, “debug”, “trace” - floatPrecision = 0.01; # Limit the number of decimals displayed for floats - }; - progress = { - pollRate = 0; # How and when to poll for progress messages - suppressOnInsert = true; # Suppress new messages while in insert mode - ignoreDoneAlready = false; # Ignore new tasks that are already complete - ignoreEmptyMessage = false; # Ignore new tasks that don't contain a message - clearOnDetach = - # Clear notification group when LSP server detaches - '' - function(client_id) - local client = vim.lsp.get_client_by_id(client_id) - return client and client.name or nil - end - ''; - notificationGroup = - # How to get a progress message's notification group key - '' - function(msg) return msg.lsp_client.name end - ''; - ignore = []; # List of LSP servers to ignore - lsp = { - progressRingbufSize = 0; # Configure the nvim's LSP progress ring buffer size + options = { + fidget.enable = lib.mkEnableOption "Enable fidget module"; + }; + config = lib.mkIf config.fidget.enable { + + plugins.fidget = { + enable = true; + logger = { + level = "warn"; # “off”, “error”, “warn”, “info”, “debug”, “trace” + floatPrecision = 1.0e-2; # Limit the number of decimals displayed for floats }; - display = { - renderLimit = 16; # How many LSP messages to show at once - doneTtl = 3; # How long a message should persist after completion - doneIcon = "✔"; # Icon shown when all LSP progress tasks are complete - doneStyle = "Constant"; # Highlight group for completed LSP tasks - progressTtl = "math.huge"; # How long a message should persist when in progress - progressIcon = { - pattern = "dots"; - period = 1; - }; # Icon shown when LSP progress tasks are in progress - progressStyle = "WarningMsg"; # Highlight group for in-progress LSP tasks - groupStyle = "Title"; # Highlight group for group name (LSP server name) - iconStyle = "Question"; # Highlight group for group icons - priority = 30; # Ordering priority for LSP notification group - skipHistory = true; # Whether progress notifications should be omitted from history - formatMessage = '' - require ("fidget.progress.display").default_format_message - ''; # How to format a progress message - formatAnnote = '' - function (msg) return msg.title end - ''; # How to format a progress annotation - formatGroupName = '' - function (group) return tostring (group) end - ''; # How to format a progress notification group's name - overrides = { - rust_analyzer = { - name = "rust-analyzer"; - }; - }; # Override options from the default notification config + progress = { + pollRate = 0; # How and when to poll for progress messages + suppressOnInsert = true; # Suppress new messages while in insert mode + ignoreDoneAlready = false; # Ignore new tasks that are already complete + ignoreEmptyMessage = false; # Ignore new tasks that don't contain a message + clearOnDetach = + # Clear notification group when LSP server detaches + '' + function(client_id) + local client = vim.lsp.get_client_by_id(client_id) + return client and client.name or nil + end + ''; + notificationGroup = + # How to get a progress message's notification group key + '' + function(msg) return msg.lsp_client.name end + ''; + ignore = [ ]; # List of LSP servers to ignore + lsp = { + progressRingbufSize = 0; # Configure the nvim's LSP progress ring buffer size + }; + display = { + renderLimit = 16; # How many LSP messages to show at once + doneTtl = 3; # How long a message should persist after completion + doneIcon = "✔"; # Icon shown when all LSP progress tasks are complete + doneStyle = "Constant"; # Highlight group for completed LSP tasks + progressTtl = "math.huge"; # How long a message should persist when in progress + progressIcon = { + pattern = "dots"; + period = 1; + }; # Icon shown when LSP progress tasks are in progress + progressStyle = "WarningMsg"; # Highlight group for in-progress LSP tasks + groupStyle = "Title"; # Highlight group for group name (LSP server name) + iconStyle = "Question"; # Highlight group for group icons + priority = 30; # Ordering priority for LSP notification group + skipHistory = true; # Whether progress notifications should be omitted from history + formatMessage = '' + require ("fidget.progress.display").default_format_message + ''; # How to format a progress message + formatAnnote = '' + function (msg) return msg.title end + ''; # How to format a progress annotation + formatGroupName = '' + function (group) return tostring (group) end + ''; # How to format a progress notification group's name + overrides = { + rust_analyzer = { + name = "rust-analyzer"; + }; + }; # Override options from the default notification config + }; }; - }; - notification = { - pollRate = 10; # How frequently to update and render notifications - filter = "info"; # “off”, “error”, “warn”, “info”, “debug”, “trace” - historySize = 128; # Number of removed messages to retain in history - overrideVimNotify = true; - redirect = '' - function(msg, level, opts) - if opts and opts.on_open then - return require("fidget.integration.nvim-notify").delegate(msg, level, opts) + notification = { + pollRate = 10; # How frequently to update and render notifications + filter = "info"; # “off”, “error”, “warn”, “info”, “debug”, “trace” + historySize = 128; # Number of removed messages to retain in history + overrideVimNotify = true; + redirect = '' + function(msg, level, opts) + if opts and opts.on_open then + return require("fidget.integration.nvim-notify").delegate(msg, level, opts) + end end - end - ''; - configs = { - default = "require('fidget.notification').default_config"; - }; + ''; + configs = { + default = "require('fidget.notification').default_config"; + }; - window = { - normalHl = "Comment"; - winblend = 0; - border = "none"; # none, single, double, rounded, solid, shadow - zindex = 45; - maxWidth = 0; - maxHeight = 0; - xPadding = 1; - yPadding = 0; - align = "bottom"; - relative = "editor"; - }; - view = { - stackUpwards = true; # Display notification items from bottom to top - iconSeparator = " "; # Separator between group name and icon - groupSeparator = "---"; # Separator between notification groups - groupSeparatorHl = - # Highlight group used for group separator - "Comment"; + window = { + normalHl = "Comment"; + winblend = 0; + border = "none"; # none, single, double, rounded, solid, shadow + zindex = 45; + maxWidth = 0; + maxHeight = 0; + xPadding = 1; + yPadding = 0; + align = "bottom"; + relative = "editor"; + }; + view = { + stackUpwards = true; # Display notification items from bottom to top + iconSeparator = " "; # Separator between group name and icon + groupSeparator = "---"; # Separator between notification groups + groupSeparatorHl = + # Highlight group used for group separator + "Comment"; + }; }; }; }; diff --git a/config/lsp/lsp-nvim.nix b/config/lsp/lsp-nvim.nix new file mode 100644 index 0000000..ed9e7b6 --- /dev/null +++ b/config/lsp/lsp-nvim.nix @@ -0,0 +1,247 @@ +{ lib, config, ... }: +{ + options = { + lsp-nvim.enable = lib.mkEnableOption "Enable lsp-nvim module"; + }; + config = lib.mkIf config.lsp-nvim.enable { + plugins = { + lsp-format = { + enable = false; # Enable it if you want lsp-format integration for none-ls + }; + lsp = { + enable = true; + capabilities = "offsetEncoding = 'utf-16'"; + servers = { + clangd = { + enable = true; + }; + lua_ls = { + enable = true; + extraOptions = { + settings = { + Lua = { + completion = { + callSnippet = "Replace"; + }; + diagnostics = { + globals = [ "vim" ]; + }; + + telemetry = { + enabled = false; + }; + hint = { + enable = true; + }; + }; + }; + }; + }; + nil_ls = { + enable = false; + }; + nixd = { + enable = true; + }; + ts_ls = { + enable = true; + autostart = true; + filetypes = [ + "javascript" + "javascriptreact" + "typescript" + "typescriptreact" + ]; + extraOptions = { + settings = { + javascript = { + inlayHints = { + includeInlayEnumMemberValueHints = true; + includeInlayFunctionLikeReturnTypeHints = true; + includeInlayFunctionParameterTypeHints = true; + includeInlayParameterNameHints = "all"; + includeInlayParameterNameHintsWhenArgumentMatchesName = true; + includeInlayPropertyDeclarationTypeHints = true; + includeInlayVariableTypeHints = true; + includeInlayVariableTypeHintsWhenTypeMatchesName = true; + }; + }; + typescript = { + inlayHints = { + includeInlayEnumMemberValueHints = true; + includeInlayFunctionLikeReturnTypeHints = true; + includeInlayFunctionParameterTypeHints = true; + includeInlayParameterNameHints = "all"; + includeInlayParameterNameHintsWhenArgumentMatchesName = true; + includeInlayPropertyDeclarationTypeHints = true; + includeInlayVariableTypeHints = true; + includeInlayVariableTypeHintsWhenTypeMatchesName = true; + }; + }; + }; + }; + }; + eslint = { + enable = true; + }; + pyright = { + enable = true; + }; + ruff_lsp = { + enable = true; + }; + + rust_analyzer = { + enable = true; + installCargo = true; + installRustc = true; + settings = { + checkOnSave = true; + check = { + command = "clippy"; + }; + # inlayHints = { + # enable = true; + # showParameterNames = true; + # parameterHintsPrefix = "<- "; + # otherHintsPrefix = "=> "; + # }; + procMacro = { + enable = true; + }; + }; + }; + }; + keymaps = { + silent = true; + lspBuf = { + gd = { + action = "definition"; + desc = "Goto Definition"; + }; + gr = { + action = "references"; + desc = "Goto References"; + }; + gD = { + action = "declaration"; + desc = "Goto Declaration"; + }; + gI = { + action = "implementation"; + desc = "Goto Implementation"; + }; + gT = { + action = "type_definition"; + desc = "Type Definition"; + }; + K = { + action = "hover"; + desc = "Hover"; + }; + "cw" = { + action = "workspace_symbol"; + desc = "Workspace Symbol"; + }; + "cr" = { + action = "rename"; + desc = "Rename"; + }; + "ca" = { + action = "code_action"; + desc = "Code Action"; + }; + "" = { + action = "signature_help"; + desc = "Signature Help"; + }; + }; + diagnostic = { + "cd" = { + action = "open_float"; + desc = "Line Diagnostics"; + }; + "[d" = { + action = "goto_next"; + desc = "Next Diagnostic"; + }; + "]d" = { + action = "goto_prev"; + desc = "Previous Diagnostic"; + }; + }; + }; + onAttach = '' + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(false) + end + vim.bo[args.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + end, + }) + ''; + }; + }; + extraConfigLua = '' + local _border = "rounded" + + require('lspconfig.ui.windows').default_options = { + border = _border + } + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( + vim.lsp.handlers.hover, { + border = _border + } + ) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( + vim.lsp.handlers.signature_help, { + border = _border + } + ) + + vim.diagnostic.config({ + float = { border = "rounded" }, + virtual_text = { + prefix = "", + }, + signs = true, + underline = true, + update_in_insert = true, + }) + + -- vim.api.nvim_create_autocmd("LspAttach", { + -- group = vim.api.nvim_create_augroup("UserLspConfig", {}), + -- callback = function(args) + -- local client = vim.lsp.get_client_by_id(args.data.client_id) + -- if client.server_capabilities.inlayHintProvider then + -- vim.lsp.inlay_hint.enable(false) + -- end + -- vim.bo[args.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + -- + -- local opts = { buffer = args.buf } + -- vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + -- vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + -- vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + -- vim.keymap.set("n", "gI", vim.lsp.buf.implementation, opts) + -- vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, opts) + -- vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + -- vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) + -- vim.keymap.set("n", "cw", vim.lsp.buf.workspace_symbol, opts) + -- vim.keymap.set("n", "cr", vim.lsp.buf.rename, opts) + -- vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + -- vim.keymap.set("n", "cf", function() + -- vim.lsp.buf.format({ async = true }) + -- end, opts) + -- vim.keymap.set("n", "cd", vim.diagnostic.open_float, opts) + -- vim.keymap.set("n", "[d", vim.diagnostic.goto_next, opts) + -- vim.keymap.set("n", "]d", vim.diagnostic.goto_prev, opts) + -- end, + -- }) + ''; + }; +} diff --git a/config/lsp/lsp.nix b/config/lsp/lsp.nix deleted file mode 100644 index 32f81b2..0000000 --- a/config/lsp/lsp.nix +++ /dev/null @@ -1,225 +0,0 @@ -{ - plugins = { - lsp-format = { - enable = false; # Enable it if you want lsp-format integration for none-ls - }; - lsp = { - enable = true; - capabilities = "offsetEncoding = 'utf-16'"; - servers = { - clangd = { - enable = true; - }; - lua_ls = { - enable = true; - extraOptions = { - settings = { - Lua = { - completion = { - callSnippet = "Replace"; - }; - telemetry = { - enabled = false; - }; - hint = { - enable = true; - }; - }; - }; - }; - }; - nil_ls = { - enable = false; - }; - nixd = { - enable = true; - }; - ts_ls = { - enable = true; - autostart = true; - filetypes = [ - "javascript" - "javascriptreact" - "typescript" - "typescriptreact" - ]; - extraOptions = { - settings = { - javascript = { - inlayHints = { - includeInlayEnumMemberValueHints = true; - includeInlayFunctionLikeReturnTypeHints = true; - includeInlayFunctionParameterTypeHints = true; - includeInlayParameterNameHints = "all"; - includeInlayParameterNameHintsWhenArgumentMatchesName = true; - includeInlayPropertyDeclarationTypeHints = true; - includeInlayVariableTypeHints = true; - includeInlayVariableTypeHintsWhenTypeMatchesName = true; - }; - }; - typescript = { - inlayHints = { - includeInlayEnumMemberValueHints = true; - includeInlayFunctionLikeReturnTypeHints = true; - includeInlayFunctionParameterTypeHints = true; - includeInlayParameterNameHints = "all"; - includeInlayParameterNameHintsWhenArgumentMatchesName = true; - includeInlayPropertyDeclarationTypeHints = true; - includeInlayVariableTypeHints = true; - includeInlayVariableTypeHintsWhenTypeMatchesName = true; - }; - }; - }; - }; - }; - eslint = { - enable = true; - }; - pyright = { - enable = true; - }; - ruff_lsp = { - enable = true; - }; - - rust_analyzer = { - enable = true; - installCargo = true; - installRustc = true; - settings = { - checkOnSave = true; - check = { - command = "clippy"; - }; - # inlayHints = { - # enable = true; - # showParameterNames = true; - # parameterHintsPrefix = "<- "; - # otherHintsPrefix = "=> "; - # }; - procMacro = { - enable = true; - }; - }; - }; - }; - # keymaps = { - # silent = true; - # lspBuf = { - # gd = { - # action = "definition"; - # desc = "Goto Definition"; - # }; - # gr = { - # action = "references"; - # desc = "Goto References"; - # }; - # gD = { - # action = "declaration"; - # desc = "Goto Declaration"; - # }; - # gI = { - # action = "implementation"; - # desc = "Goto Implementation"; - # }; - # gT = { - # action = "type_definition"; - # desc = "Type Definition"; - # }; - # K = { - # action = "hover"; - # desc = "Hover"; - # }; - # "cw" = { - # action = "workspace_symbol"; - # desc = "Workspace Symbol"; - # }; - # "cr" = { - # action = "rename"; - # desc = "Rename"; - # }; - # "ca" = { - # action = "code_action"; - # desc = "Code Action"; - # }; - # "" = { - # action = "signature_help"; - # desc = "Signature Help"; - # }; - # }; - # diagnostic = { - # "cd" = { - # action = "open_float"; - # desc = "Line Diagnostics"; - # }; - # "[d" = { - # action = "goto_next"; - # desc = "Next Diagnostic"; - # }; - # "]d" = { - # action = "goto_prev"; - # desc = "Previous Diagnostic"; - # }; - # }; - # }; - }; - }; - extraConfigLua = '' - local _border = "rounded" - - require('lspconfig.ui.windows').default_options = { - border = _border - } - - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( - vim.lsp.handlers.hover, { - border = _border - } - ) - - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( - vim.lsp.handlers.signature_help, { - border = _border - } - ) - - vim.diagnostic.config({ - float = { border = "rounded" }, - virtual_text = { - prefix = "", - }, - signs = true, - underline = true, - update_in_insert = true, - }) - - vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("UserLspConfig", {}), - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - if client.server_capabilities.inlayHintProvider then - vim.lsp.inlay_hint.enable(false) - end - vim.bo[args.buf].omnifunc = "v:lua.vim.lsp.omnifunc" - - local opts = { buffer = args.buf } - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) - vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - vim.keymap.set("n", "gI", vim.lsp.buf.implementation, opts) - vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, opts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) - vim.keymap.set("n", "cw", vim.lsp.buf.workspace_symbol, opts) - vim.keymap.set("n", "cr", vim.lsp.buf.rename, opts) - vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) - vim.keymap.set("n", "cf", function() - vim.lsp.buf.format({ async = true }) - end, opts) - vim.keymap.set("n", "cd", vim.diagnostic.open_float, opts) - vim.keymap.set("n", "[d", vim.diagnostic.goto_next, opts) - vim.keymap.set("n", "]d", vim.diagnostic.goto_prev, opts) - end, - }) - ''; -} diff --git a/config/lsp/lspsaga.nix b/config/lsp/lspsaga.nix index 42de7fb..9a85eac 100644 --- a/config/lsp/lspsaga.nix +++ b/config/lsp/lspsaga.nix @@ -1,186 +1,198 @@ +{ lib, config, ... }: { - plugins.lspsaga = { - enable = false; - beacon = { - enable = true; - }; - ui = { - border = "rounded"; # One of none, single, double, rounded, solid, shadow - codeAction = "💡"; # Can be any symbol you want 💡 - }; - hover = { - openCmd = "!floorp"; # Choose your browser - openLink = "gx"; - }; - diagnostic = { - borderFollow = true; - diagnosticOnlyCurrent = false; - showCodeAction = true; - }; - symbolInWinbar = { - enable = true; # Breadcrumbs - }; - codeAction = { - extendGitSigns = false; - showServerName = true; - onlyInCursor = true; - numShortcut = true; - keys = { - exec = ""; - quit = ["" "q"]; - }; - }; - lightbulb = { - enable = false; - sign = false; - virtualText = true; - }; - implement = { + options = { + lspsaga.enable = lib.mkEnableOption "Enable lspsaga module"; + }; + config = lib.mkIf config.lspsaga.enable { + plugins.lspsaga = { enable = false; - }; - rename = { - autoSave = false; - keys = { - exec = ""; - quit = ["" ""]; - select = "x"; + beacon = { + enable = true; }; - }; - outline = { - autoClose = true; - autoPreview = true; - closeAfterJump = true; - layout = "normal"; # normal or float - winPosition = "right"; # left or right - keys = { - jump = "e"; - quit = "q"; - toggleOrJump = "o"; + ui = { + border = "rounded"; # One of none, single, double, rounded, solid, shadow + codeAction = "💡"; # Can be any symbol you want 💡 + }; + hover = { + openCmd = "!floorp"; # Choose your browser + openLink = "gx"; + }; + diagnostic = { + borderFollow = true; + diagnosticOnlyCurrent = false; + showCodeAction = true; + }; + symbolInWinbar = { + enable = true; # Breadcrumbs + }; + codeAction = { + extendGitSigns = false; + showServerName = true; + onlyInCursor = true; + numShortcut = true; + keys = { + exec = ""; + quit = [ + "" + "q" + ]; + }; + }; + lightbulb = { + enable = false; + sign = false; + virtualText = true; + }; + implement = { + enable = false; + }; + rename = { + autoSave = false; + keys = { + exec = ""; + quit = [ + "" + "" + ]; + select = "x"; + }; + }; + outline = { + autoClose = true; + autoPreview = true; + closeAfterJump = true; + layout = "normal"; # normal or float + winPosition = "right"; # left or right + keys = { + jump = "e"; + quit = "q"; + toggleOrJump = "o"; + }; + }; + scrollPreview = { + scrollDown = ""; + scrollUp = ""; }; }; - scrollPreview = { - scrollDown = ""; - scrollUp = ""; - }; + # keymaps = [ + # { + # mode = "n"; + # key = "gd"; + # action = "Lspsaga finder def"; + # options = { + # desc = "Goto Definition"; + # silent = true; + # }; + # } + # { + # mode = "n"; + # key = "gr"; + # action = "Lspsaga finder ref"; + # options = { + # desc = "Goto References"; + # silent = true; + # }; + # } + # + # # { + # # mode = "n"; + # # key = "gD"; + # # action = "Lspsaga show_line_diagnostics"; + # # options = { + # # desc = "Goto Declaration"; + # # silent = true; + # # }; + # # } + # + # { + # mode = "n"; + # key = "gI"; + # action = "Lspsaga finder imp"; + # options = { + # desc = "Goto Implementation"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "gT"; + # action = "Lspsaga peek_type_definition"; + # options = { + # desc = "Type Definition"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "K"; + # action = "Lspsaga hover_doc"; + # options = { + # desc = "Hover"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "cw"; + # action = "Lspsaga outline"; + # options = { + # desc = "Outline"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "cr"; + # action = "Lspsaga rename"; + # options = { + # desc = "Rename"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "ca"; + # action = "Lspsaga code_action"; + # options = { + # desc = "Code Action"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "cd"; + # action = "Lspsaga show_line_diagnostics"; + # options = { + # desc = "Line Diagnostics"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "[d"; + # action = "Lspsaga diagnostic_jump_next"; + # options = { + # desc = "Next Diagnostic"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "]d"; + # action = "Lspsaga diagnostic_jump_prev"; + # options = { + # desc = "Previous Diagnostic"; + # silent = true; + # }; + # } + # ]; }; - # keymaps = [ - # { - # mode = "n"; - # key = "gd"; - # action = "Lspsaga finder def"; - # options = { - # desc = "Goto Definition"; - # silent = true; - # }; - # } - # { - # mode = "n"; - # key = "gr"; - # action = "Lspsaga finder ref"; - # options = { - # desc = "Goto References"; - # silent = true; - # }; - # } - # - # # { - # # mode = "n"; - # # key = "gD"; - # # action = "Lspsaga show_line_diagnostics"; - # # options = { - # # desc = "Goto Declaration"; - # # silent = true; - # # }; - # # } - # - # { - # mode = "n"; - # key = "gI"; - # action = "Lspsaga finder imp"; - # options = { - # desc = "Goto Implementation"; - # silent = true; - # }; - # } - # - # { - # mode = "n"; - # key = "gT"; - # action = "Lspsaga peek_type_definition"; - # options = { - # desc = "Type Definition"; - # silent = true; - # }; - # } - # - # { - # mode = "n"; - # key = "K"; - # action = "Lspsaga hover_doc"; - # options = { - # desc = "Hover"; - # silent = true; - # }; - # } - # - # { - # mode = "n"; - # key = "cw"; - # action = "Lspsaga outline"; - # options = { - # desc = "Outline"; - # silent = true; - # }; - # } - # - # { - # mode = "n"; - # key = "cr"; - # action = "Lspsaga rename"; - # options = { - # desc = "Rename"; - # silent = true; - # }; - # } - # - # { - # mode = "n"; - # key = "ca"; - # action = "Lspsaga code_action"; - # options = { - # desc = "Code Action"; - # silent = true; - # }; - # } - # - # { - # mode = "n"; - # key = "cd"; - # action = "Lspsaga show_line_diagnostics"; - # options = { - # desc = "Line Diagnostics"; - # silent = true; - # }; - # } - # - # { - # mode = "n"; - # key = "[d"; - # action = "Lspsaga diagnostic_jump_next"; - # options = { - # desc = "Next Diagnostic"; - # silent = true; - # }; - # } - # - # { - # mode = "n"; - # key = "]d"; - # action = "Lspsaga diagnostic_jump_prev"; - # options = { - # desc = "Previous Diagnostic"; - # silent = true; - # }; - # } - # ]; } diff --git a/config/lsp/trouble.nix b/config/lsp/trouble.nix index 783aa08..0973b5e 100644 --- a/config/lsp/trouble.nix +++ b/config/lsp/trouble.nix @@ -1,52 +1,58 @@ +{ lib, config, ... }: { - plugins.trouble = { - enable = true; - settings = { - auto_close = true; - }; + options = { + trouble.enable = lib.mkEnableOption "Enable trouble module"; }; - # TODO: Add keybinds to close trouble (q would be nice), rn I need to use :x to close it... - keymaps = [ - { - mode = "n"; - key = "x"; - action = "+diagnostics/quickfix"; - } - { - mode = "n"; - key = "xx"; - action = "TroubleToggle"; - options = { - silent = true; - desc = "Document Diagnostics (Trouble)"; - }; - } - { - mode = "n"; - key = "xX"; - action = "TroubleToggle workspace_diagnostics"; - options = { - silent = true; - desc = "Workspace Diagnostics (Trouble)"; - }; - } - { - mode = "n"; - key = "xt"; - action = "TroubleToggle todo"; - options = { - silent = true; - desc = "Todo (Trouble)"; + config = lib.mkIf config.trouble.enable { + plugins.trouble = { + enable = true; + settings = { + auto_close = true; }; - } - { - mode = "n"; - key = "xQ"; - action = "TodoQuickFix"; - options = { - silent = true; - desc = "Quickfix List (Trouble)"; - }; - } - ]; + }; + # TODO: Add keybinds to close trouble (q would be nice), rn I need to use :x to close it... + keymaps = [ + { + mode = "n"; + key = "x"; + action = "+diagnostics/quickfix"; + } + { + mode = "n"; + key = "xx"; + action = "Trouble diagnostics toggle"; + options = { + silent = true; + desc = "Diagnostics (Trouble)"; + }; + } + { + mode = "n"; + key = "xX"; + action = "Trouble diagnostics toggle filter.buf=0"; + options = { + silent = true; + desc = "Buffer Diagnostics (Trouble)"; + }; + } + { + mode = "n"; + key = "xt"; + action = "Trouble todo"; + options = { + silent = true; + desc = "Todo (Trouble)"; + }; + } + { + mode = "n"; + key = "xQ"; + action = "Trouble qflist toggle"; + options = { + silent = true; + desc = "Quickfix List (Trouble)"; + }; + } + ]; + }; } From 615fdccebfd3df6b17a012082480681dab0a662f Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:00:19 -0300 Subject: [PATCH 09/20] refactor: make none-ls modular --- config/none-ls/default.nix | 17 +++++++ config/none-ls/none-ls-nvim.nix | 84 +++++++++++++++++++++++++++++++++ config/none-ls/none-ls.nix | 78 ------------------------------ 3 files changed, 101 insertions(+), 78 deletions(-) create mode 100644 config/none-ls/default.nix create mode 100644 config/none-ls/none-ls-nvim.nix delete mode 100644 config/none-ls/none-ls.nix diff --git a/config/none-ls/default.nix b/config/none-ls/default.nix new file mode 100644 index 0000000..57e313f --- /dev/null +++ b/config/none-ls/default.nix @@ -0,0 +1,17 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./none-ls-nvim.nix + ]; + + options = { + none-ls.enable = lib.mkEnableOption "Enable none-ls module"; + }; + config = lib.mkIf config.none-ls.enable { + none-ls-nvim.enable = lib.mkDefault true; + }; +} diff --git a/config/none-ls/none-ls-nvim.nix b/config/none-ls/none-ls-nvim.nix new file mode 100644 index 0000000..61208df --- /dev/null +++ b/config/none-ls/none-ls-nvim.nix @@ -0,0 +1,84 @@ +{ lib, config, ... }: +{ + options = { + none-ls-nvim.enable = lib.mkEnableOption "Enable none-ls-nvim module"; + }; + config = lib.mkIf config.none-ls-nvim.enable { + plugins.none-ls = { + enable = false; + settings = { + enableLspFormat = false; + updateInInsert = false; + onAttach = '' + function(client, bufnr) + if client.supports_method "textDocument/formatting" then + vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr } + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format { bufnr = bufnr } + end, + }) + end + end + ''; + }; + sources = { + code_actions = { + gitsigns.enable = true; + statix.enable = true; + }; + diagnostics = { + checkstyle = { + enable = true; + }; + statix = { + enable = true; + }; + }; + formatting = { + alejandra = { + enable = false; + }; + nixfmt = { + enable = true; + }; + prettier = { + enable = true; + settings = '' + { + extra_args = { "--no-semi", "--single-quote" }, + } + ''; + }; + google_java_format = { + enable = true; + }; + stylua = { + enable = true; + }; + black = { + enable = true; + settings = '' + { + extra_args = { "--fast" }, + } + ''; + }; + }; + }; + }; + # keymaps = [ + # { + # mode = [ "n" "v" ]; + # key = "cf"; + # action = "lua vim.lsp.buf.format()"; + # options = { + # silent = true; + # desc = "Format"; + # }; + # } + # ]; + }; +} diff --git a/config/none-ls/none-ls.nix b/config/none-ls/none-ls.nix deleted file mode 100644 index 05172cc..0000000 --- a/config/none-ls/none-ls.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ - plugins.none-ls = { - enable = false; - settings = { - enableLspFormat = false; - updateInInsert = false; - onAttach = '' - function(client, bufnr) - if client.supports_method "textDocument/formatting" then - vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr } - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format { bufnr = bufnr } - end, - }) - end - end - ''; - }; - sources = { - code_actions = { - gitsigns.enable = true; - statix.enable = true; - }; - diagnostics = { - checkstyle = { - enable = true; - }; - statix = { - enable = true; - }; - }; - formatting = { - alejandra = { - enable = false; - }; - nixfmt = { - enable = true; - }; - prettier = { - enable = true; - settings = '' - { - extra_args = { "--no-semi", "--single-quote" }, - } - ''; - }; - google_java_format = { - enable = true; - }; - stylua = { - enable = true; - }; - black = { - enable = true; - settings = '' - { - extra_args = { "--fast" }, - } - ''; - }; - }; - }; - }; - # keymaps = [ - # { - # mode = [ "n" "v" ]; - # key = "cf"; - # action = "lua vim.lsp.buf.format()"; - # options = { - # silent = true; - # desc = "Format"; - # }; - # } - # ]; -} From adab5d2f4b0cb9ab24eca54e41e6cc200ba15ab1 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:00:29 -0300 Subject: [PATCH 10/20] refactor: make pluginmanagers modular --- config/pluginmanagers/default.nix | 17 +++++++++++++++++ config/pluginmanagers/lazy-nvim.nix | 15 +++++++++++++++ config/pluginmanagers/lazy.nix | 5 ----- 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 config/pluginmanagers/default.nix create mode 100644 config/pluginmanagers/lazy-nvim.nix delete mode 100644 config/pluginmanagers/lazy.nix diff --git a/config/pluginmanagers/default.nix b/config/pluginmanagers/default.nix new file mode 100644 index 0000000..4ff522a --- /dev/null +++ b/config/pluginmanagers/default.nix @@ -0,0 +1,17 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./lazy-nvim.nix + ]; + + options = { + pluginmanagers.enable = lib.mkEnableOption "Enable pluginmanagers module"; + }; + config = lib.mkIf config.pluginmanagers.enable { + lazy-nvim.enable = lib.mkDefault true; + }; +} diff --git a/config/pluginmanagers/lazy-nvim.nix b/config/pluginmanagers/lazy-nvim.nix new file mode 100644 index 0000000..3218591 --- /dev/null +++ b/config/pluginmanagers/lazy-nvim.nix @@ -0,0 +1,15 @@ +{ + lib, + config, + ... +}: +{ + options = { + lazy-nvim.enable = lib.mkEnableOption "Enable lazy-nvim module"; + }; + config = lib.mkIf config.lazy-nvim.enable { + plugins.lazy = { + enable = true; + }; + }; +} diff --git a/config/pluginmanagers/lazy.nix b/config/pluginmanagers/lazy.nix deleted file mode 100644 index 0c0d098..0000000 --- a/config/pluginmanagers/lazy.nix +++ /dev/null @@ -1,5 +0,0 @@ -{pkgs, ...}: { - plugins.lazy = { - enable = true; - }; -} From 1790045c5fe531e8c3d28ce5c117ca1777681b4e Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:00:54 -0300 Subject: [PATCH 11/20] refactor: create own dir for sets + modularize it --- config/sets/default.nix | 17 +++++ config/sets/set.nix | 149 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 config/sets/default.nix create mode 100644 config/sets/set.nix diff --git a/config/sets/default.nix b/config/sets/default.nix new file mode 100644 index 0000000..5b7e6a9 --- /dev/null +++ b/config/sets/default.nix @@ -0,0 +1,17 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./set.nix + ]; + + options = { + sets.enable = lib.mkEnableOption "Enable sets module"; + }; + config = lib.mkIf config.utils.enable { + set.enable = lib.mkDefault true; + }; +} diff --git a/config/sets/set.nix b/config/sets/set.nix new file mode 100644 index 0000000..0e4f726 --- /dev/null +++ b/config/sets/set.nix @@ -0,0 +1,149 @@ +{ + lib, + config, + ... +}: +{ + options = { + set.enable = lib.mkEnableOption "Enable set module"; + }; + config = lib.mkIf config.set.enable { + opts = { + # Enable relative line numbers + number = true; + relativenumber = true; + + # Set tabs to 2 spaces + tabstop = 2; + softtabstop = 2; + showtabline = 2; + expandtab = true; + + # Enable auto indenting and set it to spaces + smartindent = true; + shiftwidth = 2; + + # Enable smart indenting (see https://stackoverflow.com/questions/1204149/smart-wrap-in-vim) + breakindent = true; + + # Enable incremental searching + hlsearch = true; + incsearch = true; + + # Enable text wrap + wrap = true; + + # Better splitting + splitbelow = true; + splitright = true; + + # Enable mouse mode + mouse = "a"; # Mouse + + # Enable ignorecase + smartcase for better searching + ignorecase = true; + smartcase = true; # Don't ignore case with capitals + grepprg = "rg --vimgrep"; + grepformat = "%f:%l:%c:%m"; + + # Decrease updatetime + updatetime = 50; # faster completion (4000ms default) + + # Set completeopt to have a better completion experience + completeopt = [ + "menuone" + "noselect" + "noinsert" + ]; # mostly just for cmp + + # Enable persistent undo history + swapfile = false; + backup = false; + undofile = true; + + # Enable 24-bit colors + termguicolors = true; + + # Enable the sign column to prevent the screen from jumping + signcolumn = "yes"; + + # Enable cursor line highlight + cursorline = false; # Highlight the line where the cursor is located + + # Set fold settings + # These options were reccommended by nvim-ufo + # See: https://github.com/kevinhwang91/nvim-ufo#minimal-configuration + foldcolumn = "0"; + foldlevel = 99; + foldlevelstart = 99; + foldenable = true; + foldmethod = "expr"; + foldexpr = "v:lua.vim.treesitter.foldexpr()"; + + # Always keep 8 lines above/below cursor unless at start/end of file + scrolloff = 8; + + # Place a column line + colorcolumn = "80"; + + # Reduce which-key timeout + timeoutlen = 200; + + # Set encoding type + encoding = "utf-8"; + fileencoding = "utf-8"; + + # Change cursor options + guicursor = [ + "n-v-c:block" # Normal, visual, command-line: block cursor + "i-ci-ve:block" # Insert, command-line insert, visual-exclude: vertical bar cursor with block cursor, use "ver25" for 25% width + "r-cr:hor20" # Replace, command-line replace: horizontal bar cursor with 20% height + "o:hor50" # Operator-pending: horizontal bar cursor with 50% height + "a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor" # All modes: blinking settings + "sm:block-blinkwait175-blinkoff150-blinkon175" # Showmatch: block cursor with specific blinking settings + ]; + + # Enable chars list + list = true; # Show invisible characters (tabs, eol, ...) + listchars = "eol:↲,tab:|->,lead:·,space: ,trail:•,extends:→,precedes:←,nbsp:␣"; + + # More space in the neovim command line for displaying messages + cmdheight = 2; + + # We don't need to see things like INSERT anymore + showmode = false; + + # Maximum number of items to show in the popup menu (0 means "use available screen space") + pumheight = 0; + + # Use conform-nvim for gq formatting. ('formatexpr' is set to vim.lsp.formatexpr(), so you can format lines via gq if the language server supports it) + formatexpr = "v:lua.require'conform'.formatexpr()"; + + laststatus = 3; # (https://neovim.io/doc/user/options.html#'laststatus') + + inccommand = "split"; # (https://neovim.io/doc/user/options.html#'inccommand') + }; + + extraConfigLua = '' + local opt = vim.opt + local g = vim.g + local o = vim.o + -- Neovide + if g.neovide then + g.neovide_fullscreen = false + g.neovide_hide_mouse_when_typing = false + g.neovide_refresh_rate = 165 + g.neovide_cursor_vfx_mode = "ripple" + g.neovide_cursor_animate_command_line = true + g.neovide_cursor_animate_in_insert_mode = true + g.neovide_cursor_vfx_particle_lifetime = 5.0 + g.neovide_cursor_vfx_particle_density = 14.0 + g.neovide_cursor_vfx_particle_speed = 12.0 + g.neovide_transparency = 0.8 + + -- Neovide Fonts + o.guifont = "JetBrainsMono Nerd Font:h14:Medium:i" + end + ''; + }; +} From b72d6ae0e27a6f98e19847a88a843966f72388b3 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:01:06 -0300 Subject: [PATCH 12/20] refactor: make snippets dir modular --- config/snippets/default.nix | 17 +++++++++++++++++ config/snippets/luasnip.nix | 35 +++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 config/snippets/default.nix diff --git a/config/snippets/default.nix b/config/snippets/default.nix new file mode 100644 index 0000000..956df7d --- /dev/null +++ b/config/snippets/default.nix @@ -0,0 +1,17 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./luasnip.nix + ]; + + options = { + snippets.enable = lib.mkEnableOption "Enable snippets module"; + }; + config = lib.mkIf config.snippets.enable { + luasnip.enable = lib.mkDefault true; + }; +} diff --git a/config/snippets/luasnip.nix b/config/snippets/luasnip.nix index 2efb62d..ec4286e 100644 --- a/config/snippets/luasnip.nix +++ b/config/snippets/luasnip.nix @@ -1,15 +1,26 @@ -{pkgs, ...}: { - plugins.luasnip = { - enable = true; - settings = { - enable_autosnippets = true; - store_selection_keys = ""; +{ + lib, + config, + pkgs, + ... +}: +{ + options = { + luasnip.enable = lib.mkEnableOption "Enable luasnip module"; + }; + config = lib.mkIf config.luasnip.enable { + plugins.luasnip = { + enable = true; + settings = { + enable_autosnippets = true; + store_selection_keys = ""; + }; + fromVscode = [ + { + lazyLoad = true; + paths = "${pkgs.vimPlugins.friendly-snippets}"; + } + ]; }; - fromVscode = [ - { - lazyLoad = true; - paths = "${pkgs.vimPlugins.friendly-snippets}"; - } - ]; }; } From 8a208b42e3a2ab8eef1b0ca4491208cf6786955c Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:01:13 -0300 Subject: [PATCH 13/20] refactor: make statusline modular --- config/statusline/default.nix | 19 +++++ config/statusline/lualine.nix | 138 +++++++++++++++++++++++++-------- config/statusline/staline.nix | 139 ++++++++++++++++++---------------- 3 files changed, 201 insertions(+), 95 deletions(-) create mode 100644 config/statusline/default.nix diff --git a/config/statusline/default.nix b/config/statusline/default.nix new file mode 100644 index 0000000..c1897c3 --- /dev/null +++ b/config/statusline/default.nix @@ -0,0 +1,19 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./lualine.nix + ./staline.nix + ]; + + options = { + statusline.enable = lib.mkEnableOption "Enable statusline module"; + }; + config = lib.mkIf config.dap.enable { + lualine.enable = lib.mkDefault true; + staline.enable = lib.mkDefault false; + }; +} diff --git a/config/statusline/lualine.nix b/config/statusline/lualine.nix index 2636f10..427b5c1 100644 --- a/config/statusline/lualine.nix +++ b/config/statusline/lualine.nix @@ -1,36 +1,112 @@ +{ lib, config, ... }: { - plugins.lualine = { - enable = false; - settings = { - - alwaysDivideMiddle = true; - globalstatus = true; - ignoreFocus = [ "neo-tree" ]; - extensions = [ "fzf" ]; - theme = "auto"; - componentSeparators = { - left = "|"; - right = "|"; - }; - sectionSeparators = { - left = "█"; #  - right = "█"; #  - }; - sections = { - lualine_a = [ "mode" ]; - lualine_b = [ - { - name = "branch"; - icon = ""; - } - "diff" - "diagnostics" - ]; - lualine_c = [ "filename" ]; - lualine_x = [ "filetype" ]; - lualine_y = [ "progress" ]; - lualine_z = [ ''" " .. os.date("%R")'' ]; + options = { + lualine.enable = lib.mkEnableOption "Enable lualine module"; + }; + config = lib.mkIf config.lualine.enable { + plugins.lualine = { + enable = true; + settings = { + alwaysDivideMiddle = true; + globalstatus = true; + ignoreFocus = [ "neo-tree" ]; + extensions = [ "fzf" ]; + theme = "auto"; + componentSeparators = { + left = "|"; + right = "|"; + }; + sectionSeparators = { + left = "█"; #  + right = "█"; #  + }; + sections = { + lualine_a = [ "mode" ]; + lualine_b = [ + "branch" + "" + "diff" + "diagnostics" + ]; + lualine_c = [ "filename" ]; + lualine_x = [ "filetype" ]; + lualine_y = [ "progress" ]; + lualine_z = [ ''" " .. os.date("%R")'' ]; + }; }; }; + extraConfigLua = '' + config = function() + local harpoon = require("harpoon.mark") + + local function truncate_branch_name(branch) + if not branch or branch == "" then + return "" + end + + -- Match the branch name to the specified format + local user, team, ticket_number = string.find(branch, "(%w+)%/(%w+)%-(%d+)%-") + + -- If the branch name matches the format, display sko-{ticket_number}, otherwise display the full branch name + if ticket_number then + return user .. "/" .. team .. "-" .. ticket_number + else + return branch + end + end + + local function harpoon_component() + local total_marks = harpoon.get_length() + + if total_marks == 0 then + return "" + end + + local current_mark = "—" + + local mark_idx = harpoon.get_current_index() + if mark_idx ~= nil then + current_mark = tostring(mark_idx) + end + + return string.format("󱡅 %s/%d", current_mark, total_marks) + end + + local function get_lsp_client(_) + ---@type any?{} + local client_names = {} + local msg = "No Active Lsp" + local clients = vim.lsp.get_clients({ bufnr = 0 }) + if next(clients) == nil then + return msg + end + for _, client in ipairs(clients) do + table.insert(client_names, client.name) + end + return #client_names == 0 and msg or table.concat(client_names, " | ") + end + local function wordcount() + return tostring(vim.fn.wordcount().words) .. " words" + end + local function readingtime() + return tostring(math.ceil(vim.fn.wordcount().words / 200.0)) .. " min" + end + local function is_markdown() + return vim.bo.filetype == "markdown" or vim.bo.filetype == "asciidoc" + end + local function navic() + return require("nvim-navic").get_location() + end + local function navic_is_available() + return package.loaded["nvim-navic"] and require("nvim-navic").is_available() + end + local cmd_mode = function() + return require("noice").api.status.mode.get() + end + local show_mode = function() + return package.loaded["noice"] and require("noice").api.status.mode.has() or "" + end + end + ''; }; } diff --git a/config/statusline/staline.nix b/config/statusline/staline.nix index ae07bb8..de83112 100644 --- a/config/statusline/staline.nix +++ b/config/statusline/staline.nix @@ -1,65 +1,76 @@ -{pkgs, ...}: { - extraPlugins = with pkgs.vimUtils; [ - (buildVimPlugin { - pname = "staline.nvim"; - version = "2024-02-05"; - src = pkgs.fetchFromGitHub { - owner = "tamton-aquib"; - repo = "staline.nvim"; - rev = "a53f869278b8b186a5afd6f21680cd103c381599"; - hash = "sha256-GDMKzxFDtQk5LL+rMsxTGTyLv69w5NUd+u19noeO5ws="; - }; - }) - ]; - extraConfigLua = '' - require("staline").setup({ - sections = { - left = { "-mode", " ", "branch" }, - mid = { "lsp_name" }, - right = { "file_name", "line_column" }, - }, - inactive_sections = { - left = { "-mode", " ", "branch" }, - mid = { "lsp_name" }, - right = { "file_name", "line_column" }, - }, - defaults = { - left_separator = " ", - right_separator = " ", - branch_symbol = " ", - mod_symbol = "", - line_column = "[%l/%L]", - inactive_color = "#80a6f2", --#303030 is the default - inactive_bgcolor = "none", - }, - special_table = { - lazy = { "Plugins", "💤 " }, - TelescopePrompt = { "Telescope", " " }, - oil = { "Oil", "󰏇 " }, - lazygit = { "LazyGit", " " }, - }, - mode_icons = { - ["n"] = "NORMAL", - ["no"] = "NORMAL", - ["nov"] = "NORMAL", - ["noV"] = "NORMAL", - ["niI"] = "NORMAL", - ["niR"] = "NORMAL", - ["niV"] = "NORMAL", - ["i"] = "INSERT", - ["ic"] = "INSERT", - ["ix"] = "INSERT", - ["s"] = "INSERT", - ["S"] = "INSERT", - ["v"] = "VISUAL", - ["V"] = "VISUAL", - [""] = "VISUAL", - ["r"] = "REPLACE", - ["r?"] = "REPLACE", - ["R"] = "REPLACE", - ["c"] = "COMMAND", - ["t"] = "TERMINAL", - }, - }) - ''; +{ + lib, + config, + pkgs, + ... +}: +{ + options = { + staline.enable = lib.mkEnableOption "Enable staline module"; + }; + config = lib.mkIf config.staline.enable { + extraPlugins = with pkgs.vimUtils; [ + (buildVimPlugin { + pname = "staline.nvim"; + version = "2024-02-05"; + src = pkgs.fetchFromGitHub { + owner = "tamton-aquib"; + repo = "staline.nvim"; + rev = "a53f869278b8b186a5afd6f21680cd103c381599"; + hash = "sha256-GDMKzxFDtQk5LL+rMsxTGTyLv69w5NUd+u19noeO5ws="; + }; + }) + ]; + extraConfigLua = '' + require("staline").setup({ + sections = { + left = { "-mode", " ", "branch" }, + mid = { "lsp_name" }, + right = { "file_name", "line_column" }, + }, + inactive_sections = { + left = { "-mode", " ", "branch" }, + mid = { "lsp_name" }, + right = { "file_name", "line_column" }, + }, + defaults = { + left_separator = " ", + right_separator = " ", + branch_symbol = " ", + mod_symbol = "", + line_column = "[%l/%L]", + inactive_color = "#80a6f2", --#303030 is the default + inactive_bgcolor = "none", + }, + special_table = { + lazy = { "Plugins", "💤 " }, + TelescopePrompt = { "Telescope", " " }, + oil = { "Oil", "󰏇 " }, + lazygit = { "LazyGit", " " }, + }, + mode_icons = { + ["n"] = "NORMAL", + ["no"] = "NORMAL", + ["nov"] = "NORMAL", + ["noV"] = "NORMAL", + ["niI"] = "NORMAL", + ["niR"] = "NORMAL", + ["niV"] = "NORMAL", + ["i"] = "INSERT", + ["ic"] = "INSERT", + ["ix"] = "INSERT", + ["s"] = "INSERT", + ["S"] = "INSERT", + ["v"] = "VISUAL", + ["V"] = "VISUAL", + [""] = "VISUAL", + ["r"] = "REPLACE", + ["r?"] = "REPLACE", + ["R"] = "REPLACE", + ["c"] = "COMMAND", + ["t"] = "TERMINAL", + }, + }) + ''; + }; } From d10925a01a9d4a35301b232f87208db17f4e2027 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:01:21 -0300 Subject: [PATCH 14/20] refactor: make telescope modular --- config/telescope/default.nix | 17 +++ config/telescope/telescope-nvim.nix | 159 +++++++++++++++++++++++++ config/telescope/telescope.nix | 178 ---------------------------- 3 files changed, 176 insertions(+), 178 deletions(-) create mode 100644 config/telescope/default.nix create mode 100644 config/telescope/telescope-nvim.nix delete mode 100644 config/telescope/telescope.nix diff --git a/config/telescope/default.nix b/config/telescope/default.nix new file mode 100644 index 0000000..35b8617 --- /dev/null +++ b/config/telescope/default.nix @@ -0,0 +1,17 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./telescope-nvim.nix + ]; + + options = { + telescope.enable = lib.mkEnableOption "Enable telescope module"; + }; + config = lib.mkIf config.telescope.enable { + telescope-nvim.enable = lib.mkDefault true; + }; +} diff --git a/config/telescope/telescope-nvim.nix b/config/telescope/telescope-nvim.nix new file mode 100644 index 0000000..7164478 --- /dev/null +++ b/config/telescope/telescope-nvim.nix @@ -0,0 +1,159 @@ +{ lib, config, ... }: +{ + options = { + telescope-nvim.enable = lib.mkEnableOption "Enable telescope-nvim module"; + }; + config = lib.mkIf config.telescope-nvim.enable { + plugins.telescope = { + enable = true; + extensions = { + fzf-native = { + enable = true; + settings = { + fuzzy = true; + override_generic_sorter = true; + override_file_sorter = true; + case_mode = "smart_case"; + }; + }; + ui-select = { + enable = true; + settings = { + specific_opts = { + codeactions = true; + }; + }; + }; + }; + # If you'd prefer Telescope not to enter a normal-like mode when hitting escape (and instead exiting), you can map to do so via: + settings = { + defaults = { + mappings = { + i = { + "" = { + __raw = '' + function(...) + return require("telescope.actions").close(...) + end''; + }; + }; + }; + }; + pickers = { + colorscheme = { + enable_preview = true; + }; + # find_files = { + # theme = "ivy"; + # }; + }; + }; + keymaps = { + "" = { + action = "find_files"; + options.desc = "Find project files"; + }; + "/" = { + action = "live_grep"; + options.desc = "Grep (root dir)"; + }; + ":" = { + action = "command_history"; + options.desc = "Command History"; + }; + "b" = { + action = "buffers"; + options.desc = "+buffer"; + }; + "ff" = { + action = "find_files"; + options.desc = "Find project files"; + }; + "fr" = { + action = "oldfiles"; + options.desc = "Recent"; + }; + "fb" = { + action = "buffers"; + options.desc = "Buffers"; + }; + "" = { + action = "git_files"; + options.desc = "Search git files"; + }; + "gc" = { + action = "git_commits"; + options.desc = "Commits"; + }; + "gs" = { + action = "git_status"; + options.desc = "Status"; + }; + "sa" = { + action = "autocommands"; + options.desc = "Auto Commands"; + }; + "sb" = { + action = "current_buffer_fuzzy_find"; + options.desc = "Buffer"; + }; + "sc" = { + action = "command_history"; + options.desc = "Command History"; + }; + "sC" = { + action = "commands"; + options.desc = "Commands"; + }; + "sD" = { + action = "diagnostics"; + options.desc = "Workspace diagnostics"; + }; + "sh" = { + action = "help_tags"; + options.desc = "Help pages"; + }; + "sH" = { + action = "highlights"; + options.desc = "Search Highlight Groups"; + }; + "sk" = { + action = "keymaps"; + options.desc = "Keymaps"; + }; + "sM" = { + action = "man_pages"; + options.desc = "Man pages"; + }; + "sm" = { + action = "marks"; + options.desc = "Jump to Mark"; + }; + "so" = { + action = "vim_options"; + options.desc = "Options"; + }; + "sR" = { + action = "resume"; + options.desc = "Resume"; + }; + "uC" = { + action = "colorscheme"; + options.desc = "Colorscheme preview"; + }; + "fp" = { + action = "projects"; + options.desc = "Projects"; + }; + "sd" = { + action = "diagnostics bufnr=0"; + options.desc = "Document Diagnostics"; + }; + "st" = { + action = "todo-comments"; + options.desc = "Todo (Telescope)"; + }; + }; + }; + }; +} diff --git a/config/telescope/telescope.nix b/config/telescope/telescope.nix deleted file mode 100644 index 19303aa..0000000 --- a/config/telescope/telescope.nix +++ /dev/null @@ -1,178 +0,0 @@ -{ - plugins.telescope = { - enable = true; - - extensions = { - fzf-native = { - enable = true; - }; - ui-select = { - settings = { - specific_opts = { - codeactions = true; - }; - }; - }; - undo = { - enable = true; - }; - }; - # If you'd prefer Telescope not to enter a normal-like mode when hitting escape (and instead exiting), you can map to do so via: - settings = { - defaults = { - mappings = { - i = { - "" = { - __raw = '' - function(...) - return require("telescope.actions").close(...) - end''; - }; - }; - }; - }; - }; - keymaps = { - "" = { - action = "find_files"; - options.desc = "Find project files"; - }; - "/" = { - action = "live_grep"; - options.desc = "Grep (root dir)"; - }; - ":" = { - action = "command_history"; - options.desc = "Command History"; - }; - "b" = { - action = "buffers"; - options.desc = "+buffer"; - }; - "ff" = { - action = "find_files"; - options.desc = "Find project files"; - }; - "fr" = { - action = "oldfiles"; - options.desc = "Recent"; - }; - "fb" = { - action = "buffers"; - options.desc = "Buffers"; - }; - "" = { - action = "git_files"; - options.desc = "Search git files"; - }; - "gc" = { - action = "git_commits"; - options.desc = "Commits"; - }; - "gs" = { - action = "git_status"; - options.desc = "Status"; - }; - "sa" = { - action = "autocommands"; - options.desc = "Auto Commands"; - }; - "sb" = { - action = "current_buffer_fuzzy_find"; - options.desc = "Buffer"; - }; - "sc" = { - action = "command_history"; - options.desc = "Command History"; - }; - "sC" = { - action = "commands"; - options.desc = "Commands"; - }; - "sD" = { - action = "diagnostics"; - options.desc = "Workspace diagnostics"; - }; - "sh" = { - action = "help_tags"; - options.desc = "Help pages"; - }; - "sH" = { - action = "highlights"; - options.desc = "Search Highlight Groups"; - }; - "sk" = { - action = "keymaps"; - options.desc = "Keymaps"; - }; - "sM" = { - action = "man_pages"; - options.desc = "Man pages"; - }; - "sm" = { - action = "marks"; - options.desc = "Jump to Mark"; - }; - "so" = { - action = "vim_options"; - options.desc = "Options"; - }; - "sR" = { - action = "resume"; - options.desc = "Resume"; - }; - "uC" = { - action = "colorscheme"; - options.desc = "Colorscheme preview"; - }; - }; - }; - keymaps = [ - { - mode = "n"; - key = "fp"; - action = "Telescope projects"; - options = { - desc = "Projects"; - }; - } - - { - mode = "n"; - key = "sd"; - action = "Telescope diagnostics bufnr=0"; - options = { - desc = "Document diagnostics"; - }; - } - - { - mode = "n"; - key = "st"; - action = "TodoTelescope"; - options = { - silent = true; - desc = "Todo (Telescope)"; - }; - } - - # { - # mode = "n"; - # key = ","; - # action = "Telescope buffers sort_mru=true sort_lastused=true"; - # options = { - # desc = "Switch Buffer"; - # }; - # } - ]; - extraConfigLua = '' - local telescope = require('telescope') - telescope.setup{ - pickers = { - colorscheme = { - enable_preview = true - } - } - } - ''; -} From 30c92f52dc77213d81e5e8141fb8f13041d2c6ed Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:01:34 -0300 Subject: [PATCH 15/20] refactor: make ui dir modular --- config/ui/alpha.nix | 394 +++++++++++++++++---------------- config/ui/barbecue.nix | 31 +++ config/ui/default.nix | 31 +++ config/ui/dressing-nvim.nix | 310 +++++++++++++------------- config/ui/indent-blankline.nix | 63 +++--- config/ui/noice.nix | 76 ++++--- config/ui/notify.nix | 143 ++++++++++++ config/ui/nui.nix | 16 +- config/ui/nvim-notify.nix | 137 ------------ config/ui/web-devicons.nix | 10 +- 10 files changed, 673 insertions(+), 538 deletions(-) create mode 100644 config/ui/barbecue.nix create mode 100644 config/ui/default.nix create mode 100644 config/ui/notify.nix delete mode 100644 config/ui/nvim-notify.nix diff --git a/config/ui/alpha.nix b/config/ui/alpha.nix index c16b713..97d5751 100644 --- a/config/ui/alpha.nix +++ b/config/ui/alpha.nix @@ -1,205 +1,211 @@ +{ lib, config, ... }: { - plugins.alpha = { - enable = true; - theme = null; - layout = - let - padding = val: { - type = "padding"; - inherit val; - }; - in - [ - (padding 4) - { - opts = { - hl = "AlphaHeader"; - position = "center"; - }; - type = "text"; - val = [ - " ███▄ █ ▓█████ ██▒ █▓▓█████ " - " ██ ▀█ █ ▓█ ▀▓██░ █▒▓█ ▀ " - " ▓██ ▀█ ██▒▒███ ▓██ █▒░▒███ " - " ▓██▒ ▐▌██▒▒▓█ ▄ ▒██ █░░▒▓█ ▄ " - " ▒██░ ▓██░░▒████▒ ▒▀█░ ░▒████▒ " - " ░ ▒░ ▒ ▒ ░░ ▒░ ░ ░ ▐░ ░░ ▒░ ░ " - " ░ ░░ ░ ▒░ ░ ░ ░ ░ ░░ ░ ░ ░ " - " ░ ░ ░ ░ ░░ ░ " - " ░ ░ ░ ░ ░ ░ " - " ░ " - " " - " git@github.com:redyf/neve " - ]; - } - (padding 2) - { - type = "button"; - val = " Find File"; - on_press = { - __raw = "function() require('telescope.builtin').find_files() end"; + options = { + alpha.enable = lib.mkEnableOption "Enable alpha module"; + }; + config = lib.mkIf config.alpha.enable { + plugins.alpha = { + enable = true; + theme = null; + layout = + let + padding = val: { + type = "padding"; + inherit val; }; - opts = { - # hl = "comment"; - keymap = [ - "n" - "f" - ":Telescope find_files " - { - noremap = true; - silent = true; - nowait = true; - } + in + [ + (padding 4) + { + opts = { + hl = "AlphaHeader"; + position = "center"; + }; + type = "text"; + val = [ + " ███▄ █ ▓█████ ██▒ █▓▓█████ " + " ██ ▀█ █ ▓█ ▀▓██░ █▒▓█ ▀ " + " ▓██ ▀█ ██▒▒███ ▓██ █▒░▒███ " + " ▓██▒ ▐▌██▒▒▓█ ▄ ▒██ █░░▒▓█ ▄ " + " ▒██░ ▓██░░▒████▒ ▒▀█░ ░▒████▒ " + " ░ ▒░ ▒ ▒ ░░ ▒░ ░ ░ ▐░ ░░ ▒░ ░ " + " ░ ░░ ░ ▒░ ░ ░ ░ ░ ░░ ░ ░ ░ " + " ░ ░ ░ ░ ░░ ░ " + " ░ ░ ░ ░ ░ ░ " + " ░ " + " " + " git@github.com:redyf/neve " ]; - shortcut = "f"; + } + (padding 2) + { + type = "button"; + val = " Find File"; + on_press = { + __raw = "function() require('telescope.builtin').find_files() end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "f" + ":Telescope find_files " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "f"; - position = "center"; - cursor = 3; - width = 38; - align_shortcut = "right"; - hl_shortcut = "Keyword"; - }; - } - (padding 1) - { - type = "button"; - val = " New File"; - on_press = { - __raw = "function() vim.cmd[[ene]] end"; - }; - opts = { - # hl = "comment"; - keymap = [ - "n" - "n" - ":ene startinsert " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - shortcut = "n"; + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = " New File"; + on_press = { + __raw = "function() vim.cmd[[ene]] end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "n" + ":ene startinsert " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "n"; - position = "center"; - cursor = 3; - width = 38; - align_shortcut = "right"; - hl_shortcut = "Keyword"; - }; - } - (padding 1) - { - type = "button"; - val = "󰈚 Recent Files"; - on_press = { - __raw = "function() require('telescope.builtin').oldfiles() end"; - }; - opts = { - # hl = "comment"; - keymap = [ - "n" - "r" - ":Telescope oldfiles " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - shortcut = "r"; + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = "󰈚 Recent Files"; + on_press = { + __raw = "function() require('telescope.builtin').oldfiles() end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "r" + ":Telescope oldfiles " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "r"; - position = "center"; - cursor = 3; - width = 38; - align_shortcut = "right"; - hl_shortcut = "Keyword"; - }; - } - (padding 1) - { - type = "button"; - val = "󰈭 Find Word"; - on_press = { - __raw = "function() require('telescope.builtin').live_grep() end"; - }; - opts = { - # hl = "comment"; - keymap = [ - "n" - "g" - ":Telescope live_grep " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - shortcut = "g"; + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = "󰈭 Find Word"; + on_press = { + __raw = "function() require('telescope.builtin').live_grep() end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "g" + ":Telescope live_grep " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "g"; - position = "center"; - cursor = 3; - width = 38; - align_shortcut = "right"; - hl_shortcut = "Keyword"; - }; - } - (padding 1) - { - type = "button"; - val = " Restore Session"; - on_press = { - __raw = "function() require('persistence').load() end"; - }; - opts = { - # hl = "comment"; - keymap = [ - "n" - "s" - ":lua require('persistence').load()" - { - noremap = true; - silent = true; - nowait = true; - } - ]; - shortcut = "s"; + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = " Restore Session"; + on_press = { + __raw = "function() require('persistence').load() end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "s" + ":lua require('persistence').load()" + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "s"; - position = "center"; - cursor = 3; - width = 38; - align_shortcut = "right"; - hl_shortcut = "Keyword"; - }; - } - (padding 1) - { - type = "button"; - val = " Quit Neovim"; - on_press = { - __raw = "function() vim.cmd[[qa]] end"; - }; - opts = { - # hl = "comment"; - keymap = [ - "n" - "q" - ":qa" - { - noremap = true; - silent = true; - nowait = true; - } - ]; - shortcut = "q"; + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = " Quit Neovim"; + on_press = { + __raw = "function() vim.cmd[[qa]] end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "q" + ":qa" + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "q"; - position = "center"; - cursor = 3; - width = 38; - align_shortcut = "right"; - hl_shortcut = "Keyword"; - }; - } - ]; + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + ]; + }; }; } diff --git a/config/ui/barbecue.nix b/config/ui/barbecue.nix new file mode 100644 index 0000000..9bd6f0e --- /dev/null +++ b/config/ui/barbecue.nix @@ -0,0 +1,31 @@ +{ lib, config, ... }: +{ + options = { + barbecue.enable = lib.mkEnableOption "Enable barbecue module"; + }; + config = lib.mkIf config.barbecue.enable { + plugins.barbecue = { + enable = true; + settings = { + create_autocmd = false; + theme = "auto"; + }; + }; + extraConfigLua = '' + vim.api.nvim_create_autocmd({ + "WinScrolled", -- or WinResized on NVIM-v0.9 and higher + "BufWinEnter", + "CursorHold", + "InsertLeave", + + -- include this if you have set `show_modified` to `true` + "BufModifiedSet", + }, { + group = vim.api.nvim_create_augroup("barbecue.updater", {}), + callback = function() + require("barbecue.ui").update() + end, + }) + ''; + }; +} diff --git a/config/ui/default.nix b/config/ui/default.nix new file mode 100644 index 0000000..3110d1d --- /dev/null +++ b/config/ui/default.nix @@ -0,0 +1,31 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./alpha.nix + ./barbecue.nix + ./dressing-nvim.nix + ./indent-blankline.nix + ./noice.nix + ./nui.nix + ./notify.nix + ./web-devicons.nix + ]; + + options = { + ui.enable = lib.mkEnableOption "Enable ui module"; + }; + config = lib.mkIf config.ui.enable { + alpha.enable = lib.mkDefault true; + barbecue.enable = lib.mkDefault true; + dressing-nvim.enable = lib.mkDefault true; + indent-blankline.enable = lib.mkDefault true; + noice.enable = lib.mkDefault false; + notify.enable = lib.mkDefault true; + nui.enable = lib.mkDefault true; + web-devicons.enable = lib.mkDefault true; + }; +} diff --git a/config/ui/dressing-nvim.nix b/config/ui/dressing-nvim.nix index 9f4374b..fdf93bc 100644 --- a/config/ui/dressing-nvim.nix +++ b/config/ui/dressing-nvim.nix @@ -1,157 +1,75 @@ -{pkgs, ...}: { - extraPlugins = with pkgs.vimPlugins; [ - dressing-nvim - ]; - extraConfigLua = '' - require("dressing").setup({ - input = { - -- Set to false to disable the vim.ui.input implementation - enabled = true, - - -- Default prompt string - default_prompt = "Input", - - -- Trim trailing `:` from prompt - trim_prompt = true, - - -- Can be 'left', 'right', or 'center' - title_pos = "left", - - -- When true, will close the modal - insert_only = true, - - -- When true, input will start in insert mode. - start_in_insert = true, - - -- These are passed to nvim_open_win - border = "rounded", - -- 'editor' and 'win' will default to being centered - relative = "cursor", - - -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) - prefer_width = 40, - width = nil, - -- min_width and max_width can be a list of mixed types. - -- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total" - max_width = { 140, 0.9 }, - min_width = { 20, 0.2 }, - - buf_options = {}, - win_options = { - -- Disable line wrapping - wrap = false, - -- Indicator for when text exceeds window - list = true, - listchars = "precedes:…,extends:…", - -- Increase this for more context when text scrolls off the window - sidescrolloff = 0, - }, - - -- Set to `false` to disable - mappings = { - n = { - [""] = "Close", - [""] = "Confirm", - }, - i = { - [""] = "Close", - [""] = "Confirm", - [""] = "HistoryPrev", - [""] = "HistoryNext", - }, - }, - - override = function(conf) - -- This is the config that will be passed to nvim_open_win. - -- Change values here to customize the layout - return conf - end, - - -- see :help dressing_get_config - get_config = nil, - }, - select = { - -- Set to false to disable the vim.ui.select implementation - enabled = true, - - -- Priority list of preferred vim.select implementations - backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" }, - - -- Trim trailing `:` from prompt - trim_prompt = true, - - -- Options for telescope selector - -- These are passed into the telescope picker directly. Can be used like: - -- telescope = require('telescope.themes').get_ivy({...}) - telescope = nil, - - -- Options for fzf selector - fzf = { - window = { - width = 0.5, - height = 0.4, - }, - }, - - -- Options for fzf-lua - fzf_lua = { - -- winopts = { - -- height = 0.5, - -- width = 0.5, - -- }, - }, - - -- Options for nui Menu - nui = { - position = "50%", - size = nil, - relative = "editor", - border = { - style = "rounded", - }, - buf_options = { - swapfile = false, - filetype = "DressingSelect", - }, - win_options = { - winblend = 0, - }, - max_width = 80, - max_height = 40, - min_width = 40, - min_height = 10, - }, +{ + lib, + config, + pkgs, + ... +}: +{ + options = { + dressing-nvim.enable = lib.mkEnableOption "Enable dressing-nvim module"; + }; + config = lib.mkIf config.dressing-nvim.enable { + + extraPlugins = with pkgs.vimPlugins; [ + dressing-nvim + ]; + extraConfigLua = '' + require("dressing").setup({ + input = { + -- Set to false to disable the vim.ui.input implementation + enabled = true, + + -- Default prompt string + default_prompt = "Input", + + -- Trim trailing `:` from prompt + trim_prompt = true, + + -- Can be 'left', 'right', or 'center' + title_pos = "left", + + -- When true, will close the modal + insert_only = true, + + -- When true, input will start in insert mode. + start_in_insert = true, - -- Options for built-in selector - builtin = { - -- Display numbers for options and set up keymaps - show_numbers = true, -- These are passed to nvim_open_win border = "rounded", -- 'editor' and 'win' will default to being centered - relative = "editor", + relative = "cursor", + + -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) + prefer_width = 40, + width = nil, + -- min_width and max_width can be a list of mixed types. + -- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total" + max_width = { 140, 0.9 }, + min_width = { 20, 0.2 }, buf_options = {}, win_options = { - cursorline = true, - cursorlineopt = "both", + -- Disable line wrapping + wrap = false, + -- Indicator for when text exceeds window + list = true, + listchars = "precedes:…,extends:…", + -- Increase this for more context when text scrolls off the window + sidescrolloff = 0, }, - -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) - -- the min_ and max_ options can be a list of mixed types. - -- max_width = {140, 0.8} means "the lesser of 140 columns or 80% of total" - width = nil, - max_width = { 140, 0.8 }, - min_width = { 40, 0.2 }, - height = nil, - max_height = 0.9, - min_height = { 10, 0.2 }, - -- Set to `false` to disable mappings = { - [""] = "Close", - [""] = "Close", - [""] = "Confirm", + n = { + [""] = "Close", + [""] = "Confirm", + }, + i = { + [""] = "Close", + [""] = "Confirm", + [""] = "HistoryPrev", + [""] = "HistoryNext", + }, }, override = function(conf) @@ -159,13 +77,107 @@ -- Change values here to customize the layout return conf end, + + -- see :help dressing_get_config + get_config = nil, }, + select = { + -- Set to false to disable the vim.ui.select implementation + enabled = true, + + -- Priority list of preferred vim.select implementations + backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" }, + + -- Trim trailing `:` from prompt + trim_prompt = true, + + -- Options for telescope selector + -- These are passed into the telescope picker directly. Can be used like: + -- telescope = require('telescope.themes').get_ivy({...}) + telescope = nil, + + -- Options for fzf selector + fzf = { + window = { + width = 0.5, + height = 0.4, + }, + }, - -- Used to override format_item. See :help dressing-format - format_item_override = {}, + -- Options for fzf-lua + fzf_lua = { + -- winopts = { + -- height = 0.5, + -- width = 0.5, + -- }, + }, + + -- Options for nui Menu + nui = { + position = "50%", + size = nil, + relative = "editor", + border = { + style = "rounded", + }, + buf_options = { + swapfile = false, + filetype = "DressingSelect", + }, + win_options = { + winblend = 0, + }, + max_width = 80, + max_height = 40, + min_width = 40, + min_height = 10, + }, - -- see :help dressing_get_config - get_config = nil, - }, - }) ''; + -- Options for built-in selector + builtin = { + -- Display numbers for options and set up keymaps + show_numbers = true, + -- These are passed to nvim_open_win + border = "rounded", + -- 'editor' and 'win' will default to being centered + relative = "editor", + + buf_options = {}, + win_options = { + cursorline = true, + cursorlineopt = "both", + }, + + -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) + -- the min_ and max_ options can be a list of mixed types. + -- max_width = {140, 0.8} means "the lesser of 140 columns or 80% of total" + width = nil, + max_width = { 140, 0.8 }, + min_width = { 40, 0.2 }, + height = nil, + max_height = 0.9, + min_height = { 10, 0.2 }, + + -- Set to `false` to disable + mappings = { + [""] = "Close", + [""] = "Close", + [""] = "Confirm", + }, + + override = function(conf) + -- This is the config that will be passed to nvim_open_win. + -- Change values here to customize the layout + return conf + end, + }, + + -- Used to override format_item. See :help dressing-format + format_item_override = {}, + + -- see :help dressing_get_config + get_config = nil, + }, + }) ''; + }; } diff --git a/config/ui/indent-blankline.nix b/config/ui/indent-blankline.nix index 1c382c8..23965e0 100644 --- a/config/ui/indent-blankline.nix +++ b/config/ui/indent-blankline.nix @@ -1,30 +1,41 @@ +{ lib, config, ... }: { - plugins = { - indent-blankline = { - enable = true; - settings = { - indent = { - char = "│"; # "│" or "▎" - }; - scope = { - enabled = true; - show_start = true; - }; - exclude = { - buftypes = ["terminal" "nofile"]; - filetypes = [ - "help" - "alpha" - "dashboard" - "neo-tree" - "Trouble" - "trouble" - "lazy" - "mason" - "notify" - "toggleterm" - "lazyterm" - ]; + options = { + indent-blankline.enable = lib.mkEnableOption "Enable indent-blankline module"; + }; + config = lib.mkIf config.indent-blankline.enable { + + plugins = { + indent-blankline = { + enable = true; + settings = { + indent = { + char = "│"; # "│" or "▎" + }; + scope = { + enabled = true; + show_start = true; + }; + exclude = { + buftypes = [ + "terminal" + "nofile" + ]; + filetypes = [ + "help" + "alpha" + "dashboard" + "neo-tree" + "Trouble" + "trouble" + "lazy" + "mason" + "notify" + "toggleterm" + "lazyterm" + "nvterm" + ]; + }; }; }; }; diff --git a/config/ui/noice.nix b/config/ui/noice.nix index 51db89d..f8206ad 100644 --- a/config/ui/noice.nix +++ b/config/ui/noice.nix @@ -1,35 +1,55 @@ +{ lib, config, ... }: { - plugins.noice = { - enable = true; - notify = { - enabled = false; - }; - messages = { - enabled = true; # Adds a padding-bottom to neovim statusline when set to false for some reason - }; - lsp = { - message = { - enabled = true; - }; - progress = { + options = { + noice.enable = lib.mkEnableOption "Enable noice module"; + }; + config = lib.mkIf config.noice.enable { + plugins.noice = { + enable = true; + notify = { enabled = false; - view = "mini"; }; - }; - popupmenu = { - enabled = true; - backend = "nui"; - }; - format = { - filter = { - pattern = [":%s*%%s*s:%s*" ":%s*%%s*s!%s*" ":%s*%%s*s/%s*" "%s*s:%s*" ":%s*s!%s*" ":%s*s/%s*"]; - icon = ""; - lang = "regex"; + messages = { + enabled = true; # Adds a padding-bottom to neovim statusline when set to false for some reason + }; + lsp = { + message = { + enabled = true; + }; + progress = { + enabled = false; + view = "mini"; + }; + }; + popupmenu = { + enabled = true; + backend = "nui"; }; - replace = { - pattern = [":%s*%%s*s:%w*:%s*" ":%s*%%s*s!%w*!%s*" ":%s*%%s*s/%w*/%s*" "%s*s:%w*:%s*" ":%s*s!%w*!%s*" ":%s*s/%w*/%s*"]; - icon = "󱞪"; - lang = "regex"; + format = { + filter = { + pattern = [ + ":%s*%%s*s:%s*" + ":%s*%%s*s!%s*" + ":%s*%%s*s/%s*" + "%s*s:%s*" + ":%s*s!%s*" + ":%s*s/%s*" + ]; + icon = ""; + lang = "regex"; + }; + replace = { + pattern = [ + ":%s*%%s*s:%w*:%s*" + ":%s*%%s*s!%w*!%s*" + ":%s*%%s*s/%w*/%s*" + "%s*s:%w*:%s*" + ":%s*s!%w*!%s*" + ":%s*s/%w*/%s*" + ]; + icon = "󱞪"; + lang = "regex"; + }; }; }; }; diff --git a/config/ui/notify.nix b/config/ui/notify.nix new file mode 100644 index 0000000..00481da --- /dev/null +++ b/config/ui/notify.nix @@ -0,0 +1,143 @@ +{ lib, config, ... }: +{ + options = { + notify.enable = lib.mkEnableOption "Enable notify module"; + }; + config = lib.mkIf config.notify.enable { + plugins.notify = { + enable = true; + backgroundColour = "#000000"; + fps = 60; + render = "default"; + timeout = 500; + topDown = true; + }; + keymaps = [ + { + mode = "n"; + key = "un"; + action = '' + lua require("notify").dismiss({ silent = true, pending = true }) + ''; + options = { + desc = "Dismiss All Notifications"; + }; + } + ]; + extraConfigLua = '' + local notify = require("notify") + + local function show_notification(message, level) + notify(message, level, { title = "conform.nvim" }) + end + + function ToggleLineNumber() + if vim.wo.number then + vim.wo.number = false + show_notification("Line numbers disabled", "info") + else + vim.wo.number = true + vim.wo.relativenumber = false + show_notification("Line numbers enabled", "info") + end + end + + function ToggleRelativeLineNumber() + if vim.wo.relativenumber then + vim.wo.relativenumber = false + show_notification("Relative line numbers disabled", "info") + else + vim.wo.relativenumber = true + vim.wo.number = false + show_notification("Relative line numbers enabled", "info") + end + end + + function ToggleWrap() + if vim.wo.wrap then + vim.wo.wrap = false + show_notification("Wrap disabled", "info") + else + vim.wo.wrap = true + vim.wo.number = false + show_notification("Wrap enabled", "info") + end + end + + function ToggleInlayHints() + local is_enabled = vim.lsp.inlay_hint.is_enabled() + vim.lsp.inlay_hint.enable(not is_enabled) + if is_enabled then + show_notification("Inlay Hints disabled", "info") + else + show_notification("Inlay Hints enabled", "info") + end + end + + vim.api.nvim_create_autocmd("BufReadPost", { + callback = function() + local current_dir = vim.fn.getcwd() + local is_nixpkgs = current_dir:match("nixpkgs$") + if is_nixpkgs then + vim.b.disable_autoformat = true + show_notification("Autoformat-on-save disabled for nixpkgs", "info") + else + vim.b.disable_autoformat = false + end + end, + }) + + vim.api.nvim_create_user_command("FormatToggle", function(args) + local is_global = not args.bang + local current_dir = vim.fn.getcwd() + local is_nixpkgs = current_dir:match("nixpkgs$") + + if is_global then + vim.g.disable_autoformat = not vim.g.disable_autoformat + if vim.g.disable_autoformat then + show_notification("Autoformat-on-save disabled globally", "info") + else + show_notification("Autoformat-on-save enabled globally", "info") + end + elseif is_nixpkgs then + vim.b.disable_autoformat = not vim.b.disable_autoformat + if vim.b.disable_autoformat then + show_notification("Autoformat-on-save disabled for nixpkgs", "info") + else + show_notification("Autoformat-on-save enabled for nixpkgs", "info") + end + else + vim.b.disable_autoformat = not vim.b.disable_autoformat + if vim.b.disable_autoformat then + show_notification("Autoformat-on-save disabled for this buffer", "info") + else + show_notification("Autoformat-on-save enabled for this buffer", "info") + end + end + end, { + desc = "Toggle autoformat-on-save", + bang = true, + }) + + local filtered_message = { "No information available" } + + -- Override notify function to filter out messages + ---@diagnostic disable-next-line: duplicate-set-field + vim.notify = function(message, level, opts) + local merged_opts = vim.tbl_extend("force", { + on_open = function(win) + local buf = vim.api.nvim_win_get_buf(win) + vim.api.nvim_buf_set_option(buf, "filetype", "markdown") + end, + }, opts or {}) + + for _, msg in ipairs(filtered_message) do + if message == msg then + return + end + end + return notify(message, level, merged_opts) + end + ''; + }; +} diff --git a/config/ui/nui.nix b/config/ui/nui.nix index f2710a3..2fd42b1 100644 --- a/config/ui/nui.nix +++ b/config/ui/nui.nix @@ -1,3 +1,15 @@ -{pkgs, ...}: { - extraPlugins = with pkgs.vimPlugins; [nui-nvim]; +{ + lib, + config, + pkgs, + ... +}: + +{ + options = { + nui.enable = lib.mkEnableOption "Enable nui module"; + }; + config = lib.mkIf config.nui.enable { + extraPlugins = with pkgs.vimPlugins; [ nui-nvim ]; + }; } diff --git a/config/ui/nvim-notify.nix b/config/ui/nvim-notify.nix deleted file mode 100644 index a995f0c..0000000 --- a/config/ui/nvim-notify.nix +++ /dev/null @@ -1,137 +0,0 @@ -{ - plugins.notify = { - enable = true; - backgroundColour = "#000000"; - fps = 60; - render = "default"; - timeout = 500; - topDown = true; - }; - keymaps = [ - { - mode = "n"; - key = "un"; - action = '' - lua require("notify").dismiss({ silent = true, pending = true }) - ''; - options = { - desc = "Dismiss All Notifications"; - }; - } - ]; - extraConfigLua = '' - local notify = require("notify") - - local function show_notification(message, level) - notify(message, level, { title = "conform.nvim" }) - end - - function ToggleLineNumber() - if vim.wo.number then - vim.wo.number = false - show_notification("Line numbers disabled", "info") - else - vim.wo.number = true - vim.wo.relativenumber = false - show_notification("Line numbers enabled", "info") - end - end - - function ToggleRelativeLineNumber() - if vim.wo.relativenumber then - vim.wo.relativenumber = false - show_notification("Relative line numbers disabled", "info") - else - vim.wo.relativenumber = true - vim.wo.number = false - show_notification("Relative line numbers enabled", "info") - end - end - - function ToggleWrap() - if vim.wo.wrap then - vim.wo.wrap = false - show_notification("Wrap disabled", "info") - else - vim.wo.wrap = true - vim.wo.number = false - show_notification("Wrap enabled", "info") - end - end - - function ToggleInlayHints() - local is_enabled = vim.lsp.inlay_hint.is_enabled() - vim.lsp.inlay_hint.enable(not is_enabled) - if is_enabled then - show_notification("Inlay Hints disabled", "info") - else - show_notification("Inlay Hints enabled", "info") - end - end - - vim.api.nvim_create_autocmd("BufReadPost", { - callback = function() - local current_dir = vim.fn.getcwd() - local is_nixpkgs = current_dir:match("nixpkgs$") - if is_nixpkgs then - vim.b.disable_autoformat = true - show_notification("Autoformat-on-save disabled for nixpkgs", "info") - else - vim.b.disable_autoformat = false - end - end, - }) - - vim.api.nvim_create_user_command("FormatToggle", function(args) - local is_global = not args.bang - local current_dir = vim.fn.getcwd() - local is_nixpkgs = current_dir:match("nixpkgs$") - - if is_global then - vim.g.disable_autoformat = not vim.g.disable_autoformat - if vim.g.disable_autoformat then - show_notification("Autoformat-on-save disabled globally", "info") - else - show_notification("Autoformat-on-save enabled globally", "info") - end - elseif is_nixpkgs then - vim.b.disable_autoformat = not vim.b.disable_autoformat - if vim.b.disable_autoformat then - show_notification("Autoformat-on-save disabled for nixpkgs", "info") - else - show_notification("Autoformat-on-save enabled for nixpkgs", "info") - end - else - vim.b.disable_autoformat = not vim.b.disable_autoformat - if vim.b.disable_autoformat then - show_notification("Autoformat-on-save disabled for this buffer", "info") - else - show_notification("Autoformat-on-save enabled for this buffer", "info") - end - end - end, { - desc = "Toggle autoformat-on-save", - bang = true, - }) - - local filtered_message = { "No information available" } - - -- Override notify function to filter out messages - ---@diagnostic disable-next-line: duplicate-set-field - vim.notify = function(message, level, opts) - local merged_opts = vim.tbl_extend("force", { - on_open = function(win) - local buf = vim.api.nvim_win_get_buf(win) - vim.api.nvim_buf_set_option(buf, "filetype", "markdown") - end, - }, opts or {}) - - for _, msg in ipairs(filtered_message) do - if message == msg then - return - end - end - return notify(message, level, merged_opts) - end - ''; -} diff --git a/config/ui/web-devicons.nix b/config/ui/web-devicons.nix index cb0f6ab..5e5b95c 100644 --- a/config/ui/web-devicons.nix +++ b/config/ui/web-devicons.nix @@ -1,5 +1,11 @@ +{ lib, config, ... }: { - plugins.web-devicons = { - enable = true; + options = { + web-devicons.enable = lib.mkEnableOption "Enable web-devicons module"; + }; + config = lib.mkIf config.web-devicons.enable { + plugins.web-devicons = { + enable = true; + }; }; } From fd4679fa0e083499ed49586992a99d8ea9fcc30a Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:01:51 -0300 Subject: [PATCH 16/20] refactor: modularize utils dir --- config/utils/better-escape.nix | 52 +++--- config/utils/cloak.nix | 25 +++ config/utils/default.nix | 61 +++++++ config/utils/harpoon.nix | 30 ++-- config/utils/illuminate.nix | 17 -- config/utils/markdown-preview.nix | 38 ++-- config/utils/mini.nix | 28 ++- config/utils/neocord.nix | 52 +++--- config/utils/neodev.nix | 11 -- config/utils/neotest.nix | 274 +++++++++++++++-------------- config/utils/nvim-autopairs.nix | 10 +- config/utils/nvim-colorizer.nix | 11 +- config/utils/nvim-surround.nix | 23 ++- config/utils/nvterm.nix | 132 +++++++------- config/utils/oil.nix | 104 ++++++----- config/utils/persistence.nix | 10 +- config/utils/plenary.nix | 19 +- config/utils/project-nvim.nix | 12 +- config/utils/sidebar.nix | 115 ++++++------ config/utils/tmux-navigator.nix | 10 +- config/utils/todo-comments.nix | 10 +- config/utils/ultimate-autopair.nix | 44 +++-- config/utils/undotree.nix | 38 ++-- config/utils/wakatime.nix | 10 +- config/utils/which-key.nix | 123 +++++++++++++ config/utils/whichkey.nix | 117 ------------ config/utils/wilder.nix | 93 +++++----- 27 files changed, 849 insertions(+), 620 deletions(-) create mode 100644 config/utils/cloak.nix create mode 100644 config/utils/default.nix delete mode 100644 config/utils/illuminate.nix delete mode 100644 config/utils/neodev.nix create mode 100644 config/utils/which-key.nix delete mode 100644 config/utils/whichkey.nix diff --git a/config/utils/better-escape.nix b/config/utils/better-escape.nix index 80e5e9a..800d31a 100644 --- a/config/utils/better-escape.nix +++ b/config/utils/better-escape.nix @@ -1,30 +1,36 @@ +{ lib, config, ... }: { - plugins.better-escape = { - enable = true; - settings = { - timeout = 200; - default_mappings = false; - mappings = { - i = { - j = { - k = ""; - j = ""; + options = { + better-escape.enable = lib.mkEnableOption "Enable better-escape module"; + }; + config = lib.mkIf config.better-escape.enable { + plugins.better-escape = { + enable = true; + settings = { + timeout = 200; + default_mappings = false; + mappings = { + i = { + j = { + k = ""; + j = ""; + }; }; - }; - c = { - j = { - k = ""; - j = ""; + c = { + j = { + k = ""; + j = ""; + }; }; - }; - v = { - j = { - k = ""; + v = { + j = { + k = ""; + }; }; - }; - s = { - j = { - k = ""; + s = { + j = { + k = ""; + }; }; }; }; diff --git a/config/utils/cloak.nix b/config/utils/cloak.nix new file mode 100644 index 0000000..0e8a129 --- /dev/null +++ b/config/utils/cloak.nix @@ -0,0 +1,25 @@ +{ lib, config, ... }: +{ + options = { + cloak.enable = lib.mkEnableOption "Enable cloak module"; + }; + config = lib.mkIf config.cloak.enable { + plugins.cloak = { + enable = true; + settings = { + cloak_character = "*"; + highlight_group = "Comment"; + patterns = [ + { + file_pattern = [ + ".env*" + "wrangler.toml" + ".dev.vars" + ]; + cloak_pattern = "=.+"; + } + ]; + }; + }; + }; +} diff --git a/config/utils/default.nix b/config/utils/default.nix new file mode 100644 index 0000000..ad8ed51 --- /dev/null +++ b/config/utils/default.nix @@ -0,0 +1,61 @@ +{ + lib, + config, + ... +}: +{ + imports = [ + ./better-escape.nix + ./cloak.nix + ./harpoon.nix + ./markdown-preview.nix + ./mini.nix + ./neocord.nix + ./neotest.nix + ./nvim-autopairs.nix + ./nvim-colorizer.nix + ./nvim-surround.nix + ./nvterm.nix + ./oil.nix + ./persistence.nix + ./plenary.nix + ./project-nvim.nix + ./sidebar.nix + ./tmux-navigator.nix + ./todo-comments.nix + ./ultimate-autopair.nix + ./undotree.nix + ./wakatime.nix + ./which-key.nix + ./wilder.nix + ]; + + options = { + utils.enable = lib.mkEnableOption "Enable utils module"; + }; + config = lib.mkIf config.utils.enable { + better-escape.enable = lib.mkDefault true; + cloak.enable = lib.mkDefault true; + harpoon.enable = lib.mkDefault true; + markdown-preview.enable = lib.mkDefault true; + mini.enable = lib.mkDefault true; + neocord.enable = lib.mkDefault true; + neotest.enable = lib.mkDefault true; + nvim-autopairs.enable = lib.mkDefault true; + nvim-colorizer.enable = lib.mkDefault true; + nvim-surround.enable = lib.mkDefault true; + nvterm.enable = lib.mkDefault true; + oil.enable = lib.mkDefault true; + persistence.enable = lib.mkDefault true; + plenary.enable = lib.mkDefault true; + project-nvim.enable = lib.mkDefault true; + sidebar.enable = lib.mkDefault true; + tmux-navigator.enable = lib.mkDefault true; + todo-comments.enable = lib.mkDefault true; + ultimate-autopair.enable = lib.mkDefault true; + undotree.enable = lib.mkDefault true; + wakatime.enable = lib.mkDefault true; + which-key.enable = lib.mkDefault true; + wilder.enable = lib.mkDefault false; + }; +} diff --git a/config/utils/harpoon.nix b/config/utils/harpoon.nix index b55df68..ea552b5 100644 --- a/config/utils/harpoon.nix +++ b/config/utils/harpoon.nix @@ -1,16 +1,22 @@ +{ lib, config, ... }: { - plugins.harpoon = { - enable = true; - enableTelescope = true; - keymapsSilent = true; - keymaps = { - addFile = "ha"; - toggleQuickMenu = ""; - navFile = { - "1" = "hj"; - "2" = "hk"; - "3" = "hl"; - "4" = "hm"; + options = { + harpoon.enable = lib.mkEnableOption "Enable harpoon module"; + }; + config = lib.mkIf config.harpoon.enable { + plugins.harpoon = { + enable = true; + enableTelescope = true; + keymapsSilent = true; + keymaps = { + addFile = "ha"; + toggleQuickMenu = ""; + navFile = { + "1" = "hj"; + "2" = "hk"; + "3" = "hl"; + "4" = "hm"; + }; }; }; }; diff --git a/config/utils/illuminate.nix b/config/utils/illuminate.nix deleted file mode 100644 index c05bc15..0000000 --- a/config/utils/illuminate.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - plugins.illuminate = { - enable = false; - underCursor = false; - filetypesDenylist = [ - "DressingSelect" - "Outline" - "TelescopePrompt" - "alpha" - "harpoon" - "toggleterm" - "neo-tree" - "Spectre" - "reason" - ]; - }; -} diff --git a/config/utils/markdown-preview.nix b/config/utils/markdown-preview.nix index 00df5e6..d1bd2f7 100644 --- a/config/utils/markdown-preview.nix +++ b/config/utils/markdown-preview.nix @@ -1,19 +1,27 @@ +{ lib, config, ... }: { - plugins.markdown-preview = { - enable = true; - settings = { - browser = "floorp"; - theme = "dark"; - }; + # TODO: Switch to peek.nvim + options = { + markdown-preview.enable = lib.mkEnableOption "Enable markdown-preview module"; }; - keymaps = [ - { - mode = "n"; - key = "cp"; - action = "MarkdownPreview"; - options = { - desc = "Markdown Preview"; + config = lib.mkIf config.markdown-preview.enable { + + plugins.markdown-preview = { + enable = true; + settings = { + browser = "firefox"; + theme = "dark"; }; - } - ]; + }; + keymaps = [ + { + mode = "n"; + key = "cp"; + action = "MarkdownPreview"; + options = { + desc = "Markdown Preview"; + }; + } + ]; + }; } diff --git a/config/utils/mini.nix b/config/utils/mini.nix index f688f3f..cbae13f 100644 --- a/config/utils/mini.nix +++ b/config/utils/mini.nix @@ -1,15 +1,25 @@ +{ lib, config, ... }: { - plugins.mini = { - enable = true; - modules = { - comment = { - options = { - customCommentString = '' - lua require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring - ''; + options = { + mini.enable = lib.mkEnableOption "Enable mini module"; + }; + config = lib.mkIf config.mini.enable { + plugins.mini = { + enable = true; + modules = { + comment = { + options = { + customCommentString = '' + lua require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring + ''; + }; + }; + cursorword = { + opts = { + delay = 100; + }; }; }; - cursorword = {}; }; }; } diff --git a/config/utils/neocord.nix b/config/utils/neocord.nix index 2886367..3e91b47 100644 --- a/config/utils/neocord.nix +++ b/config/utils/neocord.nix @@ -1,27 +1,33 @@ +{ lib, config, ... }: { - plugins.neocord = { - enable = true; - settings = { - auto_update = true; - blacklist = []; - client_id = "1157438221865717891"; - debounce_timeout = 10; - editing_text = "Editing..."; - enable_line_number = true; - logo = "https://repository-images.githubusercontent.com/325421844/ecb73f47-cb89-4ee0-a0fd-9743c2f3569a"; - logo_tooltip = "NixVim"; - file_assets = null; - file_explorer_text = "Browsing..."; - git_commit_text = "Committing changes..."; - global_timer = true; - line_number_text = "Line %s out of %s"; - log_level = null; - main_image = "logo"; - plugin_manager_text = "Managing plugins..."; - reading_text = "Reading..."; - show_time = true; - terminal_text = "Using Terminal..."; - workspace_text = "Working on %s"; + options = { + neocord.enable = lib.mkEnableOption "Enable neocord module"; + }; + config = lib.mkIf config.neocord.enable { + plugins.neocord = { + enable = true; + settings = { + auto_update = true; + blacklist = [ ]; + client_id = "1157438221865717891"; + debounce_timeout = 10; + editing_text = "Editing..."; + enable_line_number = true; + logo = "https://repository-images.githubusercontent.com/325421844/ecb73f47-cb89-4ee0-a0fd-9743c2f3569a"; + logo_tooltip = "NixVim"; + file_assets = null; + file_explorer_text = "Browsing..."; + git_commit_text = "Committing changes..."; + global_timer = true; + line_number_text = "Line %s out of %s"; + log_level = null; + main_image = "logo"; + plugin_manager_text = "Managing plugins..."; + reading_text = "Reading..."; + show_time = true; + terminal_text = "Using Terminal..."; + workspace_text = "Working on %s"; + }; }; }; } diff --git a/config/utils/neodev.nix b/config/utils/neodev.nix deleted file mode 100644 index fa1619e..0000000 --- a/config/utils/neodev.nix +++ /dev/null @@ -1,11 +0,0 @@ -{pkgs, ...}: { - extraPlugins = with pkgs.vimPlugins; [ - neodev-nvim - ]; - - extraConfigLua = '' - require("neodev").setup({ - library = { plugins = {"neotest"}, types = true}, - }) - ''; -} diff --git a/config/utils/neotest.nix b/config/utils/neotest.nix index 5d25bcf..8db390a 100644 --- a/config/utils/neotest.nix +++ b/config/utils/neotest.nix @@ -1,133 +1,145 @@ -{pkgs, ...}: { - extraPlugins = with pkgs.vimPlugins; [ - (pkgs.vimUtils.buildVimPlugin { - pname = "neotest-java"; - version = "v0.9.0"; - src = pkgs.fetchFromGitHub { - owner = "rcasia"; - repo = "neotest-java"; - rev = "2234bfa8044dc39a8baf90470747c65e4623a222"; - sha256 = "0w5fvqic3qapi9ggfb81nqa9fl6jv831s91r0wgn4d7c35h0340r"; - }; - }) - (pkgs.vimUtils.buildVimPlugin { - pname = "neotest-vim-test"; - version = "2023-04-17"; - src = pkgs.fetchFromGitHub { - owner = "nvim-neotest"; - repo = "neotest-vim-test"; - rev = "75c4228882ae4883b11bfce9b8383e637eb44192"; - sha256 = "12ix1lzmqlk3iyngaafby9c02fcl9d5iva965miwxfljvmibjnbw"; - }; - }) - neotest - FixCursorHold-nvim - neotest-plenary - vim-test - neotest-python - neotest-vitest - ]; - extraConfigLua = '' - require("neotest").setup({ - adapters = { - require("neotest-java")({ - ignore_wrapper = false, - -- function to determine which runner to use based on project path - determine_runner = function(project_root_path) - -- return should be "maven" or "gradle" - return "maven" - end, - -- override the builtin runner discovery behaviour to always use given - -- tool. Default is "nil", so no override - force_runner = nil, - -- if the automatic runner discovery can't uniquely determine whether - -- to use Gradle or Maven, fallback to using this runner. Default is - -- "maven" - fallback_runner = "gradle" - }), - require("neotest-python")({ - dap = { justMyCode = false }, - }), - require "neotest-vim-test" { - ignore_file_types = { "python", "java", "vim", "lua", "javascript", "typescript" }, +{ + lib, + config, + pkgs, + ... +}: +{ + # TODO: Refactor this as neotest is supported on nixvim now + options = { + neotest.enable = lib.mkEnableOption "Enable neotest module"; + }; + config = lib.mkIf config.neotest.enable { + extraPlugins = with pkgs.vimPlugins; [ + (pkgs.vimUtils.buildVimPlugin { + pname = "neotest-java"; + version = "v0.9.0"; + src = pkgs.fetchFromGitHub { + owner = "rcasia"; + repo = "neotest-java"; + rev = "2234bfa8044dc39a8baf90470747c65e4623a222"; + sha256 = "0w5fvqic3qapi9ggfb81nqa9fl6jv831s91r0wgn4d7c35h0340r"; + }; + }) + (pkgs.vimUtils.buildVimPlugin { + pname = "neotest-vim-test"; + version = "2023-04-17"; + src = pkgs.fetchFromGitHub { + owner = "nvim-neotest"; + repo = "neotest-vim-test"; + rev = "75c4228882ae4883b11bfce9b8383e637eb44192"; + sha256 = "12ix1lzmqlk3iyngaafby9c02fcl9d5iva965miwxfljvmibjnbw"; + }; + }) + neotest + FixCursorHold-nvim + neotest-plenary + vim-test + neotest-python + neotest-vitest + ]; + extraConfigLua = '' + require("neotest").setup({ + adapters = { + require("neotest-java")({ + ignore_wrapper = false, + -- function to determine which runner to use based on project path + determine_runner = function(project_root_path) + -- return should be "maven" or "gradle" + return "maven" + end, + -- override the builtin runner discovery behaviour to always use given + -- tool. Default is "nil", so no override + force_runner = nil, + -- if the automatic runner discovery can't uniquely determine whether + -- to use Gradle or Maven, fallback to using this runner. Default is + -- "maven" + fallback_runner = "gradle" + }), + require("neotest-python")({ + dap = { justMyCode = false }, + }), + require "neotest-vim-test" { + ignore_file_types = { "python", "java", "vim", "lua", "javascript", "typescript" }, + }, }, - }, - output = { enabled = true, open_on_run = true }, - summary = { enabled = true, }, - }) - ''; - keymaps = [ - { - mode = "n"; - key = "tt"; - action = "lua require('neotest').run.run(vim.fn.expand '%')"; - options = { - desc = "Run File"; - silent = true; - }; - } - { - mode = "n"; - key = "tT"; - action = "lua require('neotest').run.run(vim.loop.cwd())"; - options = { - desc = "Run All Test Files"; - silent = true; - }; - } - { - mode = "n"; - key = "tr"; - action = "lua require('neotest').run.run()"; - options = { - desc = "Run Nearest"; - silent = true; - }; - } - { - mode = "n"; - key = "td"; - action = "lua require('neotest').run.run({strategy = 'dap'})"; - options = { - desc = "Run Nearest with debugger"; - silent = true; - }; - } - { - mode = "n"; - key = "ts"; - action = "lua require('neotest').summary.toggle()"; - options = { - desc = "Toggle Summary"; - silent = true; - }; - } - { - mode = "n"; - key = "to"; - action = "lua require('neotest').output.open{ enter = true, auto_close = true }"; - options = { - desc = "Show Output"; - silent = true; - }; - } - { - mode = "n"; - key = "tO"; - action = "lua require('neotest').output_panel.toggle()"; - options = { - desc = "Toggle Output Panel"; - silent = true; - }; - } - { - mode = "n"; - key = "tS"; - action = "lua require('neotest').run.stop()"; - options = { - desc = "Stop"; - silent = true; - }; - } - ]; + output = { enabled = true, open_on_run = true }, + summary = { enabled = true, }, + }) + ''; + keymaps = [ + { + mode = "n"; + key = "tt"; + action = "lua require('neotest').run.run(vim.fn.expand '%')"; + options = { + desc = "Run File"; + silent = true; + }; + } + { + mode = "n"; + key = "tT"; + action = "lua require('neotest').run.run(vim.loop.cwd())"; + options = { + desc = "Run All Test Files"; + silent = true; + }; + } + { + mode = "n"; + key = "tr"; + action = "lua require('neotest').run.run()"; + options = { + desc = "Run Nearest"; + silent = true; + }; + } + { + mode = "n"; + key = "td"; + action = "lua require('neotest').run.run({strategy = 'dap'})"; + options = { + desc = "Run Nearest with debugger"; + silent = true; + }; + } + { + mode = "n"; + key = "ts"; + action = "lua require('neotest').summary.toggle()"; + options = { + desc = "Toggle Summary"; + silent = true; + }; + } + { + mode = "n"; + key = "to"; + action = "lua require('neotest').output.open{ enter = true, auto_close = true }"; + options = { + desc = "Show Output"; + silent = true; + }; + } + { + mode = "n"; + key = "tO"; + action = "lua require('neotest').output_panel.toggle()"; + options = { + desc = "Toggle Output Panel"; + silent = true; + }; + } + { + mode = "n"; + key = "tS"; + action = "lua require('neotest').run.stop()"; + options = { + desc = "Stop"; + silent = true; + }; + } + ]; + }; } diff --git a/config/utils/nvim-autopairs.nix b/config/utils/nvim-autopairs.nix index 2af29dc..01c110a 100644 --- a/config/utils/nvim-autopairs.nix +++ b/config/utils/nvim-autopairs.nix @@ -1,5 +1,11 @@ +{ lib, config, ... }: { - plugins.nvim-autopairs = { - enable = false; + options = { + nvim-autopairs.enable = lib.mkEnableOption "Enable nvim-autopairs module"; + }; + config = lib.mkIf config.nvim-autopairs.enable { + plugins.nvim-autopairs = { + enable = true; + }; }; } diff --git a/config/utils/nvim-colorizer.nix b/config/utils/nvim-colorizer.nix index 81d8592..d392029 100644 --- a/config/utils/nvim-colorizer.nix +++ b/config/utils/nvim-colorizer.nix @@ -1,5 +1,12 @@ +{ lib, config, ... }: { - plugins.nvim-colorizer = { - enable = true; + options = { + nvim-colorizer.enable = lib.mkEnableOption "Enable nvim-colorizer module"; + }; + config = lib.mkIf config.nvim-colorizer.enable { + + plugins.nvim-colorizer = { + enable = true; + }; }; } diff --git a/config/utils/nvim-surround.nix b/config/utils/nvim-surround.nix index 6a7f4b1..b16d817 100644 --- a/config/utils/nvim-surround.nix +++ b/config/utils/nvim-surround.nix @@ -1,9 +1,16 @@ -{pkgs, ...}: { - extraPlugins = with pkgs.vimPlugins; [ - nvim-surround - ]; - - extraConfigLua = '' - require("nvim-surround").setup() - ''; +{ + lib, + config, + pkgs, + ... +}: +{ + options = { + nvim-surround.enable = lib.mkEnableOption "Enable nvim-surround module"; + }; + config = lib.mkIf config.nvim-surround.enable { + plugins.nvim-surround = { + enable = true; + }; + }; } diff --git a/config/utils/nvterm.nix b/config/utils/nvterm.nix index 397cc78..3c296ff 100644 --- a/config/utils/nvterm.nix +++ b/config/utils/nvterm.nix @@ -1,64 +1,74 @@ -{ pkgs, ... }: { - extraPlugins = [ - pkgs.vimPlugins.nvterm - ]; - extraConfigLua = '' - require("nvterm").setup({ - terminals = { - shell = vim.o.shell, - list = {}, - type_opts = { - float = { - relative = "editor", - row = 0.3, - col = 0.25, - width = 0.5, - height = 0.4, - border = "single", - }, - horizontal = { location = "rightbelow", split_ratio = 0.5 }, - vertical = { location = "rightbelow", split_ratio = 0.5 }, - }, - }, - behavior = { - autoclose_on_quit = { - enabled = false, - confirm = true, - }, - close_on_exit = true, - auto_insert = true, - }, - }) - local terminal = require("nvterm.terminal") + lib, + config, + pkgs, + ... +}: +{ + options = { + nvterm.enable = lib.mkEnableOption "Enable nvterm module"; + }; + config = lib.mkIf config.nvterm.enable { + extraPlugins = [ + pkgs.vimPlugins.nvterm + ]; + extraConfigLua = '' + require("nvterm").setup({ + terminals = { + shell = vim.o.shell, + list = {}, + type_opts = { + float = { + relative = "editor", + row = 0.3, + col = 0.25, + width = 0.5, + height = 0.4, + border = "single", + }, + horizontal = { location = "rightbelow", split_ratio = 0.5 }, + vertical = { location = "rightbelow", split_ratio = 0.5 }, + }, + }, + behavior = { + autoclose_on_quit = { + enabled = false, + confirm = true, + }, + close_on_exit = true, + auto_insert = true, + }, + }) + local terminal = require("nvterm.terminal") - local toggle_modes = { "n", "t" } - local mappings = { - { - toggle_modes, - "", - function() - terminal.toggle("horizontal") - end, - }, - { - toggle_modes, - "", - function() - terminal.toggle("vertical") - end, - }, - { - toggle_modes, - "", - function() - terminal.toggle("float") - end, - }, - } - local opts = { noremap = true, silent = true } - for _, mapping in ipairs(mappings) do - vim.keymap.set(mapping[1], mapping[2], mapping[3], opts) - end - ''; + local toggle_modes = { "n", "t" } + local mappings = { + { + toggle_modes, + "", + function() + terminal.toggle("horizontal") + end, + }, + { + toggle_modes, + "", + function() + terminal.toggle("vertical") + end, + }, + { + toggle_modes, + "", + function() + terminal.toggle("float") + end, + }, + } + local opts = { noremap = true, silent = true } + for _, mapping in ipairs(mappings) do + vim.keymap.set(mapping[1], mapping[2], mapping[3], opts) + end + ''; + }; } diff --git a/config/utils/oil.nix b/config/utils/oil.nix index 30a093c..e52a134 100644 --- a/config/utils/oil.nix +++ b/config/utils/oil.nix @@ -1,54 +1,64 @@ +{ lib, config, ... }: { - plugins.oil = { - enable = true; - settings = { - useDefaultKeymaps = true; - deleteToTrash = true; - viewOptions = { - showHidden = true; - }; - preview = { - border = "rounded"; - }; + options = { + oil.enable = lib.mkEnableOption "Enable oil module"; + }; + config = lib.mkIf config.oil.enable { + plugins.oil = { + enable = true; + settings = { + deleteToTrash = true; + useDefaultKeymaps = true; + viewOptions = { + showHidden = true; + }; + preview = { + border = "rounded"; + win_options = { + winblend = 0; + }; - float = { - padding = 2; - maxWidth = 0; # ''math.ceil(vim.o.lines * 0.8 - 4)''; - maxHeight = 0; # ''math.ceil(vim.o.columns * 0.8)''; - border = "rounded"; # 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open - winOptions = { - winblend = 0; }; - }; - keymaps = { - "g?" = "actions.show_help"; - "" = "actions.select"; - "" = "actions.select_vsplit"; - "" = "actions.select_split"; # this is used to navigate left - "" = "actions.select_tab"; - "" = "actions.preview"; - "" = "actions.close"; - "" = "actions.refresh"; - "-" = "actions.parent"; - "_" = "actions.open_cwd"; - "`" = "actions.cd"; - "~" = "actions.tcd"; - "gs" = "actions.change_sort"; - "gx" = "actions.open_external"; - "g." = "actions.toggle_hidden"; - "q" = "actions.close"; + + float = { + padding = 2; + maxWidth = 0; # ''math.ceil(vim.o.lines * 0.8 - 4)''; + maxHeight = 0; # ''math.ceil(vim.o.columns * 0.8)''; + border = "rounded"; # 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open + winOptions = { + winblend = 0; + }; + }; + keymaps = { + "g?" = "actions.show_help"; + "" = "actions.select"; + "" = "actions.select_vsplit"; + "" = "actions.select_split"; # this is used to navigate left + "" = "actions.select_tab"; + "" = "actions.preview"; + "" = "actions.close"; + "" = "actions.refresh"; + "-" = "actions.parent"; + "_" = "actions.open_cwd"; + "`" = "actions.cd"; + "~" = "actions.tcd"; + "gs" = "actions.change_sort"; + "gx" = "actions.open_external"; + "g." = "actions.toggle_hidden"; + "q" = "actions.close"; + }; }; }; + keymaps = [ + { + mode = "n"; + key = "o"; + action = ":Oil --float"; + options = { + desc = "Open parent directory"; + silent = true; + }; + } + ]; }; - keymaps = [ - { - mode = "n"; - key = "o"; - action = ":Oil --float"; - options = { - desc = "Open parent directory"; - silent = true; - }; - } - ]; } diff --git a/config/utils/persistence.nix b/config/utils/persistence.nix index eb7cde3..58768b2 100644 --- a/config/utils/persistence.nix +++ b/config/utils/persistence.nix @@ -1,5 +1,11 @@ +{ lib, config, ... }: { - plugins.persistence = { - enable = true; + options = { + persistence.enable = lib.mkEnableOption "Enable persistence module"; + }; + config = lib.mkIf config.persistence.enable { + plugins.persistence = { + enable = true; + }; }; } diff --git a/config/utils/plenary.nix b/config/utils/plenary.nix index 133b26f..9a1e8b0 100644 --- a/config/utils/plenary.nix +++ b/config/utils/plenary.nix @@ -1,5 +1,16 @@ -{pkgs, ...}: { - extraPlugins = with pkgs.vimPlugins; [ - plenary-nvim - ]; +{ + lib, + config, + pkgs, + ... +}: +{ + options = { + plenary.enable = lib.mkEnableOption "Enable plenary module"; + }; + config = lib.mkIf config.plenary.enable { + extraPlugins = with pkgs.vimPlugins; [ + plenary-nvim + ]; + }; } diff --git a/config/utils/project-nvim.nix b/config/utils/project-nvim.nix index b411ec7..736495c 100644 --- a/config/utils/project-nvim.nix +++ b/config/utils/project-nvim.nix @@ -1,6 +1,12 @@ +{ lib, config, ... }: { - plugins.project-nvim = { - enable = true; - enableTelescope = true; + options = { + project-nvim.enable = lib.mkEnableOption "Enable project-nvim module"; + }; + config = lib.mkIf config.project-nvim.enable { + plugins.project-nvim = { + enable = true; + enableTelescope = true; + }; }; } diff --git a/config/utils/sidebar.nix b/config/utils/sidebar.nix index 0cc4316..cae1145 100644 --- a/config/utils/sidebar.nix +++ b/config/utils/sidebar.nix @@ -1,55 +1,66 @@ -{pkgs, ...}: { - extraPlugins = with pkgs.vimUtils; [ - (buildVimPlugin { - pname = "sidebar.nvim"; - version = "2024-02-07"; - src = pkgs.fetchFromGitHub { - owner = "sidebar-nvim"; - repo = "sidebar.nvim"; - rev = "5695712eef6288fff667343c4ae77c54911bdb1b"; - sha256 = "1p12189367x0x26cys9wxipzwr3i0bmz4lb0s79ki0a49d6zja2c"; - }; - }) - ]; - extraConfigLua = '' - local sidebar = require("sidebar-nvim") - sidebar.setup({ - disable_default_keybindings = 0, - bindings = nil, - open = false, - side = "left", - initial_width = 32, - hide_statusline = false, - update_interval = 1000, - sections = { "git", "containers" }, - section_separator = {"", "-----", ""}, - section_title_separator = {""}, - containers = { - attach_shell = "/bin/sh", show_all = true, interval = 5000, - }, - datetime = { format = "%a %b %d, %H:%M", clocks = { { name = "local" } } }, - todos = { ignored_paths = {} }, - ["git"] = { - icon = "", --  - }, - }) - cmd = { - "SidebarNvimToggle", - "SidebarNvimOpen", - "SidebarNvimFocus", - "SidebarNvimUpdate", +{ + lib, + config, + pkgs, + ... +}: +{ + options = { + sidebar.enable = lib.mkEnableOption "Enable sidebar module"; + }; + config = lib.mkIf config.sidebar.enable { + extraPlugins = with pkgs.vimUtils; [ + (buildVimPlugin { + pname = "sidebar.nvim"; + version = "2024-02-07"; + src = pkgs.fetchFromGitHub { + owner = "sidebar-nvim"; + repo = "sidebar.nvim"; + rev = "5695712eef6288fff667343c4ae77c54911bdb1b"; + sha256 = "1p12189367x0x26cys9wxipzwr3i0bmz4lb0s79ki0a49d6zja2c"; + }; + }) + ]; + extraConfigLua = '' + local sidebar = require("sidebar-nvim") + sidebar.setup({ + disable_default_keybindings = 0, + bindings = nil, + open = false, + side = "left", + initial_width = 32, + hide_statusline = false, + update_interval = 1000, + sections = { "git", "containers" }, + section_separator = {"", "-----", ""}, + section_title_separator = {""}, + containers = { + attach_shell = "/bin/sh", show_all = true, interval = 5000, }, - ''; + datetime = { format = "%a %b %d, %H:%M", clocks = { { name = "local" } } }, + todos = { ignored_paths = {} }, + ["git"] = { + icon = "", --  + }, + }) + cmd = { + "SidebarNvimToggle", + "SidebarNvimOpen", + "SidebarNvimFocus", + "SidebarNvimUpdate", + }, + ''; - keymaps = [ - { - mode = "n"; - key = "e"; - action = ":SidebarNvimToggle"; - options = { - desc = "Toggle Explorer"; - silent = true; - }; - } - ]; + keymaps = [ + { + mode = "n"; + key = "e"; + action = ":SidebarNvimToggle"; + options = { + desc = "Toggle Explorer"; + silent = true; + }; + } + ]; + }; } diff --git a/config/utils/tmux-navigator.nix b/config/utils/tmux-navigator.nix index efb21c3..d0dc833 100644 --- a/config/utils/tmux-navigator.nix +++ b/config/utils/tmux-navigator.nix @@ -1,5 +1,11 @@ +{ lib, config, ... }: { - plugins.tmux-navigator = { - enable = true; + options = { + tmux-navigator.enable = lib.mkEnableOption "Enable tmux-navigator module"; + }; + config = lib.mkIf config.tmux-navigator.enable { + plugins.tmux-navigator = { + enable = true; + }; }; } diff --git a/config/utils/todo-comments.nix b/config/utils/todo-comments.nix index 96878bb..65f09a3 100644 --- a/config/utils/todo-comments.nix +++ b/config/utils/todo-comments.nix @@ -1,5 +1,11 @@ +{ lib, config, ... }: { - plugins.todo-comments = { - enable = true; + options = { + todo-comments.enable = lib.mkEnableOption "Enable todo-comments module"; + }; + config = lib.mkIf config.todo-comments.enable { + plugins.todo-comments = { + enable = true; + }; }; } diff --git a/config/utils/ultimate-autopair.nix b/config/utils/ultimate-autopair.nix index 5730e45..a89c7c5 100644 --- a/config/utils/ultimate-autopair.nix +++ b/config/utils/ultimate-autopair.nix @@ -1,17 +1,29 @@ -{pkgs, ...}: { - extraPlugins = with pkgs.vimUtils; [ - (buildVimPlugin { - pname = "ultimate-autopair.nvim"; - version = "2024-02-05"; - src = pkgs.fetchFromGitHub { - owner = "altermo"; - repo = "ultimate-autopair.nvim"; - rev = "25c13e0ce167db0255456cac10158b27d2be30c0"; - sha256 = "0bsxfj6g8fii9nn92vl15hdhafx3fikgiz4srr7y10pxz01c5s4c"; - }; - }) - ]; - extraConfigLua = '' - require('ultimate-autopair').setup() - ''; +{ + lib, + config, + pkgs, + ... +}: +{ + options = { + ultimate-autopair.enable = lib.mkEnableOption "Enable ultimate-autopair module"; + }; + config = lib.mkIf config.ultimate-autopair.enable { + + extraPlugins = with pkgs.vimUtils; [ + (buildVimPlugin { + pname = "ultimate-autopair.nvim"; + version = "2024-02-05"; + src = pkgs.fetchFromGitHub { + owner = "altermo"; + repo = "ultimate-autopair.nvim"; + rev = "25c13e0ce167db0255456cac10158b27d2be30c0"; + sha256 = "0bsxfj6g8fii9nn92vl15hdhafx3fikgiz4srr7y10pxz01c5s4c"; + }; + }) + ]; + extraConfigLua = '' + require('ultimate-autopair').setup() + ''; + }; } diff --git a/config/utils/undotree.nix b/config/utils/undotree.nix index 1d6923c..ef7eddd 100644 --- a/config/utils/undotree.nix +++ b/config/utils/undotree.nix @@ -1,20 +1,26 @@ +{ lib, config, ... }: { - plugins.undotree = { - enable = true; - settings = { - autoOpenDiff = true; - focusOnToggle = true; - }; + options = { + undotree.enable = lib.mkEnableOption "Enable undotree module"; }; - keymaps = [ - { - mode = "n"; - key = "ut"; - action = "UndotreeToggle"; - options = { - silent = true; - desc = "Undotree"; + config = lib.mkIf config.undotree.enable { + plugins.undotree = { + enable = true; + settings = { + autoOpenDiff = true; + focusOnToggle = true; }; - } - ]; + }; + keymaps = [ + { + mode = "n"; + key = "ut"; + action = "UndotreeToggle"; + options = { + silent = true; + desc = "Undotree"; + }; + } + ]; + }; } diff --git a/config/utils/wakatime.nix b/config/utils/wakatime.nix index 2ee4576..564b260 100644 --- a/config/utils/wakatime.nix +++ b/config/utils/wakatime.nix @@ -1,5 +1,11 @@ +{ lib, config, ... }: { - plugins.wakatime = { - enable = true; + options = { + wakatime.enable = lib.mkEnableOption "Enable wakatime module"; + }; + config = lib.mkIf config.wakatime.enable { + plugins.wakatime = { + enable = true; + }; }; } diff --git a/config/utils/which-key.nix b/config/utils/which-key.nix new file mode 100644 index 0000000..7619077 --- /dev/null +++ b/config/utils/which-key.nix @@ -0,0 +1,123 @@ +{ lib, config, ... }: +{ + options = { + which-key.enable = lib.mkEnableOption "Enable which-key module"; + }; + config = lib.mkIf config.which-key.enable { + plugins.which-key = { + enable = true; + settings = { + icons = { + breadcrumb = "»"; + group = "+"; + separator = ""; # ➜ + }; + spec = [ + # Harpoon Configs + { + __unkeyed-1 = "h"; + mode = "n"; + group = "+harpoon"; + icon = "󱡁"; + } + { + __unkeyed-1 = "ha"; + mode = "n"; + group = "Add file to Harpoon"; + } + { + __unkeyed-1 = "hj"; + mode = "n"; + group = "Harpoon File 1"; + } + { + __unkeyed-1 = "hk"; + mode = "n"; + group = "Harpoon File 2"; + } + { + __unkeyed-1 = "hl"; + mode = "n"; + group = "Harpoon File 3"; + } + { + __unkeyed-1 = "hm"; + mode = "n"; + group = "Harpoon File 4"; + } + + # General Mappings + { + __unkeyed-1 = "c"; + mode = [ + "n" + "v" + ]; + group = "+code"; + } + { + __unkeyed-1 = "d"; + mode = [ + "n" + "v" + ]; + group = "+debug"; + } + { + __unkeyed-1 = "f"; + mode = "n"; + group = "+find/file"; + } + + { + __unkeyed-1 = "g"; + mode = [ + "n" + "v" + ]; + group = "+git"; + } + + { + __unkeyed-1 = "q"; + mode = "n"; + group = "+quit/session"; + } + + { + __unkeyed-1 = "s"; + mode = "n"; + group = "+search"; + } + { + __unkeyed-1 = ""; + mode = "n"; + group = "+tab"; + } + + { + __unkeyed-1 = "t"; + mode = "n"; + group = "+test"; + } + + { + __unkeyed-1 = "u"; + mode = "n"; + group = "+ui"; + } + + { + __unkeyed-1 = "w"; + mode = "n"; + group = "+windows"; + } + ]; + win = { + border = "none"; + wo.winblend = 0; + }; + }; + }; + }; +} diff --git a/config/utils/whichkey.nix b/config/utils/whichkey.nix deleted file mode 100644 index dce5b7c..0000000 --- a/config/utils/whichkey.nix +++ /dev/null @@ -1,117 +0,0 @@ -{ - plugins.which-key = { - enable = true; - settings = { - icons = { - breadcrumb = "»"; - group = "+"; - separator = ""; # ➜ - }; - spec = [ - # Harpoon Configs - { - __unkeyed-1 = "h"; - mode = "n"; - group = "+harpoon"; - icon = "󱡁"; - } - { - __unkeyed-1 = "ha"; - mode = "n"; - group = "Add file to Harpoon"; - } - { - __unkeyed-1 = "hj"; - mode = "n"; - group = "Harpoon File 1"; - } - { - __unkeyed-1 = "hk"; - mode = "n"; - group = "Harpoon File 2"; - } - { - __unkeyed-1 = "hl"; - mode = "n"; - group = "Harpoon File 3"; - } - { - __unkeyed-1 = "hm"; - mode = "n"; - group = "Harpoon File 4"; - } - - # General Mappings - { - __unkeyed-1 = "c"; - mode = [ - "n" - "v" - ]; - group = "+code"; - } - { - __unkeyed-1 = "d"; - mode = [ - "n" - "v" - ]; - group = "+debug"; - } - { - __unkeyed-1 = "f"; - mode = "n"; - group = "+find/file"; - } - - { - __unkeyed-1 = "g"; - mode = [ - "n" - "v" - ]; - group = "+git"; - } - - { - __unkeyed-1 = "q"; - mode = "n"; - group = "+quit/session"; - } - - { - __unkeyed-1 = "s"; - mode = "n"; - group = "+search"; - } - { - __unkeyed-1 = ""; - mode = "n"; - group = "+tab"; - } - - { - __unkeyed-1 = "t"; - mode = "n"; - group = "+test"; - } - - { - __unkeyed-1 = "u"; - mode = "n"; - group = "+ui"; - } - - { - __unkeyed-1 = "w"; - mode = "n"; - group = "+windows"; - } - ]; - win = { - border = "none"; - wo.winblend = 0; - }; - }; - }; -} diff --git a/config/utils/wilder.nix b/config/utils/wilder.nix index e16ecbb..4248041 100644 --- a/config/utils/wilder.nix +++ b/config/utils/wilder.nix @@ -1,47 +1,54 @@ +{ lib, config, ... }: { - plugins.wilder = { - enable = false; - modes = [ - ":" - "/" - "?" - ]; - pipeline = [ - '' - wilder.branch( - wilder.python_file_finder_pipeline({ - file_command = function(ctx, arg) - if string.find(arg, '.') ~= nil then - return {'fd', '-tf', '-H'} - else - return {'fd', '-tf'} - end - end, - dir_command = {'fd', '-td'}, - filters = {'cpsm_filter'}, - }), - wilder.substitute_pipeline({ - pipeline = wilder.python_search_pipeline({ - skip_cmdtype_check = 1, - pattern = wilder.python_fuzzy_pattern({ - start_at_boundary = 0, - }), - }), - }), - wilder.cmdline_pipeline({ - language = 'python', - fuzzy = 1, + options = { + wilder.enable = lib.mkEnableOption "Enable wilder module"; + }; + config = lib.mkIf config.wilder.enable { + plugins.wilder = { + enable = true; + modes = [ + ":" + "/" + "?" + ]; + pipeline = [ + '' + wilder.branch( + wilder.python_file_finder_pipeline({ + file_command = function(ctx, arg) + if string.find(arg, '.') ~= nil then + return {'fd', '-tf', '-H'} + else + return {'fd', '-tf'} + end + end, + dir_command = {'fd', '-td'}, + filters = {'cpsm_filter'}, + }), + wilder.substitute_pipeline({ + pipeline = wilder.python_search_pipeline({ + skip_cmdtype_check = 1, + pattern = wilder.python_fuzzy_pattern({ + start_at_boundary = 0, }), - { - wilder.check(function(ctx, x) return x == "" end), - wilder.history(), - }, - wilder.python_search_pipeline({ - pattern = wilder.python_fuzzy_pattern({ - start_at_boundary = 0, - }), - }) - ) '' - ]; + }), + }), + wilder.cmdline_pipeline({ + language = 'python', + fuzzy = 1, + }), + { + wilder.check(function(ctx, x) return x == "" end), + wilder.history(), + }, + wilder.python_search_pipeline({ + pattern = wilder.python_fuzzy_pattern({ + start_at_boundary = 0, + }), + }) + ) + '' + ]; + }; }; } From 08ab74b37537cfdf71a9c5ee5c85a794a17a0304 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:02:27 -0300 Subject: [PATCH 17/20] refactor: keymaps.nix -> keys.nix + make it modular --- config/keymaps.nix | 458 -------------------------------------------- config/keys.nix | 462 +++++++++++++++++++++++++++++++++++++++++++++ config/sets.nix | 145 -------------- 3 files changed, 462 insertions(+), 603 deletions(-) delete mode 100644 config/keymaps.nix create mode 100644 config/keys.nix delete mode 100644 config/sets.nix diff --git a/config/keymaps.nix b/config/keymaps.nix deleted file mode 100644 index 840a501..0000000 --- a/config/keymaps.nix +++ /dev/null @@ -1,458 +0,0 @@ -# Thanks for the keybinds primeagen and folke! -{ - globals.mapleader = " "; - - # TODO: Move general mappings to which-key - keymaps = [ - # Disable arrow keys - { - mode = [ - "n" - "i" - ]; - key = ""; - action = ""; - options = { - silent = true; - noremap = true; - desc = "Disable Up arrow key"; - }; - } - { - mode = [ - "n" - "i" - ]; - key = ""; - action = ""; - options = { - silent = true; - noremap = true; - desc = "Disable Down arrow key"; - }; - } - { - mode = [ - "n" - "i" - ]; - key = ""; - action = ""; - options = { - silent = true; - noremap = true; - desc = "Disable Right arrow key"; - }; - } - { - mode = [ - "n" - "i" - ]; - key = ""; - action = ""; - options = { - silent = true; - noremap = true; - desc = "Disable Left arrow key"; - }; - } - # Tabs - { - mode = "n"; - key = "l"; - action = "tablast"; - options = { - silent = true; - desc = "Last tab"; - }; - } - - { - mode = "n"; - key = "f"; - action = "tabfirst"; - options = { - silent = true; - desc = "First Tab"; - }; - } - - { - mode = "n"; - key = ""; - action = "tabnew"; - options = { - silent = true; - desc = "New Tab"; - }; - } - - { - mode = "n"; - key = "]"; - action = "tabnext"; - options = { - silent = true; - desc = "Next Tab"; - }; - } - - { - mode = "n"; - key = "d"; - action = "tabclose"; - options = { - silent = true; - desc = "Close tab"; - }; - } - - { - mode = "n"; - key = "["; - action = "tabprevious"; - options = { - silent = true; - desc = "Previous Tab"; - }; - } - - # Windows - { - mode = "n"; - key = "ww"; - action = "p"; - options = { - silent = true; - desc = "Other window"; - }; - } - - { - mode = "n"; - key = "wd"; - action = "c"; - options = { - silent = true; - desc = "Delete window"; - }; - } - - { - mode = "n"; - key = "w-"; - action = "s"; - options = { - silent = true; - desc = "Split window below"; - }; - } - - { - mode = "n"; - key = "w|"; - action = "v"; - options = { - silent = true; - desc = "Split window right"; - }; - } - - # { - # mode = "n"; - # key = "-"; - # action = "s"; - # options = { - # silent = true; - # desc = "Split window below"; - # }; - # } - - # { - # mode = "n"; - # key = "|"; - # action = "v"; - # options = { - # silent = true; - # desc = "Split window right"; - # }; - # } - - { - mode = "n"; - key = ""; - action = "w"; - options = { - silent = true; - desc = "Save file"; - }; - } - - # Quit/Session - { - mode = "n"; - key = "qq"; - action = "quitall"; - options = { - silent = true; - desc = "Quit all"; - }; - } - - { - mode = "n"; - key = "qs"; - action = ":lua require('persistence').load()"; - options = { - silent = true; - desc = "Restore session"; - }; - } - - { - mode = "n"; - key = "ql"; - action = "lua require('persistence').load({ last = true })"; - options = { - silent = true; - desc = "Restore last session"; - }; - } - - { - mode = "n"; - key = "qd"; - action = "lua require('persistence').stop()"; - options = { - silent = true; - desc = "Don't save current session"; - }; - } - - # Toggle - { - mode = "n"; - key = "ul"; - action = ":lua ToggleLineNumber()"; - options = { - silent = true; - desc = "Toggle Line Numbers"; - }; - } - - { - mode = "n"; - key = "uL"; - action = ":lua ToggleRelativeLineNumber()"; - options = { - silent = true; - desc = "Toggle Relative Line Numbers"; - }; - } - - { - mode = "n"; - key = "uw"; - action = ":lua ToggleWrap()"; - options = { - silent = true; - desc = "Toggle Line Wrap"; - }; - } - - # Inlay Hints - { - mode = "n"; - key = "uh"; - action = ":lua ToggleInlayHints()"; - options = { - silent = true; - desc = "Toggle Inlay Hints"; - }; - } - - { - mode = "v"; - key = "J"; - action = ":m '>+1gv=gv"; - options = { - silent = true; - desc = "Move up when line is highlighted"; - }; - } - - { - mode = "v"; - key = "K"; - action = ":m '<-2gv=gv"; - options = { - silent = true; - desc = "Move down when line is highlighted"; - }; - } - - { - mode = "n"; - key = "J"; - action = "mzJ`z"; - options = { - silent = true; - desc = "Allow cursor to stay in the same place after appeding to current line"; - }; - } - - { - mode = "v"; - key = "<"; - action = " + y or just y to have it just in vim - { - mode = [ - "n" - "v" - ]; - key = "y"; - action = "\"+y"; - options = { - desc = "Copy to system clipboard"; - }; - } - - { - mode = [ - "n" - "v" - ]; - key = "Y"; - action = "\"+Y"; - options = { - desc = "Copy to system clipboard"; - }; - } - - # Delete to void register - { - mode = [ - "n" - "v" - ]; - key = "D"; - action = "\"_d"; - options = { - desc = "Delete to void register"; - }; - } - - # instead of pressing esc just because - { - mode = "i"; - key = ""; - action = ""; - } - - { - mode = "n"; - key = ""; - action = "!tmux new tmux-sessionizer"; - options = { - desc = "Switch between projects"; - }; - } - - # Set highlight on search, but clear on pressing in normal mode - { - mode = "n"; - key = ""; - action = "nohlsearch"; - } - ]; -} diff --git a/config/keys.nix b/config/keys.nix new file mode 100644 index 0000000..5398e3f --- /dev/null +++ b/config/keys.nix @@ -0,0 +1,462 @@ +# Thanks for the keybinds primeagen and folke! +{ lib, config, ... }: +{ + options = { + keys.enable = lib.mkEnableOption "Enable keys module"; + }; + config = lib.mkIf config.keys.enable { + globals.mapleader = " "; + keymaps = [ + # Disable arrow keys + { + mode = [ + "n" + "i" + ]; + key = ""; + action = ""; + options = { + silent = true; + noremap = true; + desc = "Disable Up arrow key"; + }; + } + { + mode = [ + "n" + "i" + ]; + key = ""; + action = ""; + options = { + silent = true; + noremap = true; + desc = "Disable Down arrow key"; + }; + } + { + mode = [ + "n" + "i" + ]; + key = ""; + action = ""; + options = { + silent = true; + noremap = true; + desc = "Disable Right arrow key"; + }; + } + { + mode = [ + "n" + "i" + ]; + key = ""; + action = ""; + options = { + silent = true; + noremap = true; + desc = "Disable Left arrow key"; + }; + } + # Tabs + { + mode = "n"; + key = "l"; + action = "tablast"; + options = { + silent = true; + desc = "Last tab"; + }; + } + + { + mode = "n"; + key = "f"; + action = "tabfirst"; + options = { + silent = true; + desc = "First Tab"; + }; + } + + { + mode = "n"; + key = ""; + action = "tabnew"; + options = { + silent = true; + desc = "New Tab"; + }; + } + + { + mode = "n"; + key = "]"; + action = "tabnext"; + options = { + silent = true; + desc = "Next Tab"; + }; + } + + { + mode = "n"; + key = "d"; + action = "tabclose"; + options = { + silent = true; + desc = "Close tab"; + }; + } + + { + mode = "n"; + key = "["; + action = "tabprevious"; + options = { + silent = true; + desc = "Previous Tab"; + }; + } + + # Windows + { + mode = "n"; + key = "ww"; + action = "p"; + options = { + silent = true; + desc = "Other window"; + }; + } + + { + mode = "n"; + key = "wd"; + action = "c"; + options = { + silent = true; + desc = "Delete window"; + }; + } + + { + mode = "n"; + key = "w-"; + action = "s"; + options = { + silent = true; + desc = "Split window below"; + }; + } + + { + mode = "n"; + key = "w|"; + action = "v"; + options = { + silent = true; + desc = "Split window right"; + }; + } + + # { + # mode = "n"; + # key = "-"; + # action = "s"; + # options = { + # silent = true; + # desc = "Split window below"; + # }; + # } + + # { + # mode = "n"; + # key = "|"; + # action = "v"; + # options = { + # silent = true; + # desc = "Split window right"; + # }; + # } + + { + mode = "n"; + key = ""; + action = "w"; + options = { + silent = true; + desc = "Save file"; + }; + } + + # Quit/Session + { + mode = "n"; + key = "qq"; + action = "quitall"; + options = { + silent = true; + desc = "Quit all"; + }; + } + + { + mode = "n"; + key = "qs"; + action = ":lua require('persistence').load()"; + options = { + silent = true; + desc = "Restore session"; + }; + } + + { + mode = "n"; + key = "ql"; + action = "lua require('persistence').load({ last = true })"; + options = { + silent = true; + desc = "Restore last session"; + }; + } + + { + mode = "n"; + key = "qd"; + action = "lua require('persistence').stop()"; + options = { + silent = true; + desc = "Don't save current session"; + }; + } + + # Toggle + { + mode = "n"; + key = "ul"; + action = ":lua ToggleLineNumber()"; + options = { + silent = true; + desc = "Toggle Line Numbers"; + }; + } + + { + mode = "n"; + key = "uL"; + action = ":lua ToggleRelativeLineNumber()"; + options = { + silent = true; + desc = "Toggle Relative Line Numbers"; + }; + } + + { + mode = "n"; + key = "uw"; + action = ":lua ToggleWrap()"; + options = { + silent = true; + desc = "Toggle Line Wrap"; + }; + } + + # Inlay Hints + { + mode = "n"; + key = "uh"; + action = ":lua ToggleInlayHints()"; + options = { + silent = true; + desc = "Toggle Inlay Hints"; + }; + } + + { + mode = "v"; + key = "J"; + action = ":m '>+1gv=gv"; + options = { + silent = true; + desc = "Move up when line is highlighted"; + }; + } + + { + mode = "v"; + key = "K"; + action = ":m '<-2gv=gv"; + options = { + silent = true; + desc = "Move down when line is highlighted"; + }; + } + + { + mode = "n"; + key = "J"; + action = "mzJ`z"; + options = { + silent = true; + desc = "Allow cursor to stay in the same place after appeding to current line"; + }; + } + + { + mode = "v"; + key = "<"; + action = " + y or just y to have it just in vim + { + mode = [ + "n" + "v" + ]; + key = "y"; + action = "\"+y"; + options = { + desc = "Copy to system clipboard"; + }; + } + + { + mode = [ + "n" + "v" + ]; + key = "Y"; + action = "\"+Y"; + options = { + desc = "Copy to system clipboard"; + }; + } + + # Delete to void register + { + mode = [ + "n" + "v" + ]; + key = "D"; + action = "\"_d"; + options = { + desc = "Delete to void register"; + }; + } + + # instead of pressing esc just because + { + mode = "i"; + key = ""; + action = ""; + } + + { + mode = "n"; + key = ""; + action = "!tmux new tmux-sessionizer"; + options = { + desc = "Switch between projects"; + }; + } + + # Set highlight on search, but clear on pressing in normal mode + { + mode = "n"; + key = ""; + action = "nohlsearch"; + } + ]; + }; +} diff --git a/config/sets.nix b/config/sets.nix deleted file mode 100644 index 73ca811..0000000 --- a/config/sets.nix +++ /dev/null @@ -1,145 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: -{ - config = { - opts = { - # Enable relative line numbers - number = true; - relativenumber = true; - - # Set tabs to 2 spaces - tabstop = 2; - softtabstop = 2; - showtabline = 2; - expandtab = true; - - # Enable auto indenting and set it to spaces - smartindent = true; - shiftwidth = 2; - - # Enable smart indenting (see https://stackoverflow.com/questions/1204149/smart-wrap-in-vim) - breakindent = true; - - # Enable incremental searching - hlsearch = true; - incsearch = true; - - # Enable text wrap - wrap = true; - - # Better splitting - splitbelow = true; - splitright = true; - - # Enable mouse mode - mouse = "a"; # Mouse - - # Enable ignorecase + smartcase for better searching - ignorecase = true; - smartcase = true; # Don't ignore case with capitals - grepprg = "rg --vimgrep"; - grepformat = "%f:%l:%c:%m"; - - # Decrease updatetime - updatetime = 50; # faster completion (4000ms default) - - # Set completeopt to have a better completion experience - completeopt = [ - "menuone" - "noselect" - "noinsert" - ]; # mostly just for cmp - - # Enable persistent undo history - swapfile = false; - backup = false; - undofile = true; - - # Enable 24-bit colors - termguicolors = true; - - # Enable the sign column to prevent the screen from jumping - signcolumn = "yes"; - - # Enable cursor line highlight - cursorline = false; # Highlight the line where the cursor is located - - # Set fold settings - # These options were reccommended by nvim-ufo - # See: https://github.com/kevinhwang91/nvim-ufo#minimal-configuration - foldcolumn = "0"; - foldlevel = 99; - foldlevelstart = 99; - foldenable = true; - - # Always keep 8 lines above/below cursor unless at start/end of file - scrolloff = 8; - - # Place a column line - colorcolumn = "80"; - - # Reduce which-key timeout - timeoutlen = 200; - - # Set encoding type - encoding = "utf-8"; - fileencoding = "utf-8"; - - # Change cursor options - guicursor = [ - "n-v-c:block" # Normal, visual, command-line: block cursor - "i-ci-ve:block" # Insert, command-line insert, visual-exclude: vertical bar cursor with block cursor, use "ver25" for 25% width - "r-cr:hor20" # Replace, command-line replace: horizontal bar cursor with 20% height - "o:hor50" # Operator-pending: horizontal bar cursor with 50% height - "a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor" # All modes: blinking settings - "sm:block-blinkwait175-blinkoff150-blinkon175" # Showmatch: block cursor with specific blinking settings - ]; - - # Enable chars list - list = true; # Show invisible characters (tabs, eol, ...) - listchars = "eol:↲,tab:|->,lead:·,space: ,trail:•,extends:→,precedes:←,nbsp:␣"; - - # More space in the neovim command line for displaying messages - cmdheight = 2; - - # We don't need to see things like INSERT anymore - showmode = false; - - # Maximum number of items to show in the popup menu (0 means "use available screen space") - pumheight = 0; - - # Use conform-nvim for gq formatting. ('formatexpr' is set to vim.lsp.formatexpr(), so you can format lines via gq if the language server supports it) - formatexpr = "v:lua.require'conform'.formatexpr()"; - - laststatus = 3; # (https://neovim.io/doc/user/options.html#'laststatus') - - inccommand = "split"; # (https://neovim.io/doc/user/options.html#'inccommand') - }; - - extraConfigLua = '' - local opt = vim.opt - local g = vim.g - local o = vim.o - -- Neovide - if g.neovide then - g.neovide_fullscreen = false - g.neovide_hide_mouse_when_typing = false - g.neovide_refresh_rate = 165 - g.neovide_cursor_vfx_mode = "ripple" - g.neovide_cursor_animate_command_line = true - g.neovide_cursor_animate_in_insert_mode = true - g.neovide_cursor_vfx_particle_lifetime = 5.0 - g.neovide_cursor_vfx_particle_density = 14.0 - g.neovide_cursor_vfx_particle_speed = 12.0 - g.neovide_transparency = 0.8 - - -- Neovide Fonts - o.guifont = "JetBrainsMono Nerd Font:h14:Medium:i" - end - ''; - }; -} From 17c8da6f58574efd674f1dc3b2f93931accf9eee Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:03:06 -0300 Subject: [PATCH 18/20] refactor: modularize main import file --- config/default.nix | 114 ++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 78 deletions(-) diff --git a/config/default.nix b/config/default.nix index a1e7827..ada7e66 100644 --- a/config/default.nix +++ b/config/default.nix @@ -1,83 +1,41 @@ +{ lib, config, ... }: { # Import all your configuration modules here imports = [ - ./sets.nix - ./keymaps.nix - - ./bufferlines/bufferline.nix - - ./colorschemes/base16.nix - ./colorschemes/catppuccin.nix - ./colorschemes/rose-pine.nix - - ./completion/cmp.nix - ./completion/copilot.nix - ./completion/lspkind.nix - - ./dap/dap.nix - - ./filetrees/neo-tree.nix - ./git/gitsigns.nix - ./git/diffview.nix - ./git/lazygit.nix - ./git/neogit.nix - - ./languages/nvim-jdtls.nix - ./languages/nvim-lint.nix - ./languages/treesitter/treesitter.nix - ./languages/treesitter/treesitter-context.nix - ./languages/treesitter/treesitter-textobjects.nix - ./languages/treesitter/ts-autotag.nix - ./languages/treesitter/ts-context-commentstring.nix - - ./lsp/conform.nix - ./lsp/fidget.nix - ./lsp/lsp.nix - ./lsp/lspsaga.nix - ./lsp/trouble.nix - - ./none-ls/none-ls.nix - - ./pluginmanagers/lazy.nix - - ./snippets/luasnip.nix - - ./statusline/lualine.nix - ./statusline/staline.nix - - ./telescope/telescope.nix - - ./ui/alpha.nix - ./ui/dressing-nvim.nix - ./ui/indent-blankline.nix - ./ui/noice.nix - ./ui/nvim-notify.nix - ./ui/nui.nix - ./ui/web-devicons.nix - - ./utils/better-escape.nix - ./utils/neocord.nix - ./utils/harpoon.nix - ./utils/illuminate.nix - ./utils/markdown-preview.nix - ./utils/mini.nix - ./utils/neodev.nix - ./utils/neotest.nix - ./utils/nvim-autopairs.nix - ./utils/nvim-colorizer.nix - ./utils/nvim-surround.nix - ./utils/nvterm.nix - ./utils/oil.nix - ./utils/persistence.nix - ./utils/plenary.nix - ./utils/project-nvim.nix - ./utils/sidebar.nix - ./utils/tmux-navigator.nix - ./utils/todo-comments.nix - ./utils/ultimate-autopair.nix - ./utils/undotree.nix - ./utils/wakatime.nix - ./utils/whichkey.nix - ./utils/wilder.nix + ./bufferlines + ./colorschemes + ./completion + ./dap + ./filetrees + ./git + ./keys.nix + ./languages + ./lsp + ./none-ls + ./pluginmanagers + ./sets + ./snippets + ./statusline + ./telescope + ./ui + ./utils ]; + + bufferlines.enable = lib.mkDefault true; + colorschemes.enable = lib.mkDefault true; + completion.enable = lib.mkDefault true; + dap.enable = lib.mkDefault true; + filetrees.enable = lib.mkDefault true; + git.enable = lib.mkDefault true; + keys.enable = true; + languages.enable = true; + lsp.enable = lib.mkDefault true; + none-ls.enable = lib.mkDefault true; + sets.enable = lib.mkDefault true; + pluginmanagers.enable = lib.mkDefault true; + snippets.enable = lib.mkDefault true; + statusline.enable = lib.mkDefault true; + telescope.enable = lib.mkDefault true; + ui.enable = lib.mkDefault true; + utils.enable = lib.mkDefault true; } From 794bd0db99b3d9118595c4e72ad3e04146f6a760 Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 20:03:24 -0300 Subject: [PATCH 19/20] chore: update filenames accordingly --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e051dd4..0bcb1d2 100644 --- a/README.md +++ b/README.md @@ -96,11 +96,11 @@ Neve is highly customizable. Here are some important files for configuring your - **config/default.nix:** This file contains the main configuration file. You can add or delete plugins as you like. -- **config/sets.nix:** In this file, you can add or remove options and adjust their specific settings. +- **config/sets/set.nix:** In this file, you can add or remove options and adjust their specific settings. -- **config/keymaps.nix:** This file contains custom key mappings. You can add your own keyboard shortcuts to enhance productivity. +- **config/keys.nix:** This file contains custom key mappings. You can add your own keyboard shortcuts to enhance productivity. -- **config/lsp/lsp.nix:** Here you can configure your preferred Language Servers. +- **config/lsp/lsp-nvim.nix:** Here you can configure your preferred Language Servers. - **config/lsp/conform.nix:** Configure Formatters for the desired languages. From 6478f64558e984a3ae862072e91cad5e3ded4f6d Mon Sep 17 00:00:00 2001 From: redyf Date: Sat, 12 Oct 2024 23:06:27 +0000 Subject: [PATCH 20/20] Auto lint/format --- flake.lock | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/flake.lock b/flake.lock index 23abafb..6da4ddf 100644 --- a/flake.lock +++ b/flake.lock @@ -109,11 +109,11 @@ ] }, "locked": { - "lastModified": 1728092656, - "narHash": "sha256-eMeCTJZ5xBeQ0f9Os7K8DThNVSo9gy4umZLDfF5q6OM=", + "lastModified": 1728727368, + "narHash": "sha256-7FMyNISP7K6XDSIt1NJxkXZnEdV3HZUXvFoBaJ/qdOg=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "1211305a5b237771e13fcca0c51e60ad47326a9a", + "rev": "eb74e0be24a11a1531b5b8659535580554d30b28", "type": "github" }, "original": { @@ -152,11 +152,11 @@ ] }, "locked": { - "lastModified": 1728337164, - "narHash": "sha256-VdRTjJFyq4Q9U7Z/UoC2Q5jK8vSo6E86lHc2OanXtvc=", + "lastModified": 1728726232, + "narHash": "sha256-8ZWr1HpciQsrFjvPMvZl0W+b0dilZOqXPoKa2Ux36bc=", "owner": "nix-community", "repo": "home-manager", - "rev": "038630363e7de57c36c417fd2f5d7c14773403e4", + "rev": "d57112db877f07387ce7104b5ac346ede556d2d7", "type": "github" }, "original": { @@ -188,10 +188,12 @@ }, "nixpkgs": { "locked": { - "lastModified": 0, - "narHash": "sha256-NOiTvBbRLIOe5F6RbHaAh6++BNjsb149fGZd1T4+KBg=", - "path": "/nix/store/sdzpqjwx7pdx6lsq6llyfqqf7hspp83c-source", - "type": "path" + "lastModified": 1728538411, + "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", + "type": "github" }, "original": { "id": "nixpkgs", @@ -227,11 +229,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1728571833, - "narHash": "sha256-hSMfDsmcPNx74soy7xK01squgiwNGf0eYTfbW8ZUCuk=", + "lastModified": 1728736326, + "narHash": "sha256-JYy050VI7AQyDPHjZ/48rdNFfVvdbR0wPtsRA/4nc7E=", "owner": "nix-community", "repo": "nixvim", - "rev": "7916df22d2dde3d9db37047ce78bbf13e1129794", + "rev": "2e1b3b7d43f485866573f70411a4797ce38e27bb", "type": "github" }, "original": { @@ -249,11 +251,11 @@ ] }, "locked": { - "lastModified": 1728513479, - "narHash": "sha256-yAR9M1jvuAoahYNxo3RNnPMcua1TAIPurFKmH2/g3lg=", + "lastModified": 1728701796, + "narHash": "sha256-FTDCOUnq+gdnHC3p5eisv1X1mMtKJDNMegwpZjRzQKY=", "owner": "NuschtOS", "repo": "search", - "rev": "5cb7ef512ec20a5b7d60fc70dba014560559698a", + "rev": "9578d865b081c29ae98131caf7d2f69a42f0ca6e", "type": "github" }, "original": {