2022-09-23 19:28:12 +05:30
|
|
|
" ==============================================================================
|
|
|
|
" Plugins
|
|
|
|
" ==============================================================================
|
|
|
|
call plug#begin('~/.vim/plugged')
|
|
|
|
|
|
|
|
" base16 theme
|
|
|
|
Plug 'chriskempson/base16-vim'
|
|
|
|
|
2023-01-22 09:58:06 +05:30
|
|
|
" treesitter
|
|
|
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" auto-complete
|
|
|
|
Plug 'neovim/nvim-lspconfig'
|
|
|
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
|
|
|
Plug 'hrsh7th/cmp-buffer'
|
|
|
|
Plug 'hrsh7th/cmp-path'
|
|
|
|
Plug 'hrsh7th/cmp-cmdline'
|
|
|
|
Plug 'hrsh7th/nvim-cmp'
|
|
|
|
" for vsnip
|
|
|
|
Plug 'hrsh7th/cmp-vsnip'
|
|
|
|
Plug 'hrsh7th/vim-vsnip'
|
|
|
|
|
|
|
|
" fuzzy finder
|
2023-01-22 09:53:26 +05:30
|
|
|
Plug 'nvim-lua/plenary.nvim'
|
|
|
|
Plug 'nvim-telescope/telescope.nvim'
|
2022-09-23 19:28:12 +05:30
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" optional
|
2023-01-22 09:53:26 +05:30
|
|
|
Plug 'airblade/vim-rooter'
|
2022-09-24 19:33:51 +05:30
|
|
|
Plug 'nvim-lua/popup.nvim'
|
|
|
|
Plug 'nvim-lua/plenary.nvim'
|
|
|
|
Plug 'nvim-telescope/telescope.nvim'
|
|
|
|
|
2022-09-23 19:28:12 +05:30
|
|
|
" vim ripgrep
|
|
|
|
Plug 'jremmen/vim-ripgrep'
|
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" official rust plugin
|
2022-09-23 19:28:12 +05:30
|
|
|
Plug 'rust-lang/rust.vim'
|
2022-09-24 19:33:51 +05:30
|
|
|
" to enable more of the features of rust-analyzer, such as inlay hints and more!
|
|
|
|
Plug 'simrat39/rust-tools.nvim'
|
2022-09-23 19:28:12 +05:30
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" git wrapper
|
|
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
|
|
|
|
" src tree view
|
2023-02-07 21:14:00 +05:30
|
|
|
Plug 'nvim-tree/nvim-tree.lua'
|
|
|
|
Plug 'nvim-tree/nvim-web-devicons' " optional, for file icons
|
2022-09-23 19:28:12 +05:30
|
|
|
|
|
|
|
call plug#end()
|
2023-02-07 21:14:00 +05:30
|
|
|
" lua require("setup"
|
|
|
|
luafile ~/.config/nvim/lua/setup.lua
|
2022-09-23 19:28:12 +05:30
|
|
|
|
|
|
|
|
|
|
|
" ==============================================================================
|
|
|
|
" Neovim core(?)
|
|
|
|
" ==============================================================================
|
|
|
|
" dealing with files
|
|
|
|
syntax on
|
|
|
|
filetype plugin indent on
|
2023-02-07 21:14:00 +05:30
|
|
|
set paste
|
2022-09-24 19:33:51 +05:30
|
|
|
set colorcolumn=80
|
2022-09-23 19:28:12 +05:30
|
|
|
set autoindent expandtab tabstop=4 shiftwidth=4
|
|
|
|
set encoding=utf-8
|
|
|
|
|
|
|
|
" appearance
|
|
|
|
set number relativenumber
|
|
|
|
set noshowmode
|
|
|
|
set showcmd
|
|
|
|
set timeoutlen=300 " (http://stackoverflow.com/questions/2158516/delay-before-o-opens-a-new-line)
|
|
|
|
set spell
|
|
|
|
set termguicolors
|
|
|
|
set cursorline
|
|
|
|
let base16colorspace=256
|
|
|
|
colorscheme base16-google-dark
|
2022-09-24 19:33:51 +05:30
|
|
|
"colorscheme base16-gruvbox-dark-hard
|
2022-09-23 19:28:12 +05:30
|
|
|
"set cursorcolumn
|
|
|
|
|
|
|
|
"set clipboard=unnamed,unnamedplus
|
|
|
|
set title
|
|
|
|
set noswapfile
|
|
|
|
"set lazyredraw
|
|
|
|
"set ttyfast (https://neovim.io/doc/user/vim_diff.html#'ttyfast')
|
|
|
|
|
|
|
|
" undo
|
|
|
|
set undolevels=200
|
|
|
|
set undodir=~/.vimdid
|
|
|
|
set undofile
|
|
|
|
|
|
|
|
" search
|
|
|
|
set incsearch ignorecase smartcase hlsearch
|
|
|
|
" do not substitute _globally_
|
|
|
|
set nogdefault
|
|
|
|
|
|
|
|
set visualbell
|
|
|
|
set wildmenu
|
|
|
|
set showmatch
|
|
|
|
|
|
|
|
set pastetoggle=<F2>
|
2022-12-12 18:52:13 +05:30
|
|
|
"prevent trackpad mis{click,touche}s
|
2022-12-12 18:54:37 +05:30
|
|
|
set mouse=
|
2022-09-23 19:28:12 +05:30
|
|
|
"set viminfo=
|
|
|
|
|
|
|
|
|
|
|
|
" ==============================================================================
|
2022-09-24 19:33:51 +05:30
|
|
|
" Rust
|
2022-09-23 19:28:12 +05:30
|
|
|
" ==============================================================================
|
2022-09-24 19:33:51 +05:30
|
|
|
" Set updatetime for CursorHold
|
|
|
|
" 300ms of no cursor movement to trigger CursorHold
|
|
|
|
set updatetime=300
|
2022-09-23 19:28:12 +05:30
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" have a fixed column for the diagnostics to appear in
|
|
|
|
" this removes the jitter when warnings/errors flow in
|
|
|
|
set signcolumn=yes
|
2022-09-23 19:28:12 +05:30
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" Set completeopt to have a better completion experience
|
|
|
|
" :help completeopt
|
|
|
|
" menuone: popup even when there's only one match
|
|
|
|
" noinsert: Do not insert text until a selection is made
|
|
|
|
" noselect: Do not select, force user to select one from the menu
|
|
|
|
set completeopt=menuone,noinsert,noselect
|
2022-09-23 19:28:12 +05:30
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" Avoid showing extra messages when using completion
|
|
|
|
set shortmess+=c
|
2022-09-23 19:28:12 +05:30
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" Show diagnostic popup on cursor hold
|
|
|
|
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
|
2022-09-23 19:28:12 +05:30
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" format-on-write
|
2022-11-04 03:51:53 +05:30
|
|
|
" `vim.lsp.buf.formatting_sync` is depricated
|
|
|
|
" but it is still present until Debian switches to a compatible version
|
|
|
|
"autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 200)
|
|
|
|
autocmd BufWritePre *.rs lua vim.lsp.buf.format(nil, 200)
|
2022-09-24 19:33:51 +05:30
|
|
|
|
|
|
|
" use 4 spaces for indent rust
|
|
|
|
autocmd FileType rust setlocal expandtab shiftwidth=4 softtabstop=4
|
2022-09-23 19:28:12 +05:30
|
|
|
|
|
|
|
let g:rustfmt_autosave = 1
|
|
|
|
let g:rustfmt_emit_files = 1
|
|
|
|
let g:rustfmt_fail_silently = 0
|
2022-09-24 19:33:51 +05:30
|
|
|
|
2022-09-24 21:07:30 +05:30
|
|
|
luafile ~/.config/nvim/lua/simrat39__rust-tools.nvim.lua
|
2022-09-24 19:33:51 +05:30
|
|
|
luafile ~/.config/nvim/lua/hrsh7th__nvim-cmp.lua
|
|
|
|
|
|
|
|
|
|
|
|
" ==============================================================================
|
|
|
|
" Indentation
|
|
|
|
" ==============================================================================
|
|
|
|
" use 2 spaces for indentation of specific file types
|
|
|
|
autocmd FileType lua setlocal expandtab shiftwidth=2 softtabstop=2
|
|
|
|
autocmd FileType json setlocal expandtab shiftwidth=2 softtabstop=2
|
|
|
|
|
|
|
|
" use 4 spaces for indentation of specific file types
|
|
|
|
autocmd FileType bash setlocal expandtab shiftwidth=4 softtabstop=4
|
|
|
|
autocmd FileType c setlocal expandtab shiftwidth=4 softtabstop=4
|
|
|
|
autocmd FileType gitconfig setlocal expandtab shiftwidth=4 softtabstop=4
|
|
|
|
autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4
|
|
|
|
autocmd FileType sh setlocal expandtab shiftwidth=4 softtabstop=4
|
|
|
|
autocmd FileType vim setlocal expandtab shiftwidth=4 softtabstop=4
|
|
|
|
autocmd FileType yaml setlocal expandtab shiftwidth=4 softtabstop=4
|
2022-09-23 19:28:12 +05:30
|
|
|
|
|
|
|
|
|
|
|
" ==============================================================================
|
|
|
|
" Statusline
|
|
|
|
" ==============================================================================
|
|
|
|
" Define all the different modes
|
|
|
|
let g:currentmode={
|
|
|
|
\ 'n' : 'NORMAL',
|
|
|
|
\ 'no' : 'NORMAL·OPERATOR PENDING',
|
|
|
|
\ 'v' : 'VISUAL',
|
|
|
|
\ 'V' : 'V·LINE',
|
|
|
|
\ '^V' : 'V·BLOCK',
|
|
|
|
\ 's' : 'SELECT',
|
|
|
|
\ 'S' : 'S·LINE',
|
|
|
|
\ '^S' : 'S·BLOCK',
|
|
|
|
\ 'i' : 'INSERT',
|
|
|
|
\ 'R' : 'REPLACE',
|
|
|
|
\ 'Rv' : 'V·REPLACE',
|
|
|
|
\ 'c' : 'COMMAND',
|
|
|
|
\ 'cv' : 'VIM EX',
|
|
|
|
\ 'ce' : 'EX',
|
|
|
|
\ 'r' : 'PROMPT',
|
|
|
|
\ 'rm' : 'MORE',
|
|
|
|
\ 'r?' : 'CONFIRM',
|
|
|
|
\ '!' : 'SHELL',
|
|
|
|
\ 't' : 'TERMINAL'
|
|
|
|
\}
|
|
|
|
|
|
|
|
set statusline=
|
|
|
|
" 2 space padding
|
|
|
|
set statusline+=%#ErrorMsg#\ \
|
|
|
|
" shows mode
|
|
|
|
set statusline+=%#Search#\ %{g:currentmode[mode()]}\
|
|
|
|
" shows '[+]' if modified else '[0]'
|
|
|
|
set statusline+=%#ErrorMsg#\ %{&modified?'[+]':'[0]'}\
|
|
|
|
" show if a file is readonly
|
|
|
|
set statusline+=%#Question#%{&readonly?'[RO]':'[RW]'}\
|
|
|
|
" show the file name
|
|
|
|
set statusline+=%#CursorLineNr#\ %f\
|
|
|
|
" show filename
|
|
|
|
set statusline+=%#SignColumn#\(%{wordcount().words}\)\ %#Comment#
|
|
|
|
" show wc
|
|
|
|
set statusline+=%=
|
|
|
|
" show file format dos/UNIX
|
|
|
|
set statusline+=%#Title#%{&ff}\
|
|
|
|
" show encoding format
|
|
|
|
set statusline+=%#Directory#%{&fileencoding}\
|
|
|
|
" show the syntax/file type eg Rust, C, Python, Vim etc
|
|
|
|
set statusline+=%#Todo#\ %Y\
|
|
|
|
" show percentage through a file
|
|
|
|
set statusline+=%#Identifier#\ %p%%
|
|
|
|
" show the currentline/totallines
|
|
|
|
set statusline+=%#Normal#\ %lL\
|
|
|
|
" show column number
|
|
|
|
set statusline+=%#CursorColumn#\ %cC\
|
|
|
|
" 2 space padding
|
|
|
|
set statusline+=%#Normal#\ \
|
|
|
|
set laststatus=2
|
|
|
|
|
|
|
|
|
|
|
|
" ==============================================================================
|
|
|
|
" key bindings
|
|
|
|
" ==============================================================================
|
|
|
|
" Jump to start and end of line using the home row keys
|
|
|
|
map H ^
|
|
|
|
map L $
|
|
|
|
|
|
|
|
" remap uppercase J and K to their lowercase counterparts;
|
|
|
|
" been bitten too many times
|
|
|
|
nnoremap K k
|
|
|
|
nnoremap J j
|
|
|
|
"inoremap K k
|
|
|
|
"inoremap J j
|
|
|
|
|
|
|
|
"map-command [map-arg] {lhs} {rhs}
|
|
|
|
nnoremap <C-J> <C-W><C-J>
|
|
|
|
nnoremap <C-K> <C-W><C-K>
|
|
|
|
nnoremap <C-L> <C-W><C-L>
|
|
|
|
nnoremap <C-H> <C-W><C-H>
|
|
|
|
|
2023-02-07 21:14:00 +05:30
|
|
|
" neovide (GUI) clipboard
|
|
|
|
nnoremap <C-S-V> "+P
|
|
|
|
" handle Ctrl+Shift+V in GUI somehow
|
|
|
|
" inoremap <C-S-V> "+P
|
2023-02-07 18:41:00 +05:30
|
|
|
|
|
|
|
|
2022-09-24 19:33:51 +05:30
|
|
|
" RUST
|
|
|
|
" Code navigation shortcuts
|
|
|
|
nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
|
|
|
|
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
|
|
|
|
nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR>
|
|
|
|
nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
|
|
|
|
nnoremap <silent> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR>
|
|
|
|
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
|
|
|
|
nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
|
|
|
|
nnoremap <silent> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
|
|
|
|
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
|
|
|
|
" code actions
|
|
|
|
nnoremap <silent> ga <cmd>lua vim.lsp.buf.code_action()<CR>
|
|
|
|
" Goto previous/next diagnostic warning/error
|
|
|
|
nnoremap <silent> g[ <cmd>lua vim.diagnostic.goto_prev()<CR>
|
|
|
|
nnoremap <silent> g] <cmd>lua vim.diagnostic.goto_next()<CR>
|
|
|
|
|
2022-09-23 19:28:12 +05:30
|
|
|
|
|
|
|
" ==============================================================================
|
|
|
|
" change highlight color when yanking
|
|
|
|
" ==============================================================================
|
|
|
|
au TextYankPost * silent! lua vim.highlight.on_yank {higroup="Visual", timeout=250}
|