From cf55ba3d7005556c8ae74e257267252b52f5d340 Mon Sep 17 00:00:00 2001 From: Christoph Hollizeck Date: Thu, 28 Mar 2024 23:42:34 +0100 Subject: [PATCH] working on improving nixvim config, just need to learn how to seperate out files now --- .../nixos/apps/cli-apps/nixvim/default.nix | 240 ++++++++++++++---- 1 file changed, 197 insertions(+), 43 deletions(-) diff --git a/modules/nixos/apps/cli-apps/nixvim/default.nix b/modules/nixos/apps/cli-apps/nixvim/default.nix index d63d9cc..4ca87a9 100644 --- a/modules/nixos/apps/cli-apps/nixvim/default.nix +++ b/modules/nixos/apps/cli-apps/nixvim/default.nix @@ -24,9 +24,17 @@ in { options = { number = true; relativenumber = true; - shiftwidth = 2; + shiftwidth = 4; }; + autoCmd = [ + { + event = "FileType"; + pattern = "nix"; + command = "setlocal tabstop=2 shiftwidth=2"; + } + ]; + keymaps = [ { action = "Ex"; @@ -97,64 +105,210 @@ in { treesitter = { enable = true; + nixGrammars = true; + indent = true; }; - - luasnip.enable = true; + treesitter-context.enable = true; lualine.enable = true; - lsp = { - enable = true; - - servers = { - nixd.enable = true; - }; - keymaps = { - lspBuf = { - "K" = "hover"; - "gf" = "references"; - "gd" = "definition"; - "gi" = "implementation"; - "gt" = "type_definition"; - }; - }; + copilot-lua = { + panel.enabled = false; + suggestion.enabled = false; }; - lsp-format = { - enable = true; - setup = { - nix = { - }; - }; - }; + nix.enable = true; + nix-develop.enable = true; - cmp = { - enable = true; - settings = { - }; - }; + nvim-autopairs.enable = true; - rainbow-delimiters = { - enable = true; - }; + rainbow-delimiters = {enable = true;}; nvim-colorizer.enable = true; undotree.enable = true; - which-key = { - enable = true; - registrations = { - "K" = "Code hover"; - "gf" = "Code references"; - "gd" = "Code definitions"; - "gi" = "Implementations"; - "gt" = "Type definition"; - }; - }; + which-key = {enable = true;}; trouble.enable = true; markdown-preview.enable = true; + + dashboard = {enable = true;}; + + auto-save = { + enable = true; + enableAutoSave = true; + }; + + ## cmp extract into file + luasnip.enable = true; + cmp-buffer = {enable = true;}; + + cmp-emoji = {enable = true;}; + + cmp-nvim-lsp = {enable = true;}; + + cmp-path = {enable = true;}; + + cmp_luasnip = {enable = true;}; + + cmp = { + enable = true; + + settings = { + snippet.expand = "luasnip"; + sources = [ + {name = "nvim_lsp";} + {name = "luasnip";} + {name = "copilot";} + { + name = "buffer"; + option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; + } + {name = "nvim_lua";} + {name = "path";} + ]; + + formatting = { + fields = ["abbr" "kind" "menu"]; + format = + # lua + '' + function(_, item) + local icons = { + Namespace = "󰌗", + Text = "󰉿", + Method = "󰆧", + Function = "󰆧", + Constructor = "", + Field = "󰜢", + Variable = "󰀫", + Class = "󰠱", + Interface = "", + Module = "", + Property = "󰜢", + Unit = "󰑭", + Value = "󰎠", + Enum = "", + Keyword = "󰌋", + Snippet = "", + Color = "󰏘", + File = "󰈚", + Reference = "󰈇", + Folder = "󰉋", + EnumMember = "", + Constant = "󰏿", + Struct = "󰙅", + Event = "", + Operator = "󰆕", + TypeParameter = "󰊄", + Table = "", + Object = "󰅩", + Tag = "", + Array = "[]", + Boolean = "", + Number = "", + Null = "󰟢", + String = "󰉿", + Calendar = "", + Watch = "󰥔", + Package = "", + Copilot = "", + Codeium = "", + TabNine = "", + } + + local icon = icons[item.kind] or "" + item.kind = string.format("%s %s", icon, item.kind or "") + return item + end + ''; + }; + + window = { + completion = { + winhighlight = "FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel"; + scrollbar = false; + sidePadding = 0; + border = ["╭" "─" "╮" "│" "╯" "─" "╰" "│"]; + }; + + settings.documentation = { + border = ["╭" "─" "╮" "│" "╯" "─" "╰" "│"]; + winhighlight = "FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel"; + }; + }; + + mapping = { + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.close()"; + "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })"; + "" = + # lua + '' + function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end + ''; + "" = + # lua + '' + function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end + ''; + }; + }; + }; + + ## lsp + lsp = { + enable = true; + servers = { + fsautocomplete.enable = true; + nixd.enable = true; + }; + keymaps.lspBuf = { + "gd" = "definition"; + "gD" = "references"; + "gt" = "type_definition"; + "gi" = "implementation"; + "K" = "hover"; + }; + }; + rust-tools.enable = true; + + ## none-ls + none-ls = { + enable = true; + sources = { + diagnostics = {statix.enable = true;}; + formatting = { + nixfmt.enable = true; + markdownlint.enable = true; + shellharden.enable = true; + shfmt.enable = true; + }; + }; + }; }; }; };