Worf: git+vim

This commit is contained in:
Felix Albrigtsen 2023-07-27 13:13:03 +02:00
parent 095af4edbe
commit 714907374e
3 changed files with 137 additions and 4 deletions

View File

@ -16,9 +16,10 @@
# System packages for all users # System packages for all users
environment = { environment = {
systemPackages = with pkgs; [ systemPackages = with pkgs; [
findutils
gnugrep
ripgrep ripgrep
wget wget
git
]; ];
variables = { variables = {
@ -39,12 +40,12 @@
fonts = { fonts = {
fontDir.enable = true; fontDir.enable = true;
fonts = with pkgs; [ fonts = with pkgs; [
source-code-pro
font-awesome font-awesome
fira-code
hack-font hack-font
(nerdfonts.override { (nerdfonts.override {
fonts = [ fonts = [
"FiraCode" "Hack"
]; ];
}) })
]; ];

View File

@ -6,6 +6,7 @@
}: { }: {
imports = [ imports = [
./neovim.nix
./zsh.nix ./zsh.nix
]; ];
@ -14,12 +15,34 @@
discord discord
exa exa
iterm2 iterm2
neovim nix-index
nodejs
slack slack
spotify spotify
vscode 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 # Copy Applications to ~/Applications to allow them to be launched from Spotlight
disabledModules = [ "targets/darwin/linkapps.nix" ]; disabledModules = [ "targets/darwin/linkapps.nix" ];
home.activation = lib.mkIf pkgs.stdenv.isDarwin { home.activation = lib.mkIf pkgs.stdenv.isDarwin {

109
hosts/worf/neovim.nix Normal file
View File

@ -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 <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>
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', <f-args>)
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Step through diagnostics
nmap <silent> <g <Plug>(coc-diagnostic-prev)
nmap <silent> >g <Plug>(coc-diagnostic-next)
" Nerdtree-settings
" Toggle nerdtree on Ctrl+t
nmap <silent> <C-t> :NERDTreeToggle<CR>
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 <C-k> :set nomore <Bar> :ls <Bar> :set more <CR>:b<Space>
" Show trailing whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
" Disable search highlights
map <Leader><Space> :noh<CR>
'';
};
}