From 80d4c64ed2aae6c91667a2c41e218f840825a943 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Thu, 27 Jul 2023 13:13:03 +0200 Subject: [PATCH] Worf: git+vim --- hosts/worf/configuration.nix | 7 ++- hosts/worf/home.nix | 25 +++++++- hosts/worf/neovim.nix | 109 +++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 hosts/worf/neovim.nix diff --git a/hosts/worf/configuration.nix b/hosts/worf/configuration.nix index 477b7c0..d941950 100644 --- a/hosts/worf/configuration.nix +++ b/hosts/worf/configuration.nix @@ -16,9 +16,10 @@ # System packages for all users environment = { systemPackages = with pkgs; [ + findutils + gnugrep ripgrep wget - git ]; variables = { @@ -39,12 +40,12 @@ fonts = { fontDir.enable = true; fonts = with pkgs; [ - source-code-pro font-awesome + fira-code hack-font (nerdfonts.override { fonts = [ - "FiraCode" + "Hack" ]; }) ]; diff --git a/hosts/worf/home.nix b/hosts/worf/home.nix index 112a68e..d08928c 100644 --- a/hosts/worf/home.nix +++ b/hosts/worf/home.nix @@ -6,6 +6,7 @@ }: { imports = [ + ./neovim.nix ./zsh.nix ]; @@ -14,12 +15,34 @@ discord exa iterm2 - neovim + nix-index + nodejs slack spotify vscode ]; + programs.git = { + enable = true; + + extraConfig = { + pull.rebase = "true"; + color.ui = "auto"; + init.defaultBranch = "main"; + + user = { + name = "Felix Albrigtsen"; + email = "felix@albrigtsen.it"; + }; + }; + ignores = [ + "*~" + "*.swp" + ".DS_Store" + ".vscode" + ]; + }; + # Copy Applications to ~/Applications to allow them to be launched from Spotlight disabledModules = [ "targets/darwin/linkapps.nix" ]; home.activation = lib.mkIf pkgs.stdenv.isDarwin { diff --git a/hosts/worf/neovim.nix b/hosts/worf/neovim.nix new file mode 100644 index 0000000..3d206a8 --- /dev/null +++ b/hosts/worf/neovim.nix @@ -0,0 +1,109 @@ +{ pkgs, lib, inputs, config, ...}: +let + # fromGitHub = rev: ref: repo: pkgs.vimUtils.buildVimPluginFrom2Nix { + # pname = "${lib.strings.sanitizeDerivationName repo}"; + # version = ref; + # src = builtins.fetchGit { + # url = "https://github.com/${repo}.git"; + # ref = ref; + # rev = rev; + # }; + # }; +in { + programs.neovim = { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + plugins = with pkgs.vimPlugins; [ + lightline-vim + vim-lightline-coc + + vim-commentary + vim-fugitive + + nerdtree + nerdtree-git-plugin + vim-devicons + + nvim-lspconfig + copilot-vim + nvim-treesitter + + coc-nvim + coc-pyright + + vim-nix + ]; + + extraConfig = '' + let mapleader = ',' + + " Integrate status with lightline + let g:lightline = { + \ 'active': { + \ 'left': [[ 'coc_info', 'coc_hints', 'coc_errors', 'coc_warnings', 'coc_ok' ], [ 'coc_status' ]] + \ } + \ } + + " register components: + call lightline#coc#register() + + " GoTo code navigation. + nmap gd (coc-definition) + nmap gy (coc-type-definition) + nmap gi (coc-implementation) + nmap gr (coc-references) + + " Use K to show documentation in preview window. + nnoremap K :call ShowDocumentation() + function! ShowDocumentation() + if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') + else + call feedkeys('K', 'in') + endif + endfunction + + " Enable syntax folding with coc + command! -nargs=* Fold :call CocAction('fold', ) + + inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + + " Highlight the symbol and its references when holding the cursor. + autocmd CursorHold * silent call CocActionAsync('highlight') + + " Symbol renaming. + nmap rn (coc-rename) + + " Use CTRL-S for selections ranges. + " Requires 'textDocument/selectionRange' support of language server. + nmap (coc-range-select) + xmap (coc-range-select) + + " Step through diagnostics + nmap (coc-diagnostic-prev) + nmap >g (coc-diagnostic-next) + + " Nerdtree-settings + " Toggle nerdtree on Ctrl+t + nmap :NERDTreeToggle + autocmd VimEnter * NERDTree " Autostart nerdtree on vim startup + autocmd VimEnter * wincmd p " Unselect nerdtree window + " Close vim is Nerdtree is the only buffer left + autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif + + " List and switch buffers on Ctrl+k + nnoremap :set nomore :ls :set more :b + + " Show trailing whitespace + highlight ExtraWhitespace ctermbg=red guibg=red + match ExtraWhitespace /\s\+$/ + + " Disable search highlights + map :noh + ''; + }; +} \ No newline at end of file