From d1f9e2c3ec6e3dd4f8311fda3a44850e97ce6974 Mon Sep 17 00:00:00 2001 From: mehbark Date: Mon, 14 Aug 2023 07:45:15 -0400 Subject: [PATCH] maybe --- flake.nix | 32 +- home.nix | 1248 ++++++++++++++++++++++++++--------------------------- 2 files changed, 641 insertions(+), 639 deletions(-) diff --git a/flake.nix b/flake.nix index f22581e..77d74d4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,16 +1,24 @@ { - inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - inputs.home-manager.url = "github:nix-community/home-manager"; - inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs"; + description = "mehbark's NixOS configuration"; - outputs = {self, nixpkgs, home-manager }: { - nixosConfigurations = { - nix = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./configuration.nix - ]; - }; - }; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + inputs.home-manager.url = "github:nix-community/home-manager"; + inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + outputs = inputs@{ self, nixpkgs, home-manager }: { + nixosConfigurations = { + nix = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.mbk = import ./home.nix; + } + ]; + }; }; + }; } diff --git a/home.nix b/home.nix index 52a7474..62bd597 100644 --- a/home.nix +++ b/home.nix @@ -1,634 +1,628 @@ { config, pkgs, ... }: { - imports = [ - + /* The home.stateVersion option does not have a default and must be set */ + home.stateVersion = "18.09"; + home.packages = with pkgs; [ + firefox + clojure + deno + kitty + # bsdgames + fortune + cowsay + git + sbcl + lispPackages.trivia + # lutris + # mono5 + nethack + chezmoi + # wineWowPackages.stable + # winetricks + # foliate + # thunderbird + starship + exa ]; - home-manager.users.mbk = {pkgs, ...}: { - /* The home.stateVersion option does not have a default and must be set */ - home.stateVersion = "18.09"; - home.packages = with pkgs; [ - firefox - clojure - deno - kitty - # bsdgames - fortune - cowsay - git - sbcl - lispPackages.trivia - # lutris - # mono5 - nethack - chezmoi - # wineWowPackages.stable - # winetricks - # foliate - # thunderbird - starship - exa + programs.fish = { + enable = true; + + shellInit = '' + #### BEGIN ALIASES #### + alias v='nvim' + + alias vcf="v ~/.config/nvim/init.vim" + + alias vw='nvim ~/vimwiki/index.wiki; commit-vimwiki' + + function commit-vimwiki --description "go to and from the vimwiki directory, commit with message (to encourage uh, good stuff, and go back" + cd ~/vimwiki + git add * + git commit + prevd + end + + alias vt='nvim ~/vimwiki/Tasks.wiki' + + alias vwo="firefox ~/vimwiki_html/index.html" + alias vwr="nvim -c "VimwikiAll2HTML" -c "q" ~/vimwiki/index.wiki" + alias nv='neovide' + # alias hx='helix' + alias lv="~/.local/bin/lvim" + alias e='emacs' + alias ce='code .' + alias se="serve ." + alias co='code --reuse-window' + alias ok='okular' + alias ko='kitty .' + alias du="du -h --total" + + #exa + alias ls="exa" + alias tree="exa --tree -I target" + + # some more ls aliases + # alias ls='ls --color=always' + alias ll='ls -alF' + alias la='ls -a' + alias l='ls -CF' + + #some cargo aliases :) + alias c='cargo' + alias cn='cargo new' + alias cnl='cargo new --lib' + alias ci='cargo init' + alias cr='cargo run' + alias cb='cargo build' + alias ct='cargo test' + alias cv='cargo clippy' + alias cf='cargo flamegraph' + alias cff='cargo flamegraph;firefox flamegraph.svg' + alias cvp='cargo clippy -- -W clippy::pedantic' + alias cw="cargo watch -c --poll -x 'clippy -- -W clippy::pedantic'" + alias cwr='cargo watch -c -x run' + alias cwt='cargo watch -c -x test' + alias cbr='cargo build --release' + alias crr='cargo run --release' + alias crd="cargo rustdoc" + alias cft="cargo fmt" + alias cdc="cargo doc; firefox target/doc/settings.html" + + #general rust aliases + alias rft='rustfmt' + + #git aliases + alias g="git" + alias gcs="batcat -p -l bash /home/mehbark/main/misc/gitCliCheatSheet.js" + alias gco="git checkout" + alias gb="git branch" + alias gc="git commit -m" + alias gst="git status" + alias ga="git add" + alias gp="git push" + alias gl='git log --oneline --graph --decorate --all' + alias gi='git init' + + #more complex aliases + alias ri="git init; cargo init" + alias rn="new_cargo_quick" + alias ka="killall -r '.*'" + + function new_cargo_quick --description "make a cargo project with git version control, cd to it and open vscode" + mkdir "$argv[1]" + cd "$argv[1]" + git init + cargo init + code . + end + + function speed-up --description "take arg 1, speed it up by arg 3 and output it to arg 2" + echo "$argv[1]" + mencoder -o "$argv[2]" -speed "$argv[3]" -ovc lavc -oac lavc "$argv[1]" + end + + alias doom='~/.config/emacs/bin/doom' + alias pipers='pipes-rs' + alias yt='yt-dlp' + alias compile_and_serve="cargo run --quiet --release example_in example_out;cd example_out;serve;cd .." + alias icat="kitty +kitten icat" + + alias do="dolphin . &> /dev/null &" + + #homestuck + alias hnav "source /home/mbk/hs/bin/hsnav" + alias hstree "tree ~/hs" + alias codestuck "code ~/hs" + + function m + mkdir $argv[1] + cd $argv[1] + end + + function playflac + flac -c -d $argv | aplay + end + + function filelink + echo "file://$(realpath $argv)" + end + alias xpy '~/Aims/rust/x.py' + alias sbcl "rlwrap sbcl" + alias guile "rlwrap guile" + #alias clj 'clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.4\"} $args}}" -m rebel-readline.main' + alias csi "rlwrap chicken-csi" + + # zig + alias zb "zig build" + alias zbr "zig build run" + alias zbt "zig build test" + + # nix + alias nrb "sudo nixos-rebuild" + #### END ALIASES #### + export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$HOME/.local/bin:$HOME/.emacs.d/bin:$PATH:$HOME/.ghcup/bin:$HOME/.cabal/bin:$HOME/hs/bin:$HOME/.cargo/bin:$HOME/.deno/bin:$HOME/Aims/curlfire" + + # [ -f ~/.fzf.bash ] && source ~/.fzf.bash + # setopt autocd + fish_vi_key_bindings + fish_vi_cursor + starship init fish | source + export RUSTC_FORCE_INCREMENTAL=1 + export EDITOR="nvim" + export TROLLNAMES_PATH="/home/mbk/hs/content/mine/trollname/6-letter-english-words.txt" + + set fish_greeting + + if status is-interactive + if set -q ASCIINEMA_REC + return + end + if test $PWD = "/home/mbk/hs" + homestartup + else + fortune | cowsay + end + end + + export CHEZSCHEMELIBDIRS="/home/mbk/Aims/chez/thunderchez:/home/mbk/Aims/chez/thunderchez:/home/mbk/Aims/chez/chez-srfi:/home/mbk/Aims/chez/pfds" + + # opam configuration + source /home/mbk/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true + ''; + }; + + # programs.vscode = { + # enable = true; + # # i prefer to let vscode manage stuff + # mutableExtensionsDir = true; + # }; + + programs.neovim = { + enable = true; + coc.enable = true; + defaultEditor = true; + plugins = with pkgs.vimPlugins; [ + vim-airline + vim-airline-themes + ale + + vim-fugitive + + vim-bufkill + + suda-vim + + # navigation + nerdtree + nerdtree-git-plugin + plenary-nvim + telescope-nvim + + vim-rooter + # Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } + # Plug 'junegunn/fzf.vim' + # Plug 'jlanzarotta/bufexplorer' + + vim-commentary + #Plug 'mrtazz/DoxygenToolkit.vim' + vim-surround + vim-sexp + + vim-operator-user + #Plug 'rhysd/vim-clang-format' + + #vim-scripts/a.vim + vim-highlightedyank + + # Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' } + ncm2 + nvim-yarp + + # Completion plugins + #Plug 'ncm2/ncm2-bufword' + ncm2-path + + # CoC + # Plug 'neoclide/coc.nvim', {'branch': 'release'} + + haskell-vim + + # Syntactic language support + rust-vim + vim-toml + elixir-tools-nvim + #vim-rubocop + zig-vim + gruvbox ]; - - programs.fish = { - enable = true; - - shellInit = '' - #### BEGIN ALIASES #### - alias v='nvim' - - alias vcf="v ~/.config/nvim/init.vim" - - alias vw='nvim ~/vimwiki/index.wiki; commit-vimwiki' - - function commit-vimwiki --description "go to and from the vimwiki directory, commit with message (to encourage uh, good stuff, and go back" - cd ~/vimwiki - git add * - git commit - prevd - end - - alias vt='nvim ~/vimwiki/Tasks.wiki' - - alias vwo="firefox ~/vimwiki_html/index.html" - alias vwr="nvim -c "VimwikiAll2HTML" -c "q" ~/vimwiki/index.wiki" - alias nv='neovide' - # alias hx='helix' - alias lv="~/.local/bin/lvim" - alias e='emacs' - alias ce='code .' - alias se="serve ." - alias co='code --reuse-window' - alias ok='okular' - alias ko='kitty .' - alias du="du -h --total" - - #exa - alias ls="exa" - alias tree="exa --tree -I target" - - # some more ls aliases - # alias ls='ls --color=always' - alias ll='ls -alF' - alias la='ls -a' - alias l='ls -CF' - - #some cargo aliases :) - alias c='cargo' - alias cn='cargo new' - alias cnl='cargo new --lib' - alias ci='cargo init' - alias cr='cargo run' - alias cb='cargo build' - alias ct='cargo test' - alias cv='cargo clippy' - alias cf='cargo flamegraph' - alias cff='cargo flamegraph;firefox flamegraph.svg' - alias cvp='cargo clippy -- -W clippy::pedantic' - alias cw="cargo watch -c --poll -x 'clippy -- -W clippy::pedantic'" - alias cwr='cargo watch -c -x run' - alias cwt='cargo watch -c -x test' - alias cbr='cargo build --release' - alias crr='cargo run --release' - alias crd="cargo rustdoc" - alias cft="cargo fmt" - alias cdc="cargo doc; firefox target/doc/settings.html" - - #general rust aliases - alias rft='rustfmt' - - #git aliases - alias g="git" - alias gcs="batcat -p -l bash /home/mehbark/main/misc/gitCliCheatSheet.js" - alias gco="git checkout" - alias gb="git branch" - alias gc="git commit -m" - alias gst="git status" - alias ga="git add" - alias gp="git push" - alias gl='git log --oneline --graph --decorate --all' - alias gi='git init' - - #more complex aliases - alias ri="git init; cargo init" - alias rn="new_cargo_quick" - alias ka="killall -r '.*'" - - function new_cargo_quick --description "make a cargo project with git version control, cd to it and open vscode" - mkdir "$argv[1]" - cd "$argv[1]" - git init - cargo init - code . - end - - function speed-up --description "take arg 1, speed it up by arg 3 and output it to arg 2" - echo "$argv[1]" - mencoder -o "$argv[2]" -speed "$argv[3]" -ovc lavc -oac lavc "$argv[1]" - end - - alias doom='~/.config/emacs/bin/doom' - alias pipers='pipes-rs' - alias yt='yt-dlp' - alias compile_and_serve="cargo run --quiet --release example_in example_out;cd example_out;serve;cd .." - alias icat="kitty +kitten icat" - - alias do="dolphin . &> /dev/null &" - - #homestuck - alias hnav "source /home/mbk/hs/bin/hsnav" - alias hstree "tree ~/hs" - alias codestuck "code ~/hs" - - function m - mkdir $argv[1] - cd $argv[1] - end - - function playflac - flac -c -d $argv | aplay - end - - function filelink - echo "file://$(realpath $argv)" - end - alias xpy '~/Aims/rust/x.py' - alias sbcl "rlwrap sbcl" - alias guile "rlwrap guile" - #alias clj 'clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.4\"} $args}}" -m rebel-readline.main' - alias csi "rlwrap chicken-csi" - - # zig - alias zb "zig build" - alias zbr "zig build run" - alias zbt "zig build test" - - # nix - alias nrb "sudo nixos-rebuild" - #### END ALIASES #### - export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$HOME/.local/bin:$HOME/.emacs.d/bin:$PATH:$HOME/.ghcup/bin:$HOME/.cabal/bin:$HOME/hs/bin:$HOME/.cargo/bin:$HOME/.deno/bin:$HOME/Aims/curlfire" - - # [ -f ~/.fzf.bash ] && source ~/.fzf.bash - # setopt autocd - fish_vi_key_bindings - fish_vi_cursor - starship init fish | source - export RUSTC_FORCE_INCREMENTAL=1 - export EDITOR="nvim" - export TROLLNAMES_PATH="/home/mbk/hs/content/mine/trollname/6-letter-english-words.txt" - - set fish_greeting - - if status is-interactive - if set -q ASCIINEMA_REC - return - end - if test $PWD = "/home/mbk/hs" - homestartup - else - fortune | cowsay - end - end - - export CHEZSCHEMELIBDIRS="/home/mbk/Aims/chez/thunderchez:/home/mbk/Aims/chez/thunderchez:/home/mbk/Aims/chez/chez-srfi:/home/mbk/Aims/chez/pfds" - - # opam configuration - source /home/mbk/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true - ''; - }; - - # programs.vscode = { - # enable = true; - # # i prefer to let vscode manage stuff - # mutableExtensionsDir = true; - # }; - - programs.neovim = { - enable = true; - coc.enable = true; - defaultEditor = true; - plugins = with pkgs.vimPlugins; [ - vim-airline - vim-airline-themes - ale - - vim-fugitive - - vim-bufkill - - suda-vim - - # navigation - nerdtree - nerdtree-git-plugin - plenary-nvim - telescope-nvim - - vim-rooter - # Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } - # Plug 'junegunn/fzf.vim' - # Plug 'jlanzarotta/bufexplorer' - - vim-commentary - #Plug 'mrtazz/DoxygenToolkit.vim' - vim-surround - vim-sexp - - vim-operator-user - #Plug 'rhysd/vim-clang-format' - - #vim-scripts/a.vim - vim-highlightedyank - - # Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' } - ncm2 - nvim-yarp - - # Completion plugins - #Plug 'ncm2/ncm2-bufword' - ncm2-path - - # CoC - # Plug 'neoclide/coc.nvim', {'branch': 'release'} - - haskell-vim - - # Syntactic language support - rust-vim - vim-toml - elixir-tools-nvim - #vim-rubocop - zig-vim - gruvbox - ]; - extraConfig = '' - let mapleader = ";" - let maplocalleader = ";;" - - let g:ConqueGdb_GdbExe = 'arm-none-eabi-gdb' - - " call plug#begin('~/.config/nvim/plugged') - " " Using master branch - " call plug#end() - - - "===== Code Completion =====" - autocmd BufEnter * call ncm2#enable_for_buffer() - set completeopt=noinsert,menuone,noselect - " tab to select - " and don't hijack my enter key - inoremap (pumvisible()?(empty(v:completed_item)?"\":"\"):"\") - inoremap (pumvisible()?(empty(v:completed_item)?"\\":"\"):"\") - - "===== Compilation Error Navigation =====" - nmap (coc-diagnostic-next-error) - nmap (coc-diagnostic-next) - - - "===== Key bindings =====" - map :BufExplorer " Explore buffers - map :bnext " Next buffer! - map :bprev " Prev buffer! - map :Commentary " Toggle comment on this line - - map w :w - map q :q - - " mehbark added this, bracket and braces and stuff completion - " https://coderwall.com/p/h1dv0g/completion-for-parentheses-braces-and-brackets-in-vim - " inoremap { {} - " inoremap {{ { - " inoremap {} {} - " inoremap { {}O - " inoremap [ [] - " inoremap [[ [ - " inoremap [] [] - " inoremap ( () - " inoremap (( ( - " inoremap () () - " inoremap " "" - " inoremap "" "" - - "===== Airline =====" - set ttimeoutlen=50 - set laststatus=2 - let g:airline_powerline_fonts = 1 - let g:airline_theme='base16' - let g:airline#extensions#tabline#enabled = 1 - " let g:airline_left_sep="" - " let g:airline_right_sep="" - " let g:airline#extensions#whitespace#checks = [ 'indent' ] - - " Map f4 to switch header/source for c projects - map :A - - " remove trailing white spaces when saving - autocmd BufWritePre * :%s/\s\+$//e - - " OCaml settings - filetype indent on - filetype plugin on - - au BufRead,BufNewFile *.ml,*.mli compiler ocaml - - " different color schemes depending on the file type - syntax enable - "let g:rehash256 = 1 - colorscheme gruvbox - - - "===== NERDTree =====" - "Auto close if only NERDTree is open - autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif - - "Open nerd tree if no cl argument supplied - " function! StartUp() - " if 0 == argc() - " NERDTree . - " end - " endfunction - " let g:NERDTreeWinPos = 'right' - - " autocmd VimEnter * call StartUp() - - "toggle on Ctrl+n - map :NERDTreeToggle - - " let g:NERDTreeWinSize=60 - - - "===== Rust =====" - autocmd FileType rust nnoremap :RustFmt - let g:rustfmt_autosave = 1 - let g:rustfmt_command = "rustfmt" - au BufNewFile,BufRead *.rs setlocal colorcolumn=100 - let g:ycm_rust_src_path = '~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src' - - - "===== Nvim Behaviour =====" - " Changes regular vim behaviours - " Set so the files auto updates when changed on disk - set autoread - - " No swap files - set backupdir-=. - set backupdir^=~/tmp,/tmp - - " Fold the code - set foldmethod=syntax - " activate the folder - set foldcolumn=1 - " automatically fold larger files, for small ones, it doesn't matter - autocmd! BufReadPost * :if line('$') < 200 | set foldlevel=99 | else | set foldlevel=1 |endif - " Relative line numbers in normal mode, absolute in insert (mainly for reading errors easier) - set number - - autocmd InsertEnter * :set norelativenumber - autocmd InsertLeave * :set relativenumber - - - "===== Persistent Undo =====" - " Keep undo history across sessions, by storing in file. - silent !mkdir ~/.config/nvim/backups > /dev/null 2>&1 - set undodir=~/.config/nvim/backups - set undofile - - - "===== Close current buffer =====" - nnoremap :BW - - - "===== Typo fixes =====" - "Fix common typos when saving and exiting - command WQ wq - command Wq wq - command W w - command Q q - - - "===== Misc =====" - set nocompatible - " Dont update view in scripts, 10000 times speedup - set lazyredraw - " set Colour support so airline works - set t_Co=256 - " set mouse activated - set mouse=a - set clipboard=unnamedplus - " Include stdlib dirs for 'gf' command. Also include all subdir in - " workingfolder - let &path.="src/include,/usr/include/AL,.**" - " Search for tags file, from current directory until home directory - set tags=./tags;$HOME - - - "===== Terminal =====" - " Set exiting term mode to esc esc - tnoremap - - - set incsearch - set ignorecase - set smartcase - set tabstop=4 shiftwidth=4 expandtab - set wrap linebreak nolist " list disables line break - " indicate where the 80 chars wide is - set cc=100 - set textwidth=0 - set wrapmargin=0 - " set spell spelllang=en_us - set number - set relativenumber - set langmenu=en_US - let $LANG = 'en_US' - set cursorline - " retain undo history in buffers - set hidden - " set so the files auto updates when changed on disk - set autoread - " Better default for yanking - :map Y y$ - " Set yank highlight to something reasonable - let g:highlightedyank_highlight_duration = 150 - - - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - "==== Haskell - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - let g:haskell_enable_quantification = 1 " to enable highlighting of `forall` - let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec` - let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc` - let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern` - let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles - let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static` - let g:haskell_backpack = 1 " to enable highlighting of backpack keywords - - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - "==== Coc settings - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - - " Give more space for displaying messages. - set cmdheight=2 - - " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable - " delays and poor user experience. - set updatetime=300 - - " Don't pass messages to |ins-completion-menu|. - set shortmess+=c - - " Always show the signcolumn, otherwise it would shift the text each time - " diagnostics appear/become resolved. - set signcolumn=yes - - "function! s:check_back_space() abort - " let col = col('.') - 1 - " return !col || getline('.')[col - 1] =~# '\s' - "endfunction - " - "" 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() ? "\" : - " \ check_back_space() ? "\" : - " \ coc#refresh() - "inoremap pumvisible() ? "\" : "\" - - inoremap - \ coc#pum#visible() ? coc#pum#next(1) : - \ CheckBackspace() ? "\" : - \ coc#refresh() - inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" - - function! CheckBackspace() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' - endfunction - - " Make to accept selected completion item or notify coc.nvim to format - " u breaks current undo, please make your own choice. - inoremap coc#pum#visible() ? coc#pum#confirm() - \: "\u\\=coc#on_enter()\" - - " Use to trigger completion. - inoremap coc#refresh() - - " Use to confirm completion, `u` means break undo chain at current - " position. Coc only does snippet and additional edit on confirm. - " if has('patch8.1.1068') - " " Use `complete_info` if your (Neo)Vim version supports it. - " inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" - " else - " imap pumvisible() ? "\" : "\u\" - " endif - - " Use `[g` and `]g` to navigate diagnostics - 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 show_documentation() - - let g:sexp_insert_after_wrap = 0 - - function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - 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) - - augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder. - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') - augroup end - - " Applying codeAction to the selected region. - " Example: `aap` for current paragraph - xmap a (coc-codeaction-selected) - nmap a (coc-codeaction-selected) - - " Remap keys for applying codeAction to the current line. - nmap ac (coc-codeaction) - " Apply AutoFix to problem on the current line. - nmap qf (coc-fix-current) - - " Introduce function text object - " NOTE: Requires 'textDocument.documentSymbol' support from the language server. - xmap if (coc-funcobj-i) - xmap af (coc-funcobj-a) - omap if (coc-funcobj-i) - omap af (coc-funcobj-a) - - " Use for selections ranges. - " NOTE: Requires 'textDocument/selectionRange' support from the language server. - " coc-tsserver, coc-python are the examples of servers that support it. - nmap (coc-range-select) - xmap (coc-range-select) - - " Add `:Format` command to format current buffer. - command! -nargs=0 Format :call CocAction('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 CocAction('runCommand', 'editor.action.organizeImport') - - let g:airline#extensions#coc#enabled = 1 - " 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',''')} - - " hopefully this fixes the weird thing with the working directory being a - " parent directory - " it hasn't, yet - set autochdir - - " Mappings using CoCList: - " Show all diagnostics. - " nnoremap a :CocList diagnostics - " Manage extensions. - " nnoremap e :CocList extensions - " Show commands. - " nnoremap c :CocList commands - " Find symbol of current document. - " nnoremap o :CocList outline - " Search workspace symbols. - " nnoremap s :CocList -I symbols - " Do default action for next item. - " nnoremap j :CocNext - " Do default action for previous item. - " nnoremap k :CocPrev - " Resume latest coc list. - " nnoremap p :CocListResume - - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - " / Coc settings - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - ''; - }; + extraConfig = '' + let mapleader = ";" + let maplocalleader = ";;" + + let g:ConqueGdb_GdbExe = 'arm-none-eabi-gdb' + + " call plug#begin('~/.config/nvim/plugged') + " " Using master branch + " call plug#end() + + + "===== Code Completion =====" + autocmd BufEnter * call ncm2#enable_for_buffer() + set completeopt=noinsert,menuone,noselect + " tab to select + " and don't hijack my enter key + inoremap (pumvisible()?(empty(v:completed_item)?"\":"\"):"\") + inoremap (pumvisible()?(empty(v:completed_item)?"\\":"\"):"\") + + "===== Compilation Error Navigation =====" + nmap (coc-diagnostic-next-error) + nmap (coc-diagnostic-next) + + + "===== Key bindings =====" + map :BufExplorer " Explore buffers + map :bnext " Next buffer! + map :bprev " Prev buffer! + map :Commentary " Toggle comment on this line + + map w :w + map q :q + + " mehbark added this, bracket and braces and stuff completion + " https://coderwall.com/p/h1dv0g/completion-for-parentheses-braces-and-brackets-in-vim + " inoremap { {} + " inoremap {{ { + " inoremap {} {} + " inoremap { {}O + " inoremap [ [] + " inoremap [[ [ + " inoremap [] [] + " inoremap ( () + " inoremap (( ( + " inoremap () () + " inoremap " "" + " inoremap "" "" + + "===== Airline =====" + set ttimeoutlen=50 + set laststatus=2 + let g:airline_powerline_fonts = 1 + let g:airline_theme='base16' + let g:airline#extensions#tabline#enabled = 1 + " let g:airline_left_sep="" + " let g:airline_right_sep="" + " let g:airline#extensions#whitespace#checks = [ 'indent' ] + + " Map f4 to switch header/source for c projects + map :A + + " remove trailing white spaces when saving + autocmd BufWritePre * :%s/\s\+$//e + + " OCaml settings + filetype indent on + filetype plugin on + + au BufRead,BufNewFile *.ml,*.mli compiler ocaml + + " different color schemes depending on the file type + syntax enable + "let g:rehash256 = 1 + colorscheme gruvbox + + + "===== NERDTree =====" + "Auto close if only NERDTree is open + autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif + + "Open nerd tree if no cl argument supplied + " function! StartUp() + " if 0 == argc() + " NERDTree . + " end + " endfunction + " let g:NERDTreeWinPos = 'right' + + " autocmd VimEnter * call StartUp() + + "toggle on Ctrl+n + map :NERDTreeToggle + + " let g:NERDTreeWinSize=60 + + + "===== Rust =====" + autocmd FileType rust nnoremap :RustFmt + let g:rustfmt_autosave = 1 + let g:rustfmt_command = "rustfmt" + au BufNewFile,BufRead *.rs setlocal colorcolumn=100 + let g:ycm_rust_src_path = '~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src' + + + "===== Nvim Behaviour =====" + " Changes regular vim behaviours + " Set so the files auto updates when changed on disk + set autoread + + " No swap files + set backupdir-=. + set backupdir^=~/tmp,/tmp + + " Fold the code + set foldmethod=syntax + " activate the folder + set foldcolumn=1 + " automatically fold larger files, for small ones, it doesn't matter + autocmd! BufReadPost * :if line('$') < 200 | set foldlevel=99 | else | set foldlevel=1 |endif + " Relative line numbers in normal mode, absolute in insert (mainly for reading errors easier) + set number + + autocmd InsertEnter * :set norelativenumber + autocmd InsertLeave * :set relativenumber + + + "===== Persistent Undo =====" + " Keep undo history across sessions, by storing in file. + silent !mkdir ~/.config/nvim/backups > /dev/null 2>&1 + set undodir=~/.config/nvim/backups + set undofile + + + "===== Close current buffer =====" + nnoremap :BW + + + "===== Typo fixes =====" + "Fix common typos when saving and exiting + command WQ wq + command Wq wq + command W w + command Q q + + + "===== Misc =====" + set nocompatible + " Dont update view in scripts, 10000 times speedup + set lazyredraw + " set Colour support so airline works + set t_Co=256 + " set mouse activated + set mouse=a + set clipboard=unnamedplus + " Include stdlib dirs for 'gf' command. Also include all subdir in + " workingfolder + let &path.="src/include,/usr/include/AL,.**" + " Search for tags file, from current directory until home directory + set tags=./tags;$HOME + + + "===== Terminal =====" + " Set exiting term mode to esc esc + tnoremap + + + set incsearch + set ignorecase + set smartcase + set tabstop=4 shiftwidth=4 expandtab + set wrap linebreak nolist " list disables line break + " indicate where the 80 chars wide is + set cc=100 + set textwidth=0 + set wrapmargin=0 + " set spell spelllang=en_us + set number + set relativenumber + set langmenu=en_US + let $LANG = 'en_US' + set cursorline + " retain undo history in buffers + set hidden + " set so the files auto updates when changed on disk + set autoread + " Better default for yanking + :map Y y$ + " Set yank highlight to something reasonable + let g:highlightedyank_highlight_duration = 150 + + + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + "==== Haskell + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + let g:haskell_enable_quantification = 1 " to enable highlighting of `forall` + let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec` + let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc` + let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern` + let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles + let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static` + let g:haskell_backpack = 1 " to enable highlighting of backpack keywords + + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + "==== Coc settings + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + + " Give more space for displaying messages. + set cmdheight=2 + + " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable + " delays and poor user experience. + set updatetime=300 + + " Don't pass messages to |ins-completion-menu|. + set shortmess+=c + + " Always show the signcolumn, otherwise it would shift the text each time + " diagnostics appear/become resolved. + set signcolumn=yes + + "function! s:check_back_space() abort + " let col = col('.') - 1 + " return !col || getline('.')[col - 1] =~# '\s' + "endfunction + " + "" 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() ? "\" : + " \ check_back_space() ? "\" : + " \ coc#refresh() + "inoremap pumvisible() ? "\" : "\" + + inoremap + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\" : + \ coc#refresh() + inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" + + function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' + endfunction + + " Make to accept selected completion item or notify coc.nvim to format + " u breaks current undo, please make your own choice. + inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + + " Use to trigger completion. + inoremap coc#refresh() + + " Use to confirm completion, `u` means break undo chain at current + " position. Coc only does snippet and additional edit on confirm. + " if has('patch8.1.1068') + " " Use `complete_info` if your (Neo)Vim version supports it. + " inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" + " else + " imap pumvisible() ? "\" : "\u\" + " endif + + " Use `[g` and `]g` to navigate diagnostics + 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 show_documentation() + + let g:sexp_insert_after_wrap = 0 + + function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + 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) + + augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s). + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder. + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') + augroup end + + " Applying codeAction to the selected region. + " Example: `aap` for current paragraph + xmap a (coc-codeaction-selected) + nmap a (coc-codeaction-selected) + + " Remap keys for applying codeAction to the current line. + nmap ac (coc-codeaction) + " Apply AutoFix to problem on the current line. + nmap qf (coc-fix-current) + + " Introduce function text object + " NOTE: Requires 'textDocument.documentSymbol' support from the language server. + xmap if (coc-funcobj-i) + xmap af (coc-funcobj-a) + omap if (coc-funcobj-i) + omap af (coc-funcobj-a) + + " Use for selections ranges. + " NOTE: Requires 'textDocument/selectionRange' support from the language server. + " coc-tsserver, coc-python are the examples of servers that support it. + nmap (coc-range-select) + xmap (coc-range-select) + + " Add `:Format` command to format current buffer. + command! -nargs=0 Format :call CocAction('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 CocAction('runCommand', 'editor.action.organizeImport') + + let g:airline#extensions#coc#enabled = 1 + " 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',''')} + + " hopefully this fixes the weird thing with the working directory being a + " parent directory + " it hasn't, yet + set autochdir + + " Mappings using CoCList: + " Show all diagnostics. + " nnoremap a :CocList diagnostics + " Manage extensions. + " nnoremap e :CocList extensions + " Show commands. + " nnoremap c :CocList commands + " Find symbol of current document. + " nnoremap o :CocList outline + " Search workspace symbols. + " nnoremap s :CocList -I symbols + " Do default action for next item. + " nnoremap j :CocNext + " Do default action for previous item. + " nnoremap k :CocPrev + " Resume latest coc list. + " nnoremap p :CocListResume + + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + " / Coc settings + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + ''; }; }