From d92bfc59450df512d0112ba3fff7688fbb3862a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 2 Mar 2023 15:15:16 +0100 Subject: [PATCH 01/12] desktop: use unstable handbrake again --- modules/profiles/desktop.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/profiles/desktop.nix b/modules/profiles/desktop.nix index 10de55c..d6d0bad 100644 --- a/modules/profiles/desktop.nix +++ b/modules/profiles/desktop.nix @@ -103,7 +103,7 @@ with lib; { # ripping abcde - stable.handbrake # HACK to fix broken ffmpeg on unstable + handbrake picard # other From 04dacde02870aba89e299a86e0cf404d2b0bf833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 4 Mar 2023 13:22:48 +0100 Subject: [PATCH 02/12] nvim: add separate config files for most plugins --- modules/profiles/base.nix | 2 +- modules/profiles/desktop.nix | 1 + modules/programs/nvim/default.nix | 66 ++-- modules/programs/nvim/init.lua | 283 ++---------------- .../programs/nvim/plugins/catppuccin-nvim.lua | 7 + .../programs/nvim/plugins/comment-nvim.lua | 1 + modules/programs/nvim/plugins/copilot-lua.lua | 8 + .../programs/nvim/plugins/dashboard-nvim.lua | 9 + .../programs/nvim/plugins/formatter-nvim.lua | 71 +++++ .../programs/nvim/plugins/gitsigns-nvim.lua | 1 + .../programs/nvim/plugins/lualine-nvim.lua | 44 +++ modules/programs/nvim/plugins/noice-nvim.lua | 21 ++ .../programs/nvim/plugins/nvim-autopairs.lua | 1 + .../programs/nvim/plugins/nvim-lastplace.lua | 5 + .../programs/nvim/plugins/nvim-surround.lua | 1 + .../programs/nvim/plugins/nvim-tree-lua.lua | 10 + .../plugins/nvim-treesitter-textsubjects.lua | 7 + .../plugins/nvim-ts-context-commentstring.lua | 5 + modules/programs/nvim/plugins/orgmode.lua | 18 ++ .../nvim/plugins/smartcolumn-nvim.lua | 4 + .../plugins/telescope-fzf-native-nvim.lua | 1 + .../programs/nvim/plugins/telescope-nvim.lua | 9 + .../nvim/plugins/telescope-zoxide.lua | 7 + .../nvim/plugins/todo-comments-nvim.lua | 1 + .../programs/nvim/plugins/which-key-nvim.lua | 2 + 25 files changed, 294 insertions(+), 291 deletions(-) create mode 100644 modules/programs/nvim/plugins/catppuccin-nvim.lua create mode 100644 modules/programs/nvim/plugins/comment-nvim.lua create mode 100644 modules/programs/nvim/plugins/copilot-lua.lua create mode 100644 modules/programs/nvim/plugins/dashboard-nvim.lua create mode 100644 modules/programs/nvim/plugins/formatter-nvim.lua create mode 100644 modules/programs/nvim/plugins/gitsigns-nvim.lua create mode 100644 modules/programs/nvim/plugins/lualine-nvim.lua create mode 100644 modules/programs/nvim/plugins/noice-nvim.lua create mode 100644 modules/programs/nvim/plugins/nvim-autopairs.lua create mode 100644 modules/programs/nvim/plugins/nvim-lastplace.lua create mode 100644 modules/programs/nvim/plugins/nvim-surround.lua create mode 100644 modules/programs/nvim/plugins/nvim-tree-lua.lua create mode 100644 modules/programs/nvim/plugins/nvim-treesitter-textsubjects.lua create mode 100644 modules/programs/nvim/plugins/nvim-ts-context-commentstring.lua create mode 100644 modules/programs/nvim/plugins/orgmode.lua create mode 100644 modules/programs/nvim/plugins/smartcolumn-nvim.lua create mode 100644 modules/programs/nvim/plugins/telescope-fzf-native-nvim.lua create mode 100644 modules/programs/nvim/plugins/telescope-nvim.lua create mode 100644 modules/programs/nvim/plugins/telescope-zoxide.lua create mode 100644 modules/programs/nvim/plugins/todo-comments-nvim.lua create mode 100644 modules/programs/nvim/plugins/which-key-nvim.lua diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index 7bf15c8..f24182c 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -63,7 +63,6 @@ in fish.enable = true; git.enable = true; gpg.enable = true; - vim.enable = true; }; }; @@ -105,6 +104,7 @@ in up viu wget + vim ]; fonts.fonts = with pkgs; [ diff --git a/modules/profiles/desktop.nix b/modules/profiles/desktop.nix index d6d0bad..85a5362 100644 --- a/modules/profiles/desktop.nix +++ b/modules/profiles/desktop.nix @@ -77,6 +77,7 @@ with lib; { hub.enable = true; ledger.enable = true; logseq.enable = true; + nvim.enable = true; python.versions."311".enable = true; ssh = { enable = true; diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index 85cf6d3..ceb5a1e 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -7,16 +7,17 @@ with lib; let - cfg = config.my.programs.vim; + cfg = config.my.programs.nvim; + + mkPlugin = name: { + plugin = pkgs.vimPlugins.${name}; + type = "lua"; + config = lib.readFile (./plugins + "/${name}.lua"); + }; + in { - options.my.programs.vim = { - enable = mkOption { - default = true; - type = types.bool; - example = false; - }; - }; + options.my.programs.nvim.enable = mkEnableOption "nvim"; config = mkIf cfg.enable { home-manager.users.moritz = { @@ -50,46 +51,49 @@ in taplo yamlfmt ]; - plugins = with pkgs.vimPlugins; [ - catppuccin-nvim + plugins = builtins.map mkPlugin [ + "catppuccin-nvim" + "comment-nvim" + "copilot-lua" + "dashboard-nvim" + "formatter-nvim" + "gitsigns-nvim" + "lualine-nvim" + "noice-nvim" + "nvim-autopairs" + "nvim-lastplace" + "nvim-surround" + "nvim-tree-lua" + "nvim-treesitter-textsubjects" + "nvim-ts-context-commentstring" + "orgmode" + "smartcolumn-nvim" + "telescope-fzf-native-nvim" + "telescope-nvim" + "telescope-zoxide" + "which-key-nvim" + "todo-comments-nvim" + ] ++ (with pkgs.vimPlugins; [ cmp-nvim-lsp cmp_luasnip - comment-nvim copilot-cmp - copilot-lua - dashboard-nvim direnv-vim - formatter-nvim - gitsigns-nvim lsp_lines-nvim lspkind-nvim lspsaga-nvim-original lualine-lsp-progress - lualine-nvim luasnip - neogit - noice-nvim nui-nvim # for noice-nvim - nvim-autopairs nvim-cmp - nvim-lastplace nvim-lspconfig - nvim-surround - nvim-tree-lua - nvim-treesitter-textsubjects nvim-treesitter.withAllGrammars - nvim-ts-context-commentstring + nvim-ufo nvim-web-devicons # for dashboard-nvim - orgmode plenary-nvim # for telescope, neogit popup-nvim - smartcolumn-nvim - telescope-fzf-native-nvim - telescope-nvim - telescope-zoxide + promise-async vim-lion - which-key-nvim - ]; + ]); }; }; }; diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua index 419a340..a4029d7 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/init.lua @@ -8,7 +8,7 @@ if not vim.loop.fs_stat(spelldir) then end vim.opt.autoindent = true -vim.opt.backupdir = { vim.fn.stdpath("state") .. "/nvim/backup//" } -- don't store backup in files dir +vim.opt.backupdir = { vim.fn.stdpath("state") .. "/nvim/backup/" } -- don't store backup in files dir vim.opt.clipboard = "unnamedplus" -- sync with system clipboard vim.opt.conceallevel = 2 vim.opt.expandtab = true -- spaces instead of tabs @@ -37,78 +37,24 @@ if vim.g.neovide then vim.g.neovide_scale_factor = 0.7 end -require("catppuccin").setup({ - compile_path = vim.fn.stdpath("cache") .. "/catppuccin", -- fix issue of writing to nix store - integrations = { - which_key = true, - }, -}) -vim.cmd.colorscheme("catppuccin-macchiato") - -vim.o.timeout = true -vim.o.timeoutlen = 500 local wk = require("which-key") -require("noice").setup({ - lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - progress = { - enabled = false, - }, - }, - -- you can enable a preset for easier configuration - presets = { - bottom_search = true, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = false, -- add a border to hover docs and signature help - }, -}) - -require("telescope").load_extension("zoxide") -wk.register({ - f = { - name = "find", - f = { "Telescope find_files", "find file" }, - z = { "Telescope zoxide list", "find location" }, - l = { "Telescope current_buffer_fuzzy_find", "find line" }, - g = { "Telescope live_grep", "live grep" }, - b = { "Telescope buffers", "find buffer" }, - }, -}, { prefix = "" }) --- To get fzf loaded and working with telescope, you need to call --- load_extension, somewhere after setup function: -require("telescope").load_extension("fzf") - -require("neogit").setup({ - disable_commit_confirmation = true, -}) -wk.register({ - g = { "Neogit", "git" }, -}, { prefix = "" }) - require("nvim-treesitter.configs").setup({ sync_install = false, auto_install = false, highlight = { enable = true, - additional_vim_regex_highlighting = true, + additional_vim_regex_highlighting = false, }, }) -local lspkind = require("lspkind") - local cmp = require("cmp") local luasnip = require("luasnip") +require("copilot_cmp").setup() + cmp.setup({ formatting = { - format = lspkind.cmp_format({ + format = require("lspkind").cmp_format({ mode = "symbol", -- show only symbol annotations maxwidth = 50, -- prevent the popup from showing more than provided characters ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead @@ -185,76 +131,6 @@ local function table_merge(...) return result end --- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands -require("formatter").setup({ - -- Enable or disable logging - logging = true, - -- Set the log level - log_level = vim.log.levels.WARN, - -- All formatter configurations are opt-in - filetype = { - json = { - require("formatter.filetypes.json").jq, - }, - lua = { - require("formatter.filetypes.lua").stylua, - }, - nix = { - require("formatter.filetypes.nix").nixpkgs_fmt, - }, - python = { - require("formatter.filetypes.python").black, - }, - rust = { - require("formatter.filetypes.rust").rustfmt, - }, - sh = { - require("formatter.filetypes.sh").shfmt, - }, - toml = { - require("formatter.filetypes.toml").taplo, - }, - yaml = { - require("formatter.filetypes.yaml").yamlfmt, - }, - - -- HACK to use specific formatters only when specified - alejandra = { - require("formatter.filetypes.nix").alejandra, - }, - isort = { - require("formatter.filetypes.python").isort, - }, - - -- Use the special "*" filetype for defining formatter configurations on - -- any filetype - ["*"] = { - -- "formatter.filetypes.any" defines default configurations for any - -- filetype - require("formatter.filetypes.any").remove_trailing_whitespace, - }, - }, -}) -vim.api.nvim_create_user_command("Fmt", function(opts) - local params = vim.split(opts.args, "%s+", { trimempty = true }) - local filetype = vim.bo.filetype - vim.cmd("set filetype=" .. params[1]) -- fake filetype - vim.cmd(":Format") - vim.cmd("set filetype=" .. filetype) -- restore original filetype -end, { - nargs = 1, - complete = function() - local languages = { - nix = { "alejandra" }, - python = { "isort" }, - } - return languages[vim.bo.filetype] or {} - end, -}) -wk.register({ - ["="] = { "Format", "format (formatter)" }, -}, { noremap = true, silent = true }) - local lsp_lines = require("lsp_lines") lsp_lines.setup() -- Disable virtual_text since it's redundant due to lsp_lines. @@ -265,6 +141,25 @@ vim.diagnostic.config({ -- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers.. local capabilities = require("cmp_nvim_lsp").default_capabilities() +vim.o.foldcolumn = "1" -- '0' is not bad +vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value +vim.o.foldlevelstart = 99 +vim.o.foldenable = true +-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself +wk.register({ + z = { + R = { require("ufo").openAllFolds, "Open all folds" }, + M = { require("ufo").closeAllFolds, "Close all folds" }, + }, +}) +-- Tell the server the capability of foldingRange, +-- Neovim hasn't added foldingRange to default capabilities, users must add it manually +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, +} +require("ufo").setup() + require("lspsaga").setup({ symbol_in_winbar = { enable = false, @@ -340,8 +235,6 @@ for _, lsp in ipairs(servers) do end lspconfig_setup("lua_ls", { - on_attach = on_attach_def, - capabilities = capabilities, settings = { Lua = { runtime = { @@ -367,131 +260,3 @@ lspconfig_setup("lua_ls", { }, }, }) - -require("dashboard").setup({ - theme = "hyper", - config = { - packages = { enable = false }, - week_header = { - enable = true, - }, - }, -}) - -require("lualine").setup({ - options = { - icons_enabled = true, - theme = "auto", - component_separators = "|", - section_separators = { left = "", right = "" }, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - }, - }, - sections = { - lualine_a = { - { "mode", separator = { left = "" }, right_padding = 2 }, - }, - lualine_b = { "branch", "diff", "diagnostics" }, - lualine_c = { "filename", "lsp_progress" }, - lualine_x = { "encoding", "fileformat", "filetype" }, - lualine_y = { "progress" }, - lualine_z = { - { "location", separator = { right = "" }, left_padding = 2 }, - }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { "filename" }, - lualine_x = { "location" }, - lualine_y = {}, - lualine_z = {}, - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {}, -}) - -require("Comment").setup() - -require("nvim-treesitter.configs").setup({ - context_commentstring = { - enable = true, - }, -}) - -require("nvim-surround").setup({}) - -require("nvim-treesitter.configs").setup({ - textsubjects = { - enable = true, - prev_selection = ",", -- (Optional) keymap to select the previous selection - keymaps = { ["."] = "textsubjects-smart" }, - }, -}) - -require("copilot").setup({ - suggestion = { enabled = false }, - panel = { enabled = false }, -}) -vim.api.nvim_create_autocmd("VimEnter", { - desc = "Disable Copilot by default on startup", - command = "Copilot disable", -}) -require("copilot_cmp").setup() - -local orgmode = require("orgmode") --- Load custom treesitter grammar for org filetype -orgmode.setup_ts_grammar() --- Treesitter configuration -require("nvim-treesitter.configs").setup({ - -- If TS highlights are not enabled at all, or disabled via `disable` prop, - -- highlighting will fallback to default Vim syntax highlighting - highlight = { - enable = true, - -- Required for spellcheck, some LaTex highlights and - -- code block highlights that do not have ts grammar - additional_vim_regex_highlighting = { "org" }, - }, -}) -orgmode.setup({ - org_agenda_files = { "~/Notes/org" }, - org_default_notes_file = "~/Notes/org/refile.org", -}) - -require("gitsigns").setup() - -require("nvim-lastplace").setup({ - lastplace_ignore_buftype = { "quickfix", "nofile", "help" }, - lastplace_ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }, - lastplace_open_folds = true, -}) - -require("nvim-autopairs").setup() - --- disable netrw at the very start of your init.lua (strongly advised) -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 --- set termguicolors to enable highlight groups -vim.opt.termguicolors = true --- empty setup using defaults -require("nvim-tree").setup() -wk.register({ - t = { "NvimTreeFindFileToggle", "nvim tree" }, -}, { prefix = "t", silent = true }) - -require("smartcolumn").setup({ - colorcolumn = 120, - disabled_filetypes = { "help", "text", "markdown", "dashboard" }, -}) diff --git a/modules/programs/nvim/plugins/catppuccin-nvim.lua b/modules/programs/nvim/plugins/catppuccin-nvim.lua new file mode 100644 index 0000000..9c3b7d7 --- /dev/null +++ b/modules/programs/nvim/plugins/catppuccin-nvim.lua @@ -0,0 +1,7 @@ +require("catppuccin").setup({ + compile_path = vim.fn.stdpath("cache") .. "/catppuccin", -- fix issue of writing to nix store + integrations = { + which_key = true, + }, +}) +vim.cmd.colorscheme("catppuccin-macchiato") diff --git a/modules/programs/nvim/plugins/comment-nvim.lua b/modules/programs/nvim/plugins/comment-nvim.lua new file mode 100644 index 0000000..bd47faf --- /dev/null +++ b/modules/programs/nvim/plugins/comment-nvim.lua @@ -0,0 +1 @@ +require("Comment").setup() diff --git a/modules/programs/nvim/plugins/copilot-lua.lua b/modules/programs/nvim/plugins/copilot-lua.lua new file mode 100644 index 0000000..7135331 --- /dev/null +++ b/modules/programs/nvim/plugins/copilot-lua.lua @@ -0,0 +1,8 @@ +require("copilot").setup({ + suggestion = { enabled = false }, + panel = { enabled = false }, +}) +vim.api.nvim_create_autocmd("VimEnter", { + desc = "Disable Copilot by default on startup", + command = "Copilot disable", +}) diff --git a/modules/programs/nvim/plugins/dashboard-nvim.lua b/modules/programs/nvim/plugins/dashboard-nvim.lua new file mode 100644 index 0000000..83dcf23 --- /dev/null +++ b/modules/programs/nvim/plugins/dashboard-nvim.lua @@ -0,0 +1,9 @@ +require("dashboard").setup({ + theme = "hyper", + config = { + packages = { enable = false }, + week_header = { + enable = true, + }, + }, +}) diff --git a/modules/programs/nvim/plugins/formatter-nvim.lua b/modules/programs/nvim/plugins/formatter-nvim.lua new file mode 100644 index 0000000..b72b72a --- /dev/null +++ b/modules/programs/nvim/plugins/formatter-nvim.lua @@ -0,0 +1,71 @@ +-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands +require("formatter").setup({ + -- Enable or disable logging + logging = true, + -- Set the log level + log_level = vim.log.levels.WARN, + -- All formatter configurations are opt-in + filetype = { + json = { + require("formatter.filetypes.json").jq, + }, + lua = { + require("formatter.filetypes.lua").stylua, + }, + nix = { + require("formatter.filetypes.nix").nixpkgs_fmt, + }, + python = { + require("formatter.filetypes.python").black, + }, + rust = { + require("formatter.filetypes.rust").rustfmt, + }, + sh = { + require("formatter.filetypes.sh").shfmt, + }, + toml = { + require("formatter.filetypes.toml").taplo, + }, + yaml = { + require("formatter.filetypes.yaml").yamlfmt, + }, + + -- HACK to use specific formatters only when specified + alejandra = { + require("formatter.filetypes.nix").alejandra, + }, + isort = { + require("formatter.filetypes.python").isort, + }, + + -- Use the special "*" filetype for defining formatter configurations on + -- any filetype + ["*"] = { + -- "formatter.filetypes.any" defines default configurations for any + -- filetype + require("formatter.filetypes.any").remove_trailing_whitespace, + }, + }, +}) + +vim.api.nvim_create_user_command("Fmt", function(opts) + local params = vim.split(opts.args, "%s+", { trimempty = true }) + local filetype = vim.bo.filetype + vim.cmd("set filetype=" .. params[1]) -- fake filetype + vim.cmd(":Format") + vim.cmd("set filetype=" .. filetype) -- restore original filetype +end, { + nargs = 1, + complete = function() + local languages = { + nix = { "alejandra" }, + python = { "isort" }, + } + return languages[vim.bo.filetype] or {} + end, +}) + +require("which-key").register({ + ["="] = { "Format", "format (formatter)" }, +}, { noremap = true, silent = true }) diff --git a/modules/programs/nvim/plugins/gitsigns-nvim.lua b/modules/programs/nvim/plugins/gitsigns-nvim.lua new file mode 100644 index 0000000..d16d238 --- /dev/null +++ b/modules/programs/nvim/plugins/gitsigns-nvim.lua @@ -0,0 +1 @@ +require("gitsigns").setup() diff --git a/modules/programs/nvim/plugins/lualine-nvim.lua b/modules/programs/nvim/plugins/lualine-nvim.lua new file mode 100644 index 0000000..b72eb13 --- /dev/null +++ b/modules/programs/nvim/plugins/lualine-nvim.lua @@ -0,0 +1,44 @@ +require("lualine").setup({ + options = { + icons_enabled = true, + theme = "auto", + component_separators = "|", + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { + { "mode", separator = { left = "" }, right_padding = 2 }, + }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename", "lsp_progress" }, + lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_y = { "progress" }, + lualine_z = { + { "location", separator = { right = "" }, left_padding = 2 }, + }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {}, +}) diff --git a/modules/programs/nvim/plugins/noice-nvim.lua b/modules/programs/nvim/plugins/noice-nvim.lua new file mode 100644 index 0000000..0d6cb82 --- /dev/null +++ b/modules/programs/nvim/plugins/noice-nvim.lua @@ -0,0 +1,21 @@ +require("noice").setup({ + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + progress = { + enabled = false, + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, +}) diff --git a/modules/programs/nvim/plugins/nvim-autopairs.lua b/modules/programs/nvim/plugins/nvim-autopairs.lua new file mode 100644 index 0000000..4de6add --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-autopairs.lua @@ -0,0 +1 @@ +require("nvim-autopairs").setup() diff --git a/modules/programs/nvim/plugins/nvim-lastplace.lua b/modules/programs/nvim/plugins/nvim-lastplace.lua new file mode 100644 index 0000000..d97700f --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-lastplace.lua @@ -0,0 +1,5 @@ +require("nvim-lastplace").setup({ + lastplace_ignore_buftype = { "quickfix", "nofile", "help" }, + lastplace_ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }, + lastplace_open_folds = true, +}) diff --git a/modules/programs/nvim/plugins/nvim-surround.lua b/modules/programs/nvim/plugins/nvim-surround.lua new file mode 100644 index 0000000..f2499fd --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-surround.lua @@ -0,0 +1 @@ +require("nvim-surround").setup({}) diff --git a/modules/programs/nvim/plugins/nvim-tree-lua.lua b/modules/programs/nvim/plugins/nvim-tree-lua.lua new file mode 100644 index 0000000..a8634bc --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-tree-lua.lua @@ -0,0 +1,10 @@ +-- disable netrw at the very start of your init.lua (strongly advised) +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 +-- set termguicolors to enable highlight groups +vim.opt.termguicolors = true +-- empty setup using defaults +require("nvim-tree").setup() +require("which-key").register({ + t = { "NvimTreeFindFileToggle", "nvim tree" }, +}, { prefix = "t", silent = true }) diff --git a/modules/programs/nvim/plugins/nvim-treesitter-textsubjects.lua b/modules/programs/nvim/plugins/nvim-treesitter-textsubjects.lua new file mode 100644 index 0000000..e60041a --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-treesitter-textsubjects.lua @@ -0,0 +1,7 @@ +require("nvim-treesitter.configs").setup({ + textsubjects = { + enable = true, + prev_selection = ",", -- (Optional) keymap to select the previous selection + keymaps = { ["."] = "textsubjects-smart" }, + }, +}) diff --git a/modules/programs/nvim/plugins/nvim-ts-context-commentstring.lua b/modules/programs/nvim/plugins/nvim-ts-context-commentstring.lua new file mode 100644 index 0000000..42a4bb9 --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-ts-context-commentstring.lua @@ -0,0 +1,5 @@ +require("nvim-treesitter.configs").setup({ + context_commentstring = { + enable = true, + }, +}) diff --git a/modules/programs/nvim/plugins/orgmode.lua b/modules/programs/nvim/plugins/orgmode.lua new file mode 100644 index 0000000..556d5e6 --- /dev/null +++ b/modules/programs/nvim/plugins/orgmode.lua @@ -0,0 +1,18 @@ +local orgmode = require("orgmode") +-- Load custom treesitter grammar for org filetype +orgmode.setup_ts_grammar() +-- Treesitter configuration +require("nvim-treesitter.configs").setup({ + -- If TS highlights are not enabled at all, or disabled via `disable` prop, + -- highlighting will fallback to default Vim syntax highlighting + highlight = { + enable = true, + -- Required for spellcheck, some LaTex highlights and + -- code block highlights that do not have ts grammar + additional_vim_regex_highlighting = { "org" }, + }, +}) +orgmode.setup({ + org_agenda_files = { "~/Notes/org" }, + org_default_notes_file = "~/Notes/org/refile.org", +}) diff --git a/modules/programs/nvim/plugins/smartcolumn-nvim.lua b/modules/programs/nvim/plugins/smartcolumn-nvim.lua new file mode 100644 index 0000000..1858689 --- /dev/null +++ b/modules/programs/nvim/plugins/smartcolumn-nvim.lua @@ -0,0 +1,4 @@ +require("smartcolumn").setup({ + colorcolumn = 120, + disabled_filetypes = { "help", "text", "markdown", "dashboard" }, +}) diff --git a/modules/programs/nvim/plugins/telescope-fzf-native-nvim.lua b/modules/programs/nvim/plugins/telescope-fzf-native-nvim.lua new file mode 100644 index 0000000..d38c004 --- /dev/null +++ b/modules/programs/nvim/plugins/telescope-fzf-native-nvim.lua @@ -0,0 +1 @@ +require("telescope").load_extension("fzf") diff --git a/modules/programs/nvim/plugins/telescope-nvim.lua b/modules/programs/nvim/plugins/telescope-nvim.lua new file mode 100644 index 0000000..d83cec4 --- /dev/null +++ b/modules/programs/nvim/plugins/telescope-nvim.lua @@ -0,0 +1,9 @@ +require("which-key").register({ + f = { + name = "find", + f = { "Telescope find_files", "find file" }, + l = { "Telescope current_buffer_fuzzy_find", "find line" }, + g = { "Telescope live_grep", "live grep" }, + b = { "Telescope buffers", "find buffer" }, + }, +}, { prefix = "" }) diff --git a/modules/programs/nvim/plugins/telescope-zoxide.lua b/modules/programs/nvim/plugins/telescope-zoxide.lua new file mode 100644 index 0000000..bb8f7f1 --- /dev/null +++ b/modules/programs/nvim/plugins/telescope-zoxide.lua @@ -0,0 +1,7 @@ +require("telescope").load_extension("zoxide") +require("which-key").register({ + f = { + name = "find", + z = { "Telescope zoxide list", "find location" }, + }, +}, { prefix = "" }) diff --git a/modules/programs/nvim/plugins/todo-comments-nvim.lua b/modules/programs/nvim/plugins/todo-comments-nvim.lua new file mode 100644 index 0000000..ae7ceee --- /dev/null +++ b/modules/programs/nvim/plugins/todo-comments-nvim.lua @@ -0,0 +1 @@ +require("todo-comments").setup({}) diff --git a/modules/programs/nvim/plugins/which-key-nvim.lua b/modules/programs/nvim/plugins/which-key-nvim.lua new file mode 100644 index 0000000..e70fb09 --- /dev/null +++ b/modules/programs/nvim/plugins/which-key-nvim.lua @@ -0,0 +1,2 @@ +vim.o.timeout = true +vim.o.timeoutlen = 500 From 6b84758a6c59227f2c1eaad82b87447711c2e2f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 5 Mar 2023 14:02:54 +0100 Subject: [PATCH 03/12] nvim: make nvim-ufo use statuscolumn (pretty) --- modules/programs/nvim/init.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua index a4029d7..b941a23 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/init.lua @@ -145,6 +145,34 @@ vim.o.foldcolumn = "1" -- '0' is not bad vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value vim.o.foldlevelstart = 99 vim.o.foldenable = true +vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] +vim.o.statuscolumn = "%= " + -- FIXME: figure out how to put on the other side without having to do a lot of shifting + .. "%s" -- sign column + .. "%{%" -- evaluate this, and then evaluate what it returns + .. "&number ?" + .. "(v:relnum ?" + -- when showing relative numbers, make sure to pad so things don't shift as you move the cursor + .. 'printf("%"..len(line("$")).."s", v:relnum)' + .. ":" + .. "v:lnum" + .. ")" + .. ":" + .. '""' + .. " " -- space between lines and fold + .. "%}" + .. "%= " + .. "%#FoldColumn#" -- highlight group for fold + .. "%{" -- expression for showing fold expand/colapse + .. "foldlevel(v:lnum) > foldlevel(v:lnum - 1)" -- any folds? + .. "? (foldclosed(v:lnum) == -1" -- currently open? + .. '? ""' -- point down + .. ': ""' -- point to right + .. ")" + .. ': " "' -- blank for no fold, or inside fold + .. "}" + .. "%= " -- spacing between end of column and start of text + -- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself wk.register({ z = { From 8e7a85b21a985d560141529ba36be7d3add00e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 5 Mar 2023 14:04:00 +0100 Subject: [PATCH 04/12] nvim: only show lsp lightbulb as sign --- modules/programs/nvim/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua index b941a23..6a7a1b2 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/init.lua @@ -192,6 +192,13 @@ require("lspsaga").setup({ symbol_in_winbar = { enable = false, }, + lightbulb = { + enable = true, + enable_in_insert = true, + sign = true, + sign_priority = 40, + virtual_text = false, + }, }) local lspconfig = require("lspconfig") From 567e4eb551fc3a77d1ade38386a0238d633fad22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Tue, 7 Mar 2023 11:25:53 +0100 Subject: [PATCH 05/12] refactor: add lib.my for useful functions --- flake.nix | 41 ++++++++++++++++++++++++----------------- lib/default.nix | 16 ++++++++++++++++ 2 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 lib/default.nix diff --git a/flake.nix b/flake.nix index e6be918..6d7c237 100644 --- a/flake.nix +++ b/flake.nix @@ -104,11 +104,17 @@ channelsConfig.allowUnfree = true; + lib = nixpkgs.lib.extend + (self: super: { my = import ./lib { lib = self; }; }); + ################ ### Overlays ### ################ - overlay = import ./overlays { inherit inputs; }; + overlay = import ./overlays { + inherit inputs; + inherit (self) lib; + }; channels.nixpkgs.overlaysBuilder = channels: [ inputs.emacs.overlays.default @@ -134,22 +140,23 @@ ./modules/profiles/gaming.nix ./modules/profiles/desktop.nix ]; - - hostDefaults.modules = [ - ./modules/default.nix - self.nixosModules.base - inputs.home-manager.nixosModule - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - extraSpecialArgs = { inherit inputs self; }; - }; - } - inputs.hyprland.nixosModules.default - inputs.agenix.nixosModules.age - inputs.howdy.nixosModules.default - ]; + hostDefaults = { + modules = [ + ./modules/default.nix + self.nixosModules.base + inputs.home-manager.nixosModule + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { inherit inputs self; }; + }; + } + inputs.hyprland.nixosModules.default + inputs.agenix.nixosModules.age + inputs.howdy.nixosModules.default + ]; + }; hosts.nixos-laptop.modules = [ ./hosts/nixos-laptop diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..f2ea1c0 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,16 @@ +{ lib, ... }: + +lib.makeExtensible (self: rec { + mkDate = longDate: lib.concatStringsSep "-" [ + (builtins.substring 0 4 longDate) + (builtins.substring 4 2 longDate) + (builtins.substring 6 2 longDate) + ]; + mkVersionSrc = src: "unstable-" + builtins.substring 0 7 src.rev; + mkVersionInput = input: + let + date = mkDate (input.lastModifiedDate or "19700101"); + rev = input.shortRev or "dirty"; + in + "unstable-${date}_${rev}}"; +}) From d1f910db692e141c2da3b4fb16ebb5f2273ff9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Tue, 7 Mar 2023 11:28:27 +0100 Subject: [PATCH 06/12] refactor: split up overlays --- overlays/channels.nix | 12 ++++++ overlays/default.nix | 87 ++++------------------------------------- overlays/packages.nix | 10 +++++ overlays/vimPlugins.nix | 29 ++++++++++++++ overlays/wayland.nix | 33 ++++++++++++++++ 5 files changed, 91 insertions(+), 80 deletions(-) create mode 100644 overlays/channels.nix create mode 100644 overlays/packages.nix create mode 100644 overlays/vimPlugins.nix create mode 100644 overlays/wayland.nix diff --git a/overlays/channels.nix b/overlays/channels.nix new file mode 100644 index 0000000..8c19d82 --- /dev/null +++ b/overlays/channels.nix @@ -0,0 +1,12 @@ +{ lib, inputs }: + +final: prev: { + master = import inputs.master { + inherit (prev) system; + config.allowUnfree = true; + }; + stable = import inputs.stable { + inherit (prev) system; + config.allowUnfree = true; + }; +} diff --git a/overlays/default.nix b/overlays/default.nix index ccea795..772ff29 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,81 +1,8 @@ -{ inputs }: final: prev: -let - mkDate = longDate: (prev.lib.concatStringsSep "-" [ - (builtins.substring 0 4 longDate) - (builtins.substring 4 2 longDate) - (builtins.substring 6 2 longDate) - ]); - mkVersionSrc = src: "unstable-" + builtins.substring 0 7 src.rev; - mkVersionInput = input: "unstable-" + mkDate (input.lastModifiedDate or "19700101") + "_" + (input.shortRev or "dirty"); -in -{ - agenix = inputs.agenix.packages.${prev.system}.default; - attic = inputs.attic.packages.${prev.system}.default; - hyprpaper = inputs.hyprpaper.packages.${prev.system}.default; - neovim-nightly = inputs.neovim.packages.${prev.system}.default; - nil = inputs.nil.packages.${prev.system}.default; +{ inputs, lib }: - logseq-wayland = prev.symlinkJoin { - name = "logseq-wayland"; - paths = [ prev.logseq ]; - nativeBuildInputs = [ prev.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/logseq \ - --add-flags "--socket=wayland --enable-features=UseOzonePlatform --ozone-platform=wayland" - ''; - }; - - waybar-hyprland = prev.waybar.overrideAttrs (old: { - pname = "${old.pname}-hyprland"; - postPatch = old.postPatch or "" + '' - sed -i 's,zext_workspace_handle_v1_activate(workspace_handle_);,const std::string command = "${final.hyprland}/bin/hyprctl dispatch workspace " + name_;\n\tsystem(command.c_str());,g' src/modules/wlr/workspace_manager.cpp - ''; - mesonFlags = old.mesonFlags or [ ] ++ [ "-Dexperimental=true" ]; - }); - - vimPlugins = prev.vimPlugins // { - nvim-treesitter-textsubjects = prev.vimUtils.buildVimPluginFrom2Nix { - pname = "nvim-treesitter-textsubjects"; - version = mkVersionInput inputs.nvim-treesitter-textsubjects; - src = inputs.nvim-treesitter-textsubjects; - }; - - smartcolumn-nvim = prev.vimUtils.buildVimPluginFrom2Nix { - pname = "smartcolumn-nvim"; - version = mkVersionInput inputs.smartcolumn-nvim; - src = inputs.smartcolumn-nvim; - }; - - copilot-lua = prev.vimPlugins.copilot-lua.overrideAttrs (old: { - version = mkVersionInput inputs.copilot-lua; - src = inputs.copilot-lua; - }); - - lspsaga-nvim-original = prev.vimPlugins.lspsaga-nvim-original.overrideAttrs (old: { - version = mkVersionInput inputs.lspsaga-nvim; - src = inputs.lspsaga-nvim; - }); - }; - - neovide-hyprland = final.symlinkJoin { - name = "neovide-hyprland-${final.neovide.version}"; - paths = [ final.neovide ]; - nativeBuildInputs = [ final.makeWrapper ]; - postBuild = '' - rm $out/bin/neovide - makeWrapper ${final.neovide}/bin/neovide $out/bin/neovide --set WINIT_UNIX_BACKEND x11 - ''; - meta = final.neovide.meta // { - mainProgram = "neovide"; - }; - }; - - master = import inputs.master { - inherit (prev) system; - config.allowUnfree = true; - }; - stable = import inputs.stable { - inherit (prev) system; - config.allowUnfree = true; - }; -} +lib.composeManyExtensions [ + (import ./channels.nix { inherit inputs lib; }) + (import ./packages.nix { inherit inputs lib; }) + (import ./vimPlugins.nix { inherit inputs lib; }) + (import ./wayland.nix { inherit inputs lib; }) +] diff --git a/overlays/packages.nix b/overlays/packages.nix new file mode 100644 index 0000000..d1fb9c3 --- /dev/null +++ b/overlays/packages.nix @@ -0,0 +1,10 @@ +{ inputs, lib }: + +final: prev: +{ + agenix = inputs.agenix.packages.${prev.system}.default; + attic = inputs.attic.packages.${prev.system}.default; + hyprpaper = inputs.hyprpaper.packages.${prev.system}.default; + neovim-nightly = inputs.neovim.packages.${prev.system}.default; + nil = inputs.nil.packages.${prev.system}.default; +} diff --git a/overlays/vimPlugins.nix b/overlays/vimPlugins.nix new file mode 100644 index 0000000..6efbecd --- /dev/null +++ b/overlays/vimPlugins.nix @@ -0,0 +1,29 @@ +{ inputs, lib }: + +final: prev: +with lib.my; +{ + vimPlugins = prev.vimPlugins // { + nvim-treesitter-textsubjects = prev.vimUtils.buildVimPluginFrom2Nix { + pname = "nvim-treesitter-textsubjects"; + version = mkVersionInput inputs.nvim-treesitter-textsubjects; + src = inputs.nvim-treesitter-textsubjects; + }; + + smartcolumn-nvim = prev.vimUtils.buildVimPluginFrom2Nix { + pname = "smartcolumn-nvim"; + version = mkVersionInput inputs.smartcolumn-nvim; + src = inputs.smartcolumn-nvim; + }; + + copilot-lua = prev.vimPlugins.copilot-lua.overrideAttrs (old: { + version = mkVersionInput inputs.copilot-lua; + src = inputs.copilot-lua; + }); + + lspsaga-nvim-original = prev.vimPlugins.lspsaga-nvim-original.overrideAttrs (old: { + version = mkVersionInput inputs.lspsaga-nvim; + src = inputs.lspsaga-nvim; + }); + }; +} diff --git a/overlays/wayland.nix b/overlays/wayland.nix new file mode 100644 index 0000000..f88709a --- /dev/null +++ b/overlays/wayland.nix @@ -0,0 +1,33 @@ +{ lib, inputs }: + +final: prev: { + neovide-hyprland = final.symlinkJoin { + name = "neovide-hyprland-${final.neovide.version}"; + paths = [ final.neovide ]; + nativeBuildInputs = [ final.makeWrapper ]; + postBuild = '' + rm $out/bin/neovide + makeWrapper ${final.neovide}/bin/neovide $out/bin/neovide --set WINIT_UNIX_BACKEND x11 + ''; + meta = final.neovide.meta // { + mainProgram = "neovide"; + }; + }; + logseq-wayland = prev.symlinkJoin { + name = "logseq-wayland"; + paths = [ prev.logseq ]; + nativeBuildInputs = [ prev.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/logseq \ + --add-flags "--socket=wayland --enable-features=UseOzonePlatform --ozone-platform=wayland" + ''; + }; + + waybar-hyprland = prev.waybar.overrideAttrs (old: { + pname = "${old.pname}-hyprland"; + postPatch = old.postPatch or "" + '' + sed -i 's,zext_workspace_handle_v1_activate(workspace_handle_);,const std::string command = "${final.hyprland}/bin/hyprctl dispatch workspace " + name_;\n\tsystem(command.c_str());,g' src/modules/wlr/workspace_manager.cpp + ''; + mesonFlags = old.mesonFlags or [ ] ++ [ "-Dexperimental=true" ]; + }); +} From 0556bfe81eb4c6b49d9686b670998cb46512b53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Tue, 7 Mar 2023 14:25:30 +0100 Subject: [PATCH 07/12] feat: add lib as overlay --- overlays/default.nix | 1 + overlays/lib.nix | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 overlays/lib.nix diff --git a/overlays/default.nix b/overlays/default.nix index 772ff29..b8da5c5 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -5,4 +5,5 @@ lib.composeManyExtensions [ (import ./packages.nix { inherit inputs lib; }) (import ./vimPlugins.nix { inherit inputs lib; }) (import ./wayland.nix { inherit inputs lib; }) + (import ./lib.nix { inherit inputs lib; }) ] diff --git a/overlays/lib.nix b/overlays/lib.nix new file mode 100644 index 0000000..69b149a --- /dev/null +++ b/overlays/lib.nix @@ -0,0 +1,5 @@ +{ lib, inputs }: + +final: prev: { + inherit lib; +} From 2df38d379d508cad3e3aa5c7f006f94fef96b914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Tue, 7 Mar 2023 14:26:37 +0100 Subject: [PATCH 08/12] feat(nvim): add lazy loading for cmp --- modules/programs/nvim/init.lua | 107 +++++++++++++++++---------------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua index 6a7a1b2..7973ce6 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/init.lua @@ -48,59 +48,64 @@ require("nvim-treesitter.configs").setup({ }, }) -local cmp = require("cmp") -local luasnip = require("luasnip") -require("copilot_cmp").setup() +-- load cmp on InsertEnter +vim.api.nvim_create_autocmd("InsertEnter", { + callback = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + require("copilot_cmp").setup() -cmp.setup({ - formatting = { - format = require("lspkind").cmp_format({ - mode = "symbol", -- show only symbol annotations - maxwidth = 50, -- prevent the popup from showing more than provided characters - ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead - symbol_map = { - Copilot = "", + cmp.setup({ + formatting = { + format = require("lspkind").cmp_format({ + mode = "symbol", -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters + ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead + symbol_map = { + Copilot = "", + }, + }), }, - }), - }, - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - sources = { - { name = "buffer", priority = 1 }, - { name = "copilot", priority = 8 }, - { name = "luasnip", priority = 7 }, - { name = "nvim_lsp", priority = 9 }, - { name = "orgmode", priority = 9 }, - }, + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = { + { name = "buffer", priority = 1 }, + { name = "copilot", priority = 8 }, + { name = "luasnip", priority = 7 }, + { name = "nvim_lsp", priority = 9 }, + { name = "orgmode", priority = 9 }, + }, + }) + end, }) ---merge tables From 277b29f62dc5d1c55ff163fa329e131fa551d20e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 9 Mar 2023 16:15:58 +0100 Subject: [PATCH 09/12] fix(lib): remove extra brace --- lib/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/default.nix b/lib/default.nix index f2ea1c0..988c2a5 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -12,5 +12,5 @@ lib.makeExtensible (self: rec { date = mkDate (input.lastModifiedDate or "19700101"); rev = input.shortRev or "dirty"; in - "unstable-${date}_${rev}}"; + "unstable-${date}_${rev}"; }) From 1be12ba2c3312da4ddbfc7f97369084acef155b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 9 Mar 2023 16:17:27 +0100 Subject: [PATCH 10/12] feat(nvim): add impatient.nvim for faster startup --- modules/programs/nvim/default.nix | 1 + modules/programs/nvim/init.lua | 2 ++ 2 files changed, 3 insertions(+) diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index ceb5a1e..36c17cb 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -78,6 +78,7 @@ in cmp_luasnip copilot-cmp direnv-vim + impatient-nvim lsp_lines-nvim lspkind-nvim lspsaga-nvim-original diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua index 6a7a1b2..e7a646d 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/init.lua @@ -37,6 +37,8 @@ if vim.g.neovide then vim.g.neovide_scale_factor = 0.7 end +require("impatient") + local wk = require("which-key") require("nvim-treesitter.configs").setup({ From f87f6d2405c2e8b14cf15900a99a8222a2c30edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 9 Mar 2023 16:58:14 +0100 Subject: [PATCH 11/12] build: update inputs --- flake.lock | 127 ++++++++++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/flake.lock b/flake.lock index ed44f3c..9a66708 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ ] }, "locked": { - "lastModified": 1677247280, - "narHash": "sha256-sa+8MtoAOSLsWP9vf0qiJUyMovIEYgDzHE8TkoK04Hk=", + "lastModified": 1677969766, + "narHash": "sha256-AIp/ZYZMNLDZR/H7iiAlaGpu4lcXsVt9JQpBlf43HRY=", "owner": "ryantm", "repo": "agenix", - "rev": "833f87c8ff574a29aea3e091045cbaed3cf86bc1", + "rev": "03b51fe8e459a946c4b88dcfb6446e45efb2c24e", "type": "github" }, "original": { @@ -69,11 +69,11 @@ ] }, "locked": { - "lastModified": 1676581287, - "narHash": "sha256-a/6ClchROZ5PoLz0WK42mkAkUtJlMDbe5QyyZZ7bomc=", + "lastModified": 1678041467, + "narHash": "sha256-qqHbiN0ZfEuZ2guMAW5T011TqgrPqGqNWlHtd8AXtQA=", "owner": "zhaofengli", "repo": "attic", - "rev": "0bb3d001365a5d75947a7a713dfd06307b3934d4", + "rev": "1a3b6513b02202198bb497608d0cedc45119799b", "type": "github" }, "original": { @@ -115,17 +115,16 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1673405853, - "narHash": "sha256-6Nq9DuOo+gE2I8z5UZaKuumykz2xxZ9JGYmUthOuwSA=", + "lastModified": 1677892403, + "narHash": "sha256-/Wi0L1spSWLFj+UQxN3j0mPYMoc7ZoAujpUF/juFVII=", "owner": "ipetkov", "repo": "crane", - "rev": "b13963c8c18026aa694acd98d14f66d24666f70b", + "rev": "105e27adb70a9890986b6d543a67761cbc1964a2", "type": "github" }, "original": { "owner": "ipetkov", "repo": "crane", - "rev": "b13963c8c18026aa694acd98d14f66d24666f70b", "type": "github" } }, @@ -333,11 +332,11 @@ "forgit-git": { "flake": false, "locked": { - "lastModified": 1676021219, - "narHash": "sha256-/cqDhHilbMSrzwip+2CGJ9Il4wsx5skyMbqC98hewdc=", + "lastModified": 1677621471, + "narHash": "sha256-merUZ0IQ/qmDkquGFjKvc4vJBj4Ff62JpWYOB67lAVY=", "owner": "wfxr", "repo": "forgit", - "rev": "065f7841f334b8707a49ac30d19370aa859db2ed", + "rev": "801239658718863b9c6e0ba21d027cb0caccd465", "type": "github" }, "original": { @@ -399,11 +398,11 @@ ] }, "locked": { - "lastModified": 1677104801, - "narHash": "sha256-2V5nKOYVFMYlseYdDKiEaww2xqcE0GtS1ax3SoUX99I=", + "lastModified": 1678271387, + "narHash": "sha256-H2dv/i1LRlunRtrESirELzfPWdlG/6ElDB1ksO529H4=", "owner": "nix-community", "repo": "home-manager", - "rev": "4295fdfa6b0005c32f2e1f0b732faf5810c1bc7f", + "rev": "36999b8d19eb6eebb41983ef017d7e0095316af2", "type": "github" }, "original": { @@ -439,11 +438,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1672071700, - "narHash": "sha256-Z0pbBVtijv4xbL42rPzMoYFSOqALFRYDMN9iOumSEso=", + "lastModified": 1677679546, + "narHash": "sha256-L+QE6hIHxhYHWPA1jfgZsbQFYxheD/hzFhtwGFRdWOk=", "owner": "hyprwm", "repo": "contrib", - "rev": "37c8121f98d76f57caa00dd7106877876e0d7483", + "rev": "d4eccc8e7d31d30c7ce39dc2b864c4f23f173855", "type": "github" }, "original": { @@ -460,11 +459,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1677162463, - "narHash": "sha256-wjZbwJvIagJ0i82LYm3eIHNsqwblOjIzAyegA3z9olA=", + "lastModified": 1678371846, + "narHash": "sha256-fOFX0PASpIpU4NK9Wen9yJKwg5RYe5jFIu1H0OUzglE=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "60e37d727def25c87a3fd6c47751c05f6082260f", + "rev": "c9167d96467f0c1546f337828e874d7dd849f900", "type": "github" }, "original": { @@ -499,11 +498,11 @@ "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1676681260, - "narHash": "sha256-R2FvbPzgvDSVs0jCUA9CMDIgw4F6exF8cR+y3Yea5jQ=", + "lastModified": 1677282271, + "narHash": "sha256-wNooEHZpKMJN2jj2qPa1jRhi6f5q1yTYCxQcXEJ32eM=", "owner": "hyprwm", "repo": "hyprpaper", - "rev": "2bc88dc8c220db674f458432aec0ac0d9ea6a640", + "rev": "83867464c523c3ac2f7ce53d2c4b8d4f9b7551cd", "type": "github" }, "original": { @@ -515,11 +514,11 @@ "lspsaga-nvim": { "flake": false, "locked": { - "lastModified": 1677497543, - "narHash": "sha256-xFba/hXqc0qyJH9Hd9XtXteXIqjJnIgYIy8Y5l9QPQQ=", + "lastModified": 1678361457, + "narHash": "sha256-nrsMdfF43k0RavCq2hZ799HpY/40O0bi4kAM18dR+f4=", "owner": "glepnir", "repo": "lspsaga.nvim", - "rev": "291629b704ba8fdd0134ef4204fb118050bca363", + "rev": "db6cdf51bf5ae45e4aa65760e597cf0d587c66ee", "type": "github" }, "original": { @@ -530,11 +529,11 @@ }, "master": { "locked": { - "lastModified": 1677259386, - "narHash": "sha256-gFXSvo9CuTJa6V0bK0Gm+JwizlJD+YyJ1VAUW2ij1R4=", + "lastModified": 1678375527, + "narHash": "sha256-0W7Xu8XJLr8wUAf0fYKI2Ese3HB1fC5b/+lS9BPVgOQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e8d97da2540b9de5962849c75c425cc2469d77ad", + "rev": "87af394014d51f563dade30f3f7ef55a00a3d1d6", "type": "github" }, "original": { @@ -550,11 +549,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1677257437, - "narHash": "sha256-fxEb0DrGXv3Q03Gz/oqI8x47WhXLlGtHQFgGIhBl4c0=", + "lastModified": 1678371176, + "narHash": "sha256-tsPKurteDIU0bz9GutdRr4vwQ1kIsbJEbaY0nsz+H94=", "owner": "neovim", "repo": "neovim", - "rev": "15cce77b383d0b0bfdaa1415cdde005cc43267d0", + "rev": "9ef7297ef142354ace8b1f3f277d0eee3cfdc6d4", "type": "github" }, "original": { @@ -575,11 +574,11 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1676390054, - "narHash": "sha256-w0KvrM+9WIEYr0juDh4Vs39ed2IaT0T696fp9pZ7i1I=", + "lastModified": 1678313833, + "narHash": "sha256-HUkOzLVYDTYzxH4zMeR2JIrh1zY/n3LIs8rtNnKeOTA=", "owner": "oxalica", "repo": "nil", - "rev": "944d5c335531778a1d7b54a97bf7fb5ec0c3e976", + "rev": "d1017418841c612552f73d1f670d87f57dc5e090", "type": "github" }, "original": { @@ -654,11 +653,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1677063315, - "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", + "lastModified": 1658161305, + "narHash": "sha256-X/nhnMCa1Wx4YapsspyAs6QYz6T/85FofrI6NpdPDHg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "988cc958c57ce4350ec248d2d53087777f9e1949", + "rev": "e4d49de45a3b5dbcb881656b4e3986e666141ea9", "type": "github" }, "original": { @@ -670,11 +669,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1677063315, - "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", + "lastModified": 1677676435, + "narHash": "sha256-6FxdcmQr5JeZqsQvfinIMr0XcTyTuR7EXX0H3ANShpQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "988cc958c57ce4350ec248d2d53087777f9e1949", + "rev": "a08d6979dd7c82c4cef0dcc6ac45ab16051c1169", "type": "github" }, "original": { @@ -686,11 +685,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1677063315, - "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", + "lastModified": 1674641431, + "narHash": "sha256-qfo19qVZBP4qn5M5gXc/h1MDgAtPA5VxJm9s8RUAkVk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "988cc958c57ce4350ec248d2d53087777f9e1949", + "rev": "9b97ad7b4330aacda9b2343396eb3df8a853b4fc", "type": "github" }, "original": { @@ -718,11 +717,11 @@ }, "nixpkgs_7": { "locked": { - "lastModified": 1677142198, - "narHash": "sha256-Y/uC2ZmkQkyrdRZ5szZilhZ/46786Wio5CGTgL+Vb/c=", + "lastModified": 1678298120, + "narHash": "sha256-iaV5xqgn29xy765Js3EoZePQyZIlLZA3pTYtTnKkejg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "03fb72201639e5274fee6d77b0d9c66e98329aba", + "rev": "1e383aada51b416c6c27d4884d2e258df201bc11", "type": "github" }, "original": { @@ -826,11 +825,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1677160285, - "narHash": "sha256-tBzpCjMP+P3Y3nKLYvdBkXBg3KvTMo3gvi8tLQaqXVY=", + "lastModified": 1677832802, + "narHash": "sha256-XQf+k6mBYTiQUjWRf/0fozy5InAs03O1b30adCpWeXs=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "2bd861ab81469428d9c823ef72c4bb08372dd2c4", + "rev": "382bee738397ca005206eefa36922cc10df8a21c", "type": "github" }, "original": { @@ -905,11 +904,11 @@ ] }, "locked": { - "lastModified": 1675391458, - "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", + "lastModified": 1677638104, + "narHash": "sha256-vbdOoDYnQ1QYSchMb3fYGCLYeta3XwmGvMrlXchST5s=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "rev": "f388187efb41ce4195b2f4de0b6bb463d3cd0a76", "type": "github" }, "original": { @@ -921,11 +920,11 @@ "smartcolumn-nvim": { "flake": false, "locked": { - "lastModified": 1677125264, - "narHash": "sha256-Om0t759e6JYwcg6V+HdJk59h2yVt9kPLwGBMKNnP8AA=", + "lastModified": 1677732751, + "narHash": "sha256-uu9h5Pjw05IokTbJxrVlavZXpm3Ny6jrmhcHXzvwngU=", "owner": "m4xshen", "repo": "smartcolumn.nvim", - "rev": "1202b0741b87b0815bdc6fc6ebacb2df9e6628ee", + "rev": "6e16c7d1b5e8bf4cb7ddcab5c91745190e80e99d", "type": "github" }, "original": { @@ -936,11 +935,11 @@ }, "stable": { "locked": { - "lastModified": 1677075010, - "narHash": "sha256-X+UmR1AkdR//lPVcShmLy8p1n857IGf7y+cyCArp8bU=", + "lastModified": 1678230755, + "narHash": "sha256-SFAXgNjNTXzcAideXcP0takfUGVft/VR5CACmYHg+Fc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c95bf18beba4290af25c60cbaaceea1110d0f727", + "rev": "a7cc81913bb3cd1ef05ed0ece048b773e1839e51", "type": "github" }, "original": { @@ -974,11 +973,11 @@ "flake": false, "locked": { "host": "gitlab.freedesktop.org", - "lastModified": 1675374853, - "narHash": "sha256-BSrjNcddYWhFUMtjGwxiEXw67MYRaIHGvLn19Mvm1NE=", + "lastModified": 1677789111, + "narHash": "sha256-dWrk+Q3bLdtFe5rkyaAKWCQJCeE/KFNllcu1DvBC38c=", "owner": "wlroots", "repo": "wlroots", - "rev": "677a3f2f8847ed2de49dd60868f9d9487a546f58", + "rev": "5ae17de23f5fd9bb252a698f3771c840280e2c05", "type": "gitlab" }, "original": { From b81735b8858b27772d8b33461deebebf11067505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 9 Mar 2023 16:58:44 +0100 Subject: [PATCH 12/12] feat(desktop)!: remove emacs --- modules/profiles/desktop.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/profiles/desktop.nix b/modules/profiles/desktop.nix index 85a5362..8ac556f 100644 --- a/modules/profiles/desktop.nix +++ b/modules/profiles/desktop.nix @@ -21,7 +21,6 @@ with lib; { adb.enable = true; hyprland.enable = true; code.enable = true; - emacs.enable = true; firefox = { enable = true; arkenfox = {