From e115a557c69c2762baf48f36858f5fcb314fa3d9 Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Sun, 9 Oct 2022 21:31:30 -0700 Subject: [PATCH] added vim and rust and nix autocomplete --- configuration.nix | 4 +-- flake.nix | 1 + home.nix | 1 + modules/vim.nix | 31 ++++++++++++++++ modules/zsh.nix | 5 --- rsrcs/.vimrc | 91 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 modules/vim.nix create mode 100644 rsrcs/.vimrc diff --git a/configuration.nix b/configuration.nix index 73663e5..c3c6986 100644 --- a/configuration.nix +++ b/configuration.nix @@ -24,7 +24,7 @@ in efiSupport = true; enable = true; version = 2; - useOSProber = true; + # useOSProber = true; }; }; @@ -107,7 +107,7 @@ in # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ - vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. # wget ]; diff --git a/flake.nix b/flake.nix index edb769d..772c259 100644 --- a/flake.nix +++ b/flake.nix @@ -37,6 +37,7 @@ ./home.nix ./modules/zsh.nix ./modules/urxvt.nix + ./modules/vim.nix ]; }; } diff --git a/home.nix b/home.nix index 6b1bb37..269afbf 100644 --- a/home.nix +++ b/home.nix @@ -31,6 +31,7 @@ in obsidian powerline + nodejs # required for coc-nvim # Gui application firefox libsForQt5.kate diff --git a/modules/vim.nix b/modules/vim.nix new file mode 100644 index 0000000..48da493 --- /dev/null +++ b/modules/vim.nix @@ -0,0 +1,31 @@ +{ config, pkgs, ... }: + +let + +in +{ + programs.vim = { + enable = true; + plugins = with pkgs.vimPlugins; + let + moonfly = pkgs.vimUtils.buildVimPlugin { + name = "moonfly"; + src = pkgs.fetchFromGitHub { + owner = "bluz71"; + repo = "vim-moonfly-colors"; + rev = "d51e3ad78654aa479d59adb81a98f179d595bdee"; + sha256 = "0uHEB8uNQeGpVWuZfyrVAWTyefJMCitTmNpHmKVFOaQ="; + }; + }; + in [ + moonfly + coc-rust-analyzer + coc-nvim + rust-vim + vim-nix + ]; + + extraConfig = builtins.readFile ../rsrcs/.vimrc; + }; + +} diff --git a/modules/zsh.nix b/modules/zsh.nix index 69a5fcc..c2e8c2f 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -40,9 +40,4 @@ in source = ../rsrcs/.p10k.zsh; }; - # programs.zsh.ohMyZsh = { - # enable = true; - - - # }; } diff --git a/rsrcs/.vimrc b/rsrcs/.vimrc new file mode 100644 index 0000000..aa476e9 --- /dev/null +++ b/rsrcs/.vimrc @@ -0,0 +1,91 @@ +set autoindent +set expandtab +set tabstop=4 +set shiftwidth=4 +set foldmethod=syntax +set foldlevel=20 +set number +syntax on +syntax enable +filetype plugin indent on + + + " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable + " delays and poor user experience. + set updatetime=300 + + set signcolumn=number + + + " Use tab for trigger completion with characters ahead and navigate. + " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by + " other plugin before putting this into your config. + inoremap + \ pumvisible() ? "\" : + \ CheckBackspace() ? "\" : + \ coc#refresh() + inoremap pumvisible() ? "\" : "\" + + function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' + endfunction + + " Use to trigger completion. + if has('nvim') + inoremap coc#refresh() + else + inoremap coc#refresh() + endif + + + " Use `[g` and `]g` to navigate diagnostics + " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. + nmap [g (coc-diagnostic-prev) + nmap ]g (coc-diagnostic-next) + + " 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 + + " Highlight the symbol and its references when holding the cursor. + autocmd CursorHold * silent call CocActionAsync('highlight') + + " Symbol renaming. + nmap rn (coc-rename) + + " Formatting selected code. + xmap f (coc-format-selected) + nmap f (coc-format-selected) + let g:rustfmt_autosave = 1 + + " Add `:Format` command to format current buffer. + command! -nargs=0 Format :call CocActionAsync('format') + + " Add `:Fold` command to fold current buffer. + command! -nargs=? Fold :call CocAction('fold', ) + + " Add `:OR` command for organize imports of the current buffer. + command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') + + " Add (Neo)Vim's native statusline support. + " NOTE: Please see `:h coc-status` for integrations with external plugins that + " provide custom statusline: lightline.vim, vim-airline. + set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + + +colorscheme moonfly +set number