From 94ee3ce222fa1606510e0f99d553919504845a3d Mon Sep 17 00:00:00 2001 From: Kopatz <7265381+Kropatz@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:46:01 +0100 Subject: [PATCH] fail miserably at neovim --- flake.nix | 11 +++++ users/anon.nix | 2 +- users/home-manager/nvim.nix | 46 ------------------- users/home-manager/nvim/config.lua | 29 ++++++++++++ users/home-manager/nvim/nvim.nix | 72 ++++++++++++++++++++++++++++++ users/kopatz.nix | 2 +- 6 files changed, 114 insertions(+), 48 deletions(-) delete mode 100644 users/home-manager/nvim.nix create mode 100644 users/home-manager/nvim/config.lua create mode 100644 users/home-manager/nvim/nvim.nix diff --git a/flake.nix b/flake.nix index 9324050..005f861 100644 --- a/flake.nix +++ b/flake.nix @@ -61,6 +61,17 @@ ]; specialArgs = { inherit inputs; }; }; + nixosConfigurations."nix-laptop" = nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = {inherit inputs; }; + modules = [ + ./users/kopatz.nix + ./laptop/configuration.nix + nixos-hardware.nixosModules.dell-xps-15-7590-nvidia + agenix.nixosModules.default + home-manager.nixosModules.home-manager + ]; + }; nixosConfigurations."nix-laptop-no-gpu" = nixpkgs.lib.nixosSystem { inherit system; specialArgs = {inherit inputs; }; diff --git a/users/anon.nix b/users/anon.nix index 6fff222..be4b073 100644 --- a/users/anon.nix +++ b/users/anon.nix @@ -5,7 +5,7 @@ in { imports = [ ( - import ./home-manager/nvim.nix ({ user="${user}"; }) + import ./home-manager/nvim/nvim.nix ({ user="${user}"; pkgs=pkgs; }) ) ]; home-manager = { diff --git a/users/home-manager/nvim.nix b/users/home-manager/nvim.nix deleted file mode 100644 index 0145d82..0000000 --- a/users/home-manager/nvim.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ user, ... }: -{ - home-manager.users.${user} = { pkgs, ...}: { - programs.neovim = { - enable = true; - defaultEditor = true; - viAlias = true; - vimAlias = true; - - plugins = with pkgs.vimPlugins; [ - (nvim-treesitter.withAllGrammars) - ]; - extraPackages = with pkgs; - []; - extraConfig = '' - set autoindent expandtab tabstop=4 shiftwidth=4 - set clipboard=unnamed - syntax on - set cc=80 - colorscheme habamax - set list - set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,precedes:«,extends:» - ''; - coc.enable = true; - coc.settings = '' - "suggest.noselect" = true; - "suggest.enablePreview" = true; - "suggest.enablePreselect" = false; - "suggest.disableKind" = true; - "languageserver": { - "nix": { - "command": "${pkgs.nil}/bin/nil", - "filetypes": ["nix"], - "rootPatterns": ["flake.nix"], - // Uncomment these to tweak settings. - // "settings": { - // "nil": { - // "formatting": { "command": ["nixpkgs-fmt"] } - // } - // } - } - } - ''; - }; - }; -} diff --git a/users/home-manager/nvim/config.lua b/users/home-manager/nvim/config.lua new file mode 100644 index 0000000..726b756 --- /dev/null +++ b/users/home-manager/nvim/config.lua @@ -0,0 +1,29 @@ +-- ------- +-- Library +-- ------- + +function map (mode, shortcut, command) +vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true }) +end +function nmap(shortcut, command) +map('n', shortcut, command) +end +function imap(shortcut, command) +map('i', shortcut, command) +end + +-- ------ +-- Config +-- ------ + +vim.cmd([[ +set autoindent expandtab tabstop=4 shiftwidth=4 +set clipboard=unnamed +syntax on +set cc=80 +colorscheme habamax +set list +set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,precedes:«,extends:» +map +]]) + diff --git a/users/home-manager/nvim/nvim.nix b/users/home-manager/nvim/nvim.nix new file mode 100644 index 0000000..3a03a1a --- /dev/null +++ b/users/home-manager/nvim/nvim.nix @@ -0,0 +1,72 @@ +{ user, pkgs, ... }: +{ + home-manager.users.${user} = { pkgs, ...}: { + programs.neovim = { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + + plugins = with pkgs.vimPlugins; [ + (nvim-treesitter.withAllGrammars) + vim-nix + # Buffer tabs + { + plugin = bufferline-nvim; + type = "lua"; + config = '' + require("bufferline").setup{ } + nmap("b", ":BufferLineCycleNext") + nmap("B", ":BufferLineCyclePrev") + ''; + } + # File browser + { + plugin = nvim-tree-lua; + type = "lua"; + config = '' + require("nvim-tree").setup() + ''; + } + { + plugin = vim-which-key; + type = "lua"; + # TODO: How to port this to Lua? + config = '' + vim.cmd([[ + map + let g:mapleader = "\" + let g:maplocalleader = ',' + nnoremap :WhichKey '' + nnoremap :WhichKey ',' + ]]) + ''; + } + ]; + extraPackages = with pkgs; [ + nodejs + nil + ]; + extraConfig = '' + lua << EOF + ${builtins.readFile ./config.lua} + EOF + ''; + coc.enable = true; + coc.settings = '' + "suggest.noselect" = true; + "suggest.enablePreview" = true; + "suggest.enablePreselect" = false; + "suggest.disableKind" = true; + "coc.preferences.formatOnSave" = true; + "languageserver": { + "nix": { + "command": "${pkgs.nil}/bin/nil", + "filetypes": ["nix"], + "rootPatterns": ["flake.nix"], + } + } + ''; + }; + }; +} diff --git a/users/kopatz.nix b/users/kopatz.nix index 023c4ea..66e2b04 100644 --- a/users/kopatz.nix +++ b/users/kopatz.nix @@ -5,7 +5,7 @@ in { imports = [ ( - import ./home-manager/nvim.nix ({ user="${user}"; }) + import ./home-manager/nvim/nvim.nix ({ user="${user}"; pkgs = pkgs; }) ) ]; home-manager = {