diff --git a/flake.lock b/flake.lock index 1bf516f..113b7c0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,28 @@ { "nodes": { + "beautysh": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "poetry2nix": "poetry2nix", + "utils": "utils" + }, + "locked": { + "lastModified": 1680308980, + "narHash": "sha256-aUEHV0jk2qIFP3jlsWYWhBbm+w/N9gzH3e4I5DcdB5s=", + "owner": "lovesegfault", + "repo": "beautysh", + "rev": "9845efc3ea3e86cc0d41465d720a47f521b2799c", + "type": "github" + }, + "original": { + "owner": "lovesegfault", + "repo": "beautysh", + "type": "github" + } + }, "crane": { "inputs": { "flake-compat": [ @@ -49,6 +72,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -88,6 +127,42 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -110,6 +185,28 @@ "type": "github" } }, + "gitignore_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -204,6 +301,97 @@ "type": "github" } }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "beautysh": "beautysh", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1693862861, + "narHash": "sha256-+ynDsujluFf187KZvyBZ1C/BTty3TtKWuzuvpQ7sy/Q=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "b7611f74a9b1107e09925664f652b141926b0b92", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": [ + "nixvim", + "beautysh", + "utils" + ], + "nixpkgs": [ + "nixvim", + "beautysh", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658665240, + "narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_3", + "gitignore": "gitignore_2", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable_2" + }, + "locked": { + "lastModified": 1692274144, + "narHash": "sha256-BxTQuRUANQ81u8DJznQyPmRsg63t4Yc+0kcyq6OLz8s=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "7e3517c03d46159fdbf8c0e5c97f82d5d4b0c8fa", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -257,9 +445,10 @@ "lanzaboote": "lanzaboote", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", + "nixvim": "nixvim", "private": "private", "rustybar": "rustybar", - "utils": "utils_2", + "utils": "utils_3", "wip-pinebook-pro": "wip-pinebook-pro" } }, @@ -293,7 +482,7 @@ "nixpkgs": [ "nixpkgs" ], - "utils": "utils" + "utils": "utils_2" }, "locked": { "lastModified": 1637380210, @@ -339,7 +528,52 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_2": { "locked": { "lastModified": 1637014545, "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=", @@ -354,9 +588,9 @@ "type": "github" } }, - "utils_2": { + "utils_3": { "inputs": { - "systems": "systems_2" + "systems": "systems_4" }, "locked": { "lastModified": 1692799911, diff --git a/flake.nix b/flake.nix index 3a2332c..07a3e43 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + rustybar = { url = "github:mildlyfunctionalgays/rustybar"; inputs.nixpkgs.follows = "nixpkgs"; @@ -28,7 +33,7 @@ }; }; - outputs = { self, nixpkgs, home-manager, private, utils, ... }@inputs: + outputs = { self, nixpkgs, home-manager, private, utils, nixvim, ... }@inputs: let makeSystem = conf: nixpkgs.lib.nixosSystem (nixpkgs.lib.recursiveUpdate conf rec { @@ -36,6 +41,7 @@ modules = [ private.nixosModules.base home-manager.nixosModules.home-manager + nixvim.nixosModules.nixvim { home-manager.extraSpecialArgs = specialArgs; } ] ++ (conf.modules or [ ]); }); diff --git a/home/default.nix b/home/default.nix index 24ee1f1..c223548 100644 --- a/home/default.nix +++ b/home/default.nix @@ -6,8 +6,7 @@ useGlobalPkgs = true; }; home-manager.users.artemis = { - imports = - [ ./fish.nix ./gtk.nix ./git.nix ./mpv.nix ./kitty.nix ./neovim ./ssh ]; + imports = [ ./fish.nix ./gtk.nix ./git.nix ./mpv.nix ./kitty.nix ./ssh ]; home.stateVersion = config.system.stateVersion; diff --git a/home/neovim/default.nix b/home/neovim/default.nix deleted file mode 100644 index 066e4d9..0000000 --- a/home/neovim/default.nix +++ /dev/null @@ -1,60 +0,0 @@ -{ config, pkgs, ... }: - -let - lsp-colors = pkgs.vimUtils.buildVimPluginFrom2Nix { - pname = "lsp-colors.nvim"; - version = "2021-10-22"; - src = pkgs.fetchFromGitHub { - owner = "folke"; - repo = "lsp-colors.nvim"; - rev = "517fe3ab6b63f9907b093bc9443ef06b56f804f3"; - sha256 = "vXX9/5hulIlDwE9ISZlTMxxrl+Jjyquagv5+AHmEA5c="; - fetchSubmodules = false; - }; - meta.homepage = "https://github.com/folke/lsp-colors.nvim"; - }; -in { - programs.neovim = { - enable = true; - vimAlias = true; - extraConfig = (builtins.replaceStrings [ "{{CLANGDPATH}}" "{{JLSPATH}}" ] [ - "${pkgs.clang-tools}/bin/clangd" - "${pkgs.java-language-server}/bin/java-language-server" - ] (builtins.readFile ./init.vim)); - plugins = with pkgs.vimPlugins; [ - editorconfig-vim - fzf-vim - gruvbox - meson - vim-airline - vim-clang-format - vim-fetch - vim-fish - vim-flatbuffers - vim-nftables - vim-nix - vim-protobuf - vim-sensible - vim-toml - - nvim-lspconfig - nvim-compe - lsp-colors - ]; - }; - - home.sessionVariables = { - EDITOR = "nvim"; - VISUAL = "nvim"; - }; - home.packages = with pkgs; [ - nixpkgs-fmt - python3 - python3Packages.ipython - python3Packages.pylint - nodePackages.pyright - rust-analyzer - rnix-lsp - ]; - -} diff --git a/home/neovim/init.vim b/home/neovim/init.vim deleted file mode 100644 index c5008b6..0000000 --- a/home/neovim/init.vim +++ /dev/null @@ -1,102 +0,0 @@ -cnoremap w!! w !sudo tee > /dev/null % - -autocmd vimenter * ++nested colorscheme gruvbox - -set guifont=Fira\ Code:h11 - -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#fnamemod = ':t' -let g:airline_powerline_fonts = 1 - -set hidden -set nobackup -set nowritebackup -set cmdheight=2 -set updatetime=300 -set shortmess+=c -set signcolumn=yes - -lua << EOF --- Mostly stolen from https://github.com/breuerfelix/nixos/blob/e0c83e66e821d407efae3e998b8eb70b50f9f5e3/shell/vim/lsp.lua -local nvim_lsp = require('lspconfig') -local on_attach = function(client, bufnr) - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - local opts = { noremap = true, silent = true } - buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'gt', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - - buf_set_keymap('n', 'ra', 'lua vim.lsp.buf.code_action()', opts) - buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'rd', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', 'rh', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', 'rs', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'rk', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', 'rj', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'rl', 'lua vim.lsp.diagnostic.set_loclist()', opts) - - -- Set some keybinds conditional on server capabilities - if client.resolved_capabilities.document_formatting then - buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) - elseif client.resolved_capabilities.document_range_formatting then - buf_set_keymap("n", "f", "lua vim.lsp.buf.range_formatting()", opts) - end - - -- Set autocommands conditional on server_capabilities - if client.resolved_capabilities.document_highlight then - vim.api.nvim_exec([[ - hi LspReferenceRead cterm=bold ctermbg=red guibg=LightGrey - hi LspReferenceText cterm=bold ctermbg=red guibg=LightGrey - hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightGrey - augroup lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END - ]], false) - end -end - -nvim_lsp['pyright'].setup { on_attach = on_attach } -nvim_lsp['clangd'].setup { - on_attach = on_attach, - cmd = { "{{CLANGDPATH}}" } -} -nvim_lsp['java_language_server'].setup { - on_attach = on_attach, - cmd = { "{{JLSPATH}}" } -} -nvim_lsp['rust_analyzer'].setup { on_attach = on_attach } -nvim_lsp['rnix'].setup { on_attach = on_attach } - -require'compe'.setup { - enabled = true; - autocomplete = true; - debug = false; - min_length = 1; - preselect = 'enable'; - throttle_time = 80; - source_timeout = 200; - incomplete_delay = 400; - max_abbr_width = 100; - max_kind_width = 100; - max_menu_width = 100; - documentation = true; - - source = { - path = true; - buffer = true; - calc = true; - nvim_lsp = true; - nvim_lua = true; - vsnip = false; - }; -} -EOF diff --git a/sets/nvim.nix b/sets/nvim.nix new file mode 100644 index 0000000..08b547d --- /dev/null +++ b/sets/nvim.nix @@ -0,0 +1,119 @@ +{ pkgs, ... }: + +{ + environment.sessionVariables = { + EDITOR = "nvim"; + VISUAL = "nvim"; + }; + programs.nixvim = { + enable = true; + vimAlias = true; + + # Basic editing / QoL + editorconfig.enable = true; + colorschemes.kanagawa.enable = true; + plugins = { + nix.enable = true; + airline = { + enable = true; + powerline = true; + theme = "dark"; + }; + }; + globals = { + "airline#extensions#tabline#enabled" = 1; + "airline#extensions#tabline#formatter" = "unique_tail_improved"; + }; + extraPlugins = with pkgs.vimPlugins; [ + vim-fetch + vim-fish + vim-flatbuffers + vim-nftables + vim-protobuf + vim-sensible + vim-toml + ]; + options = { + hidden = true; + backup = false; + writebackup = false; + cmdheight = 2; + updatetime = 300; + shortmess = "filnxtToOFc"; + signcolumn = "yes"; + number = true; + }; + + # LSP + plugins.rust-tools.enable = true; + plugins.lsp-format.enable = true; + plugins.lsp = { + enable = true; + servers = { + clangd.enable = true; + java-language-server.enable = true; + nil_ls.enable = true; + pylsp.enable = true; + }; + + keymaps = { + silent = true; + diagnostic = { + "rk" = "goto_prev"; + "rj" = "goto_next"; + }; + lspBuf = { + K = "hover"; + gD = "declaration"; + gd = "definition"; + gt = "type_definition"; + gr = "references"; + gi = "implementation"; + "ra" = "code_action"; + "rn" = "rename"; + "rs" = "signature_help"; + }; + }; + + onAttach = '' + if client.server_capabilities.documentHighlightProvider then + vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true }) + vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" } + vim.api.nvim_create_autocmd("CursorHold", { + callback = vim.lsp.buf.document_highlight, + buffer = bufnr, + group = "lsp_document_highlight", + desc = "Document Highlight", + }) + vim.api.nvim_create_autocmd("CursorMoved", { + callback = vim.lsp.buf.clear_references, + buffer = bufnr, + group = "lsp_document_highlight", + desc = "Clear All the References", + }) + end + ''; + }; + + # Autocomplete + plugins = { + nvim-cmp = { + enable = true; + sources = [ + { name = "nvim_lsp"; } + { name = "path"; } + { name = "calc"; } + { name = "emoji"; } + ]; + mappingPresets = [ "insert" "cmdline" ]; + mapping = { + "" = "cmp.mapping.confirm({ select = true })"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.abort()"; + }; + }; + }; + }; +} diff --git a/sets/packages.nix b/sets/packages.nix index a33142d..1357d6d 100644 --- a/sets/packages.nix +++ b/sets/packages.nix @@ -52,7 +52,6 @@ jq libarchive lsof - neovim nix-index openssl p7zip diff --git a/sets/workstation.nix b/sets/workstation.nix index d6ad2ff..d8603de 100644 --- a/sets/workstation.nix +++ b/sets/workstation.nix @@ -1,7 +1,8 @@ { config, pkgs, ... }: { - imports = [ ./sway.nix ./packages.nix ./pipewire.nix ./base.nix ../home ]; + imports = + [ ./sway.nix ./packages.nix ./pipewire.nix ./base.nix ./nvim.nix ../home ]; i18n.defaultLocale = "de_DE.UTF-8"; i18n.supportedLocales = [ "all" ];