nvim: Add ftdetect, ftplugin, refactor everything
* expand tab by default * add a lot of comments for future me * improve autocomplete experience a bit * revamp and fix some mappings * better plugins and remove unused ones * ftdetect scd * Add diagnostics count of lightline That's it I guess?
This commit is contained in:
parent
6cc3ef5e3e
commit
a27a8c99f0
|
@ -1,7 +1,11 @@
|
|||
" This file is only executed if we don't have nvim0.5, if we do, lua LSP will
|
||||
" be used instead. See plugins.vim
|
||||
" coc settings
|
||||
" ==== coc installs ====
|
||||
"
|
||||
" ==============
|
||||
" CoC Settings
|
||||
" ==============
|
||||
|
||||
" === coc installs ===
|
||||
" TODO: Track .config/coc in dotfiles so I can remove this
|
||||
" coc-go
|
||||
" coc-html
|
||||
|
@ -12,6 +16,8 @@
|
|||
" coc-yank
|
||||
nnoremap <silent> <space>y :<C-u>CocList -A --normal yank<cr>
|
||||
|
||||
" Below is mostly or completely copied from coc's readme
|
||||
|
||||
" Use tab for trigger completion with characters ahead and navigate.
|
||||
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
||||
" other plugin before putting this into your config.
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
autocmd BufNewFile,BufRead *.scd sed filetype=scdoc
|
|
@ -2,7 +2,7 @@
|
|||
compiler fish
|
||||
|
||||
" set indent size
|
||||
set shiftwidth=4
|
||||
setlocal shiftwidth=4
|
||||
|
||||
" Set this to have long lines wrap inside comments.
|
||||
setlocal textwidth=79
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
setlocal noexpandtab
|
|
@ -0,0 +1,3 @@
|
|||
setl tabstop=4
|
||||
setl shiftwidth=4
|
||||
setl softtabstop=4
|
|
@ -0,0 +1,2 @@
|
|||
setlocal shiftwidth=2
|
||||
setlocal tabstop=2
|
|
@ -1,30 +1,32 @@
|
|||
""""""""""""""""""
|
||||
" ================
|
||||
" General settings
|
||||
" """"""""""""""
|
||||
" ================
|
||||
|
||||
set number
|
||||
set mouse=a " allow mouse for all
|
||||
set hlsearch " highlight search
|
||||
set showcmd " show incomplete commands
|
||||
set wildmenu " command line's tab complete in a menu
|
||||
set cursorline " highlight cursor line
|
||||
set noerrorbells " no beeps
|
||||
set visualbell " flash screen instead
|
||||
set title " set window title to file name
|
||||
set autoindent
|
||||
set softtabstop=2 " indent by 2 spaces when with tab
|
||||
set tabstop=4 " show existing tab with 4 spaces width
|
||||
set shiftwidth=4
|
||||
set incsearch " find next match while typing search
|
||||
set scrolloff=6 " screen lines to keep above and below cursor
|
||||
set mouse=a " allow mouse for all; TODO: I rarely use mouse (duh) so maybe remove this
|
||||
set hlsearch " highlight search
|
||||
set showcmd " show incomplete commands
|
||||
set wildmenu " command line's tab complete in a menu
|
||||
set cursorline " highlight current cursor line (this is SO GOOD)
|
||||
set noerrorbells " no beeps please
|
||||
set visualbell " flash screen instead
|
||||
set title " set window title to file name
|
||||
set autoindent " Keep indentation from previous line when RET (I think)
|
||||
set expandtab " AIUI, tab -> spaces
|
||||
set softtabstop=2 " indent by 2 spaces with tab
|
||||
set tabstop=4 " show existing tabs with 4 spaces width
|
||||
set shiftwidth=4 " Put or remove 4 spaces with using < and >
|
||||
set incsearch " incrementally find next match while typing search
|
||||
set scrolloff=6 " screen lines to keep above and below cursor
|
||||
set sidescrolloff=8 " screen columns to keep on left and right of cursor
|
||||
set confirm " display confirmation when closing unsaved file
|
||||
set confirm " display confirmation when closing unsaved file
|
||||
set encoding=utf-8 " set encoding with Unicode
|
||||
set showmatch " match brackets when text indecator is over it
|
||||
set mat=2 " how mny tenths of second to blink when matching brackets
|
||||
set showmatch " match brackets when cursor is over it
|
||||
set mat=2 " how many tenths of second to blink when matching brackets
|
||||
set inccommand=nosplit " neovim only
|
||||
|
||||
" settings required from coc
|
||||
" Settings required from coc
|
||||
" Still keeping this if we're using lua+lsp instead of CoC because why not
|
||||
set hidden
|
||||
set cmdheight=2
|
||||
set updatetime=300
|
||||
|
@ -38,29 +40,28 @@ else
|
|||
set signcolumn=yes
|
||||
endif
|
||||
|
||||
" Bunch of shit really, spent *hours* trying to get tmux + nvim true colors to work
|
||||
" TODO: check has('termguicolors') and set a env var or something
|
||||
set termguicolors
|
||||
|
||||
|
||||
set laststatus=2 " show status line
|
||||
"set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L\ \|\ col\ %c)
|
||||
|
||||
set whichwrap+=<,>,h,l
|
||||
|
||||
"" fold settings
|
||||
" fold settings
|
||||
set foldenable
|
||||
set foldlevelstart=10
|
||||
set foldnestmax=10
|
||||
set foldmethod=manual
|
||||
set foldcolumn=2
|
||||
|
||||
|
||||
" set the swp, backup and undo settings
|
||||
" Set the swp, backup and undo settings
|
||||
set noswapfile
|
||||
set nobackup nowritebackup
|
||||
set undodir=~/.local/share/nvim/undodir/
|
||||
set undofile
|
||||
"
|
||||
"" Ignore compiled files
|
||||
|
||||
" Ignore compiled files
|
||||
set wildignore=*.o,*~,*.pyc
|
||||
if has("win16") || has("win32")
|
||||
set wildignore+=.git\*,.hg\*,.svn\*
|
||||
|
@ -68,20 +69,20 @@ else
|
|||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
|
||||
endif
|
||||
|
||||
" Return to last edit position when opening files (You want
|
||||
" this!)
|
||||
" Return to last edit position when opening files
|
||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
"au ColorScheme * hi Normal ctermbg=None
|
||||
|
||||
"" highlight extra whitespace
|
||||
" highlight trailing whitespace
|
||||
match ErrorMsg '\s\+$'
|
||||
|
||||
" setting the shell for fish to sh
|
||||
" setting the shell for fish to bash
|
||||
"if &shell =~# 'fish$'
|
||||
" set shell=bash
|
||||
"endif
|
||||
"
|
||||
" commented because without it things still seems to work
|
||||
|
||||
" IsWSL function sourced in functions.vim, declared in ~/iswsl.vim
|
||||
" I think this is a neovim-only thing, +1 for neovim :smirk:
|
||||
if IsWSL()
|
||||
let g:clipboard = {
|
||||
\ 'name': 'WSLClip',
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
-- modified from https://github.com/hrsh7th/nvim-compe
|
||||
|
||||
local compe = require('compe')
|
||||
|
||||
vim.o.completeopt = "menuone,noselect"
|
||||
|
||||
require'compe'.setup {
|
||||
compe.setup {
|
||||
enabled = true;
|
||||
autocomplete = true;
|
||||
debug = false;
|
||||
|
@ -69,7 +71,9 @@ _G.s_tab_complete = function()
|
|||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("i", "<cr", "compe#confirm('<cr>')", {expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<C-e>", "compe#close('<C-e>')", {expr = true})
|
||||
|
|
|
@ -58,3 +58,4 @@ for _, lsp in ipairs(servers) do
|
|||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,73 +1,95 @@
|
|||
"""""""""""
|
||||
" ========
|
||||
" Mappings
|
||||
""""""""""
|
||||
" leader mappings
|
||||
" ========
|
||||
|
||||
" === Leader Mappings ===
|
||||
" Leader is mapped to ';' in init.vim
|
||||
" Toggle relative number
|
||||
nnoremap <Leader>rn :set relativenumber!<CR>
|
||||
" Open all folds in current buffer (Reduce)
|
||||
nnoremap <Leader>z zR
|
||||
" The 3 mappings that I use most often out of all vim mappings :D
|
||||
nnoremap <Leader>w :w<CR>
|
||||
nnoremap <Leader>x :xa<CR>
|
||||
nnoremap <Leader>q :qa<CR>
|
||||
|
||||
" no highlight - when finished search
|
||||
" Clear search
|
||||
nnoremap <Leader>nh :noh<CR>
|
||||
" paste shortcut below
|
||||
" must be recursive bcus "+p is aldy mapped above (in WSLYank - paste)
|
||||
nmap <Leader>pa "+p
|
||||
" Paste (rarely used because I commonly work in ssh'ed environments)
|
||||
nnoremap <Leader>pa "+p
|
||||
" Show what registers contain
|
||||
nnoremap <Leader>rg :registers<CR>
|
||||
|
||||
" other mappings
|
||||
" dot command in visual mode
|
||||
vnoremap . :normal.<CR>
|
||||
|
||||
" === Normal and Universal Mappings ===
|
||||
" Close a buffer, useful when doing PlugInstall and then closing that
|
||||
" Or is it close a window? frame? DAMN all this emacs terminology got me so
|
||||
" confused
|
||||
nnoremap Q :q<CR>
|
||||
" move visual selection
|
||||
vnoremap J :m '>+1<CR>gv=gv
|
||||
vnoremap K :m '<-2<CR>gv=gv
|
||||
|
||||
" NOTE: These mappings Just Work in wsl so no need the extra binding like
|
||||
" in vimrc, this is why you use neovim instead of vim ;)
|
||||
noremap <M-j> :m+1<CR>==
|
||||
noremap <M-k> :m-2<CR>==
|
||||
|
||||
noremap <M-J> :t.<CR>==
|
||||
noremap <M-K> :t.-1<CR>==
|
||||
|
||||
|
||||
" === Visual Mappings ===
|
||||
" dot command in visual mode
|
||||
vnoremap . :normal.<CR>
|
||||
|
||||
" Move visual selection
|
||||
vnoremap J :m '>+1<CR>gv=gv
|
||||
vnoremap K :m '<-2<CR>gv=gv
|
||||
|
||||
" Visual mode pressing * or # searches for the current selection
|
||||
" Super useful! From an idea by Michael Naumann
|
||||
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
|
||||
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>"
|
||||
|
||||
" Smart way to move between windows
|
||||
" Keep text selected after indentation
|
||||
" This is... really useful sometimes but annoying other times
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
||||
|
||||
" === Window/Buffer/Tab mappings ===
|
||||
" Better way to move between windows
|
||||
noremap <C-j> <C-W>j
|
||||
noremap <C-k> <C-W>k
|
||||
noremap <C-h> <C-W>h
|
||||
noremap <C-l> <C-W>l
|
||||
|
||||
" managing buffers
|
||||
" Managing buffers
|
||||
nnoremap <leader>bd :bd<cr>
|
||||
nnoremap <leader>bn :bn<cr>
|
||||
nnoremap <leader>bp :b<cr>
|
||||
nnoremap <leader>bn :bnext<cr>
|
||||
nnoremap <leader>bp :bprev<cr>
|
||||
|
||||
" Useful mappings for managing tabs
|
||||
noremap <leader>tn :tabnew<cr>
|
||||
noremap <leader>to :tabonly<cr>
|
||||
noremap <leader>tc :tabclose<cr>
|
||||
noremap <leader>tm :tabmove
|
||||
noremap <leader>t<leader> :tabnext
|
||||
noremap <leader>bn :bnext<cr>
|
||||
noremap <leader>bp :bprev<cr>
|
||||
" Tab create
|
||||
nnoremap <leader>tc :tabnew<cr>
|
||||
nnoremap <leader>to :tabonly<cr>
|
||||
" Tab delete
|
||||
nnoremap <leader>td :tabclose<cr>
|
||||
" I rarely have >3 tabs, let alone organize their placements :D but it's here
|
||||
" because why not
|
||||
nnoremap <leader>tm :tabmove<cr>
|
||||
" Switching tabs
|
||||
nnoremap <leader>tn :tabnext<cr>
|
||||
nnoremap <leader>tp :tabprev<cr>
|
||||
|
||||
" terminal mappings
|
||||
|
||||
" === Misc Mappings ===
|
||||
" Hooray for neovim :)))))
|
||||
" Terminal mappings
|
||||
noremap <C-`> :split term://fish<cr>i
|
||||
noremap <leader>t :split term://fish<cr>i
|
||||
nnoremap <leader>t :split term://fish<cr>i
|
||||
tnoremap <Esc> <C-\><C-n>
|
||||
|
||||
" command mode mappings
|
||||
" Command mode mappings
|
||||
cnoremap <C-p> PlugInstall<cr>
|
||||
cnoremap <C-f> Format<cr>
|
||||
|
||||
" my commands
|
||||
" Quickly apply (n)vimrc changes
|
||||
command! ReloadConfig so $HOME/.config/nvim/init.vim
|
||||
nnoremap <Leader>rc :ReloadConfig<cr>
|
||||
|
||||
" keep text selected after indentation
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
|
|
@ -1,27 +1,32 @@
|
|||
" ==========================
|
||||
" Plugins and their settings
|
||||
" ==========================
|
||||
"
|
||||
" === Plugin declarations ===
|
||||
call plug#begin(stdpath('data') . '/plugged')
|
||||
|
||||
Plug 'dracula/vim', {'name': 'dracula'} " dracula color theme
|
||||
Plug 'dracula/vim', {'name': 'dracula'} " dracula color theme (THE most important plugin, yes)
|
||||
Plug 'preservim/nerdtree'
|
||||
Plug 'Xuyuanp/nerdtree-git-plugin'
|
||||
Plug 'Yggdroot/indentLine' " indentLine plugin
|
||||
Plug 'stautob/vim-fish' " fish support for vim
|
||||
Plug 'tpope/vim-fugitive' " git stuff
|
||||
Plug 'tpope/vim-surround' " quoting and parenthesizing plugin
|
||||
Plug 'jiangmiao/auto-pairs' " quote pairs and other neat stuff
|
||||
Plug 'Xuyuanp/nerdtree-git-plugin' " Show git statuses in NERDTree
|
||||
Plug 'Yggdroot/indentLine'
|
||||
Plug 'stautob/vim-fish' " fish support for vim
|
||||
Plug 'tpope/vim-fugitive' " git stuff
|
||||
Plug 'tpope/vim-surround' " quoting and parenthesizing plugin
|
||||
Plug 'jiangmiao/auto-pairs' " quote pairs and other neat stuff; TODO: switch to nvim-autopairs
|
||||
Plug 'https://github.com/tpope/vim-commentary'
|
||||
" Plug 'vim-airline/vim-airline' " airline plugin for status bar
|
||||
Plug 'itchyny/lightline.vim' " airline was throwing shitty errors so yeah.
|
||||
Plug 'mbbill/undotree' " undo tree
|
||||
Plug 'bling/vim-bufferline' " buffer line
|
||||
Plug 'tpope/vim-fugitive'
|
||||
Plug 'ctrlpvim/ctrlp.vim'
|
||||
Plug 'airblade/vim-gitgutter'
|
||||
Plug 'majutsushi/tagbar'
|
||||
if has('python')
|
||||
Plug 'laurentgoudet/vim-howdoi'
|
||||
endif
|
||||
Plug 'wakatime/vim-wakatime' " wakatime for vim
|
||||
Plug 'SuneelFreimuth/vim-gemtext'
|
||||
Plug 'itchyny/lightline.vim' " airline was throwing shitty errors so yeah.
|
||||
" Pretty and customizable status bar,
|
||||
" for components see below
|
||||
" Commented out because I realized I never used it (lol)
|
||||
" Plug 'mbbill/undotree' " undo tree
|
||||
Plug 'bling/vim-bufferline' " buffer line (one of my most used plugins!)
|
||||
Plug 'ctrlpvim/ctrlp.vim' " Quickly find a fine with fuzzy find; TODO: use fzf instead
|
||||
Plug 'airblade/vim-gitgutter' " Show git diff overview stuff in the left column
|
||||
Plug 'majutsushi/tagbar' " Quickly jump to a symbol in buffer (one of my most used omg!)
|
||||
Plug 'wakatime/vim-wakatime' " Tracks my coding stats (because I like to look at the stats for fun)
|
||||
Plug 'https://sr.ht/~torresjrjr/gemini.vim' " gemtext syntax highlighting; I know there are more
|
||||
" popular alternatives but this is the
|
||||
" best IMO
|
||||
|
||||
" Picking the right LSP completion method, see bottom of file for more
|
||||
if has("nvim-0.5")
|
||||
|
@ -31,11 +36,12 @@ else
|
|||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
endif
|
||||
call plug#end()
|
||||
" Plugin declarations ends here
|
||||
" =============================
|
||||
|
||||
"let g:dracula_colorterm = 0
|
||||
colorscheme dracula
|
||||
colorscheme dracula " Probably THE most important nvim configuration ;-;
|
||||
|
||||
" lightline
|
||||
" === Lightline Settings ===
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'dracula',
|
||||
\ 'mode_map': {
|
||||
|
@ -52,21 +58,27 @@ let g:lightline = {
|
|||
\ 't': 'T',
|
||||
\ },
|
||||
\ 'component': {
|
||||
\ 'tagbar': '%{tagbar#currenttag("[%s]", "")}',
|
||||
\ 'tagbar': '%{tagbar#currenttag("[%s]", "")}',
|
||||
\ },
|
||||
\ 'component_function': {
|
||||
\ 'fugitive': 'LightlineFugitive',
|
||||
\ 'ctrlpmark': 'CtrlPMark',
|
||||
\ 'diagnosticscount': 'LightlineDiagnostics',
|
||||
\ },
|
||||
\ 'component_type': {
|
||||
\ 'diagnosticscount': 'error',
|
||||
\ },
|
||||
\ 'active': {
|
||||
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['ctrlpmark', 'tagbar'] ],
|
||||
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['tagbar'] ],
|
||||
\ 'right': [ [ 'diagnosticscount' ], ['percent'], ['fileformat', 'fileencoding', 'filetype'] ]
|
||||
\ },
|
||||
\ }
|
||||
|
||||
function! LightlineFugitive()
|
||||
" Referenced from Lightline docs; I'm not 100% what this does but seems like
|
||||
" it just grabs the current git branch
|
||||
try
|
||||
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*FugitiveHead')
|
||||
let mark = '' " edit here for cool mark
|
||||
let mark = '' " I'm not sure what this mark does either
|
||||
let branch = FugitiveHead()
|
||||
return branch !=# '' ? mark.branch : ''
|
||||
endif
|
||||
|
@ -75,12 +87,30 @@ function! LightlineFugitive()
|
|||
return ''
|
||||
endfunction
|
||||
|
||||
function! LightlineDiagnostics()
|
||||
" Grabs the current buffer's diagnostics count and displays it in the
|
||||
" format 'E:x W:x'
|
||||
" If both errors and warnings are 0 then don't display anything
|
||||
try
|
||||
" TODO: if we don't have nvim-0.5 then call some CoC function
|
||||
let errors = luaeval('vim.lsp.diagnostic.get_count(0, [[Error]])')
|
||||
let warnings = luaeval('vim.lsp.diagnostic.get_count(0, [[Warning]])')
|
||||
if errors == 0 && warnings == 0
|
||||
return ''
|
||||
else
|
||||
return "E:" . errors . " W:" . warnings
|
||||
endif
|
||||
catch
|
||||
endtry
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
|
||||
" === Other plugins settings ===
|
||||
|
||||
" open current dir in nerdtree
|
||||
noremap <Leader>nf :NERDTreeFind<CR>
|
||||
" open nerdtree when openning a dir in vim
|
||||
let NERDTreeWinSize = 20
|
||||
" autocmd vimenter * NERDTree % | exe "normal \<c-w>l"
|
||||
" Open current dir in nerdtree
|
||||
noremap <Leader>nf :NERDTreeFind<CR>
|
||||
noremap <Leader>nt :NERDTreeToggle<CR>
|
||||
|
||||
" NerdTree Git plugin
|
||||
|
@ -97,15 +127,21 @@ let g:NERDTreeGitStatusIndicatorMapCustom = {
|
|||
\ "Unknown" : "??"
|
||||
\ }
|
||||
|
||||
|
||||
" tagbar
|
||||
nnoremap <leader>tt :TagbarToggle<CR>
|
||||
let g:tagbar_width = 20
|
||||
|
||||
" LSP
|
||||
" === LSP ===
|
||||
if has("nvim-0.5")
|
||||
lua require('lsp')
|
||||
lua require('autocomplete')
|
||||
|
||||
" Autoclose completion popup when completion is done
|
||||
" TODO: Doesn't seem to work though?
|
||||
" Just press C-e I guess (defined in ./lua/autocomplete.lua)
|
||||
augroup complete_hide_popup
|
||||
autocmd! CompleteDone * if pumvisible() == 1 | pclose | endif
|
||||
augroup END
|
||||
else
|
||||
source $HOME/.config/nvim/coc.vim
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue