Redo vim config (dependant on neovim 0.5)
This commit is contained in:
parent
8fc78835bd
commit
4ce727a7d8
|
@ -1,23 +1,12 @@
|
||||||
" Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
|
let g:mapleader = "\<Space>"
|
||||||
" If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
|
let g:maplocalleader = ','
|
||||||
" (see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
|
|
||||||
if (has("nvim"))
|
|
||||||
" For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
|
|
||||||
" Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
|
|
||||||
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
|
|
||||||
if (has("termguicolors"))
|
|
||||||
set termguicolors
|
set termguicolors
|
||||||
endif
|
syntax on
|
||||||
|
|
||||||
" Shortcuts
|
|
||||||
nnoremap <silent><nowait> <space>o :NERDTreeToggle<CR>
|
|
||||||
nnoremap <silent><nowait> <space>s :TagbarToggle<CR>
|
|
||||||
|
|
||||||
" Remove Highlight
|
set hidden
|
||||||
nnoremap <esc><esc> :let @/=""<cr>
|
|
||||||
|
|
||||||
" Always show the signcolumn
|
" Always show the signcolumn
|
||||||
if has("patch-8.1.1564")
|
if has("patch-8.1.1564")
|
||||||
|
@ -27,149 +16,260 @@ else
|
||||||
set signcolumn=yes
|
set signcolumn=yes
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Required for operations modifying multiple buffers like rename.
|
|
||||||
" Used by coc.nvim
|
|
||||||
set hidden
|
|
||||||
|
|
||||||
" Set more space for displaying messages
|
|
||||||
" Used by coc.nvim
|
|
||||||
set cmdheight=2
|
|
||||||
|
|
||||||
" Highlight the symbol and its references when holding the cursor.
|
|
||||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
|
||||||
|
|
||||||
" C-Space triggers autocompletion
|
|
||||||
inoremap <silent><expr> <c-space> coc#refresh()
|
|
||||||
|
|
||||||
" coc.nvim quick fix
|
|
||||||
nmap <leader>qf <Plug>(coc-fix-current)
|
|
||||||
|
|
||||||
" Use tab for trigger completion with characters ahead and navigate.
|
|
||||||
" Used by coc.nvim
|
|
||||||
inoremap <silent><expr> <TAB>
|
|
||||||
\ pumvisible() ? "\<C-n>" :
|
|
||||||
\ <SID>check_back_space() ? "\<TAB>" :
|
|
||||||
\ coc#refresh()
|
|
||||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
|
||||||
|
|
||||||
function! s:check_back_space() abort
|
|
||||||
let col = col('.') - 1
|
|
||||||
return !col || getline('.')[col - 1] =~# '\s'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
|
|
||||||
" position.
|
|
||||||
" Used by coc.nvim
|
|
||||||
if exists('*complete_info')
|
|
||||||
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
|
|
||||||
else
|
|
||||||
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Use K to show documentation in preview window.
|
|
||||||
" Used by coc.nvim
|
|
||||||
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
|
||||||
function! s:show_documentation()
|
|
||||||
if (index(['vim','help'], &filetype) >= 0)
|
|
||||||
execute 'h '.expand('<cword>')
|
|
||||||
else
|
|
||||||
call CocAction('doHover')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" CoC Status in LightLine
|
|
||||||
" Used by coc.nvim lightline.nvim
|
|
||||||
let g:lightline = {
|
|
||||||
\ 'colorscheme': 'one',
|
|
||||||
\ 'active': {
|
|
||||||
\ 'left': [ [ 'mode', 'paste' ],
|
|
||||||
\ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ]
|
|
||||||
\ },
|
|
||||||
\ 'component_function': {
|
|
||||||
\ 'cocstatus': 'coc#status'
|
|
||||||
\ },
|
|
||||||
\ }
|
|
||||||
|
|
||||||
" Use auocmd to force lightline update.
|
|
||||||
" Used by coc.nvim lightline.nvim
|
|
||||||
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()
|
|
||||||
|
|
||||||
|
|
||||||
" Add `:Format` command to format current buffer.
|
|
||||||
" Used by coc.nvim
|
|
||||||
command! -nargs=0 Format :call CocAction('format')
|
|
||||||
|
|
||||||
" TODO: Pick and Chose the ones I want
|
|
||||||
" Mappings for CoCList
|
|
||||||
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
|
|
||||||
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
|
|
||||||
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
|
|
||||||
|
|
||||||
|
|
||||||
" Plugged Plugins
|
|
||||||
call plug#begin(stdpath('data') . '/plugged')
|
call plug#begin(stdpath('data') . '/plugged')
|
||||||
|
|
||||||
" Blue Theme
|
Plug 'neovim/nvim-lspconfig'
|
||||||
Plug 'wadackel/vim-dogrun'
|
|
||||||
|
|
||||||
" Indent Detection
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||||
Plug 'tpope/vim-sleuth'
|
|
||||||
|
|
||||||
" One Dark Theme
|
Plug 'windwp/nvim-autopairs'
|
||||||
Plug 'rakr/vim-one'
|
|
||||||
|
|
||||||
" Activity Tracking
|
Plug 'terrortylor/nvim-comment'
|
||||||
" Plug 'ActivityWatch/aw-watcher-vim'
|
|
||||||
|
|
||||||
" Monokai Theme
|
Plug 'kyazdani42/nvim-tree.lua'
|
||||||
Plug 'tomasr/molokai'
|
|
||||||
|
|
||||||
" Tender Theme
|
Plug 'glepnir/dashboard-nvim'
|
||||||
Plug 'jacoborus/tender.vim'
|
|
||||||
|
|
||||||
" Powerline Bar at bottom of screen
|
Plug 'hoob3rt/lualine.nvim'
|
||||||
Plug 'itchyny/lightline.vim'
|
|
||||||
|
" One Dark Pro
|
||||||
|
Plug 'joshdick/onedark.vim'
|
||||||
|
|
||||||
|
" Plug 'liuchengxu/vim-which-key'
|
||||||
|
|
||||||
|
" TODO: Configure this
|
||||||
|
Plug 'mfussenegger/nvim-dap'
|
||||||
|
|
||||||
" Autocomplete
|
" Autocomplete
|
||||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
Plug 'hrsh7th/nvim-compe'
|
||||||
|
Plug 'hrsh7th/vim-vsnip'
|
||||||
|
Plug 'hrsh7th/vim-vsnip-integ'
|
||||||
|
|
||||||
" Scope Tags
|
" Telescope Config
|
||||||
Plug 'majutsushi/tagbar'
|
Plug 'nvim-lua/popup.nvim'
|
||||||
|
Plug 'nvim-lua/plenary.nvim'
|
||||||
|
Plug 'nvim-telescope/telescope.nvim'
|
||||||
|
|
||||||
" Rust Support
|
" Barbar Config
|
||||||
Plug 'rust-lang/rust.vim'
|
Plug 'kyazdani42/nvim-web-devicons'
|
||||||
|
Plug 'romgrk/barbar.nvim'
|
||||||
" TOML Support
|
|
||||||
Plug 'toml-lang/toml'
|
|
||||||
|
|
||||||
" Fuzzy Search
|
|
||||||
Plug 'junegunn/fzf'
|
|
||||||
|
|
||||||
" Multiple Cursors
|
|
||||||
Plug 'terryma/vim-multiple-cursors'
|
|
||||||
|
|
||||||
" File Browser
|
|
||||||
Plug 'preservim/nerdtree'
|
|
||||||
|
|
||||||
" Auto-close brackets
|
|
||||||
Plug 'jiangmiao/auto-pairs'
|
|
||||||
|
|
||||||
" Zig Language
|
|
||||||
Plug 'ziglang/zig.vim'
|
|
||||||
|
|
||||||
" NerdTree Icons (Should be last according to docs)
|
|
||||||
Plug 'ryanoasis/vim-devicons'
|
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
" Call RusftFmt on write to buffer
|
" --Telescope Keybinds--
|
||||||
let g:rustfmt_autosave = 1
|
nnoremap <leader>ff <cmd>lua require('telescope.builtin').find_files()<cr>
|
||||||
|
nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep()<cr>
|
||||||
|
nnoremap <leader>fb <cmd>lua require('telescope.builtin').buffers()<cr>
|
||||||
|
nnoremap <leader>fh <cmd>lua require('telescope.builtin').help_tags()<cr>
|
||||||
|
|
||||||
" Configuration
|
|
||||||
set noshowmode " Lightline requires we turn this off
|
|
||||||
colorscheme one
|
|
||||||
syntax enable
|
|
||||||
|
|
||||||
" Custom Shortcuts
|
" Compe Keybinds
|
||||||
nnoremap <silent><nowait> <space>o :NERDTreeToggle<CR>
|
inoremap <silent><expr> <C-Space> compe#complete()
|
||||||
nnoremap <silent><nowait> <space>s :TagbarToggle<CR>
|
inoremap <silent><expr> <CR> compe#confirm('<CR>')
|
||||||
|
inoremap <silent><expr> <C-e> compe#close('<C-e>')
|
||||||
|
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
|
||||||
|
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
|
||||||
|
|
||||||
|
" Which Key Keybinds
|
||||||
|
" nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
|
||||||
|
" nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
|
||||||
|
|
||||||
|
" Nvim Tree Keybinds
|
||||||
|
let g:nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default
|
||||||
|
let g:nvim_tree_gitignore = 1 "0 by default
|
||||||
|
let g:nvim_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim`
|
||||||
|
let g:nvim_tree_auto_close = 1 "0 by default, closes the tree when it's the last window
|
||||||
|
let g:nvim_tree_auto_ignore_ft = [ 'startify', 'dashboard' ] "empty by default, don't auto open tree on specific filetypes.
|
||||||
|
let g:nvim_tree_quit_on_open = 1 "0 by default, closes the tree when you open a file
|
||||||
|
let g:nvim_tree_follow = 1 "0 by default, this option allows the cursor to be updated when entering a buffer
|
||||||
|
let g:nvim_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open
|
||||||
|
let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
|
||||||
|
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
|
||||||
|
let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open
|
||||||
|
let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file
|
||||||
|
let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names
|
||||||
|
let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contain a single folder into one node in the file tree
|
||||||
|
let g:nvim_tree_lsp_diagnostics = 1 "0 by default, will show lsp diagnostics in the signcolumn. See :help nvim_tree_lsp_diagnostics
|
||||||
|
let g:nvim_tree_special_files = [ 'README.md', 'Makefile', 'MAKEFILE' ] " List of filenames that gets highlighted with NvimTreeSpecialFile
|
||||||
|
let g:nvim_tree_show_icons = {
|
||||||
|
\ 'git': 1,
|
||||||
|
\ 'folders': 1,
|
||||||
|
\ 'files': 1,
|
||||||
|
\ }
|
||||||
|
"If 0, do not show the icons for one of 'git' 'folder' and 'files'
|
||||||
|
"1 by default, notice that if 'files' is 1, it will only display
|
||||||
|
"if nvim-web-devicons is installed and on your runtimepath
|
||||||
|
|
||||||
|
" default will show icon by default if no icon is provided
|
||||||
|
" default shows no icon by default
|
||||||
|
let g:nvim_tree_icons = {
|
||||||
|
\ 'default': '',
|
||||||
|
\ 'symlink': '',
|
||||||
|
\ 'git': {
|
||||||
|
\ 'unstaged': "✗",
|
||||||
|
\ 'staged': "✓",
|
||||||
|
\ 'unmerged': "",
|
||||||
|
\ 'renamed': "➜",
|
||||||
|
\ 'untracked': "★",
|
||||||
|
\ 'deleted': "",
|
||||||
|
\ 'ignored': "◌"
|
||||||
|
\ },
|
||||||
|
\ 'folder': {
|
||||||
|
\ 'default': "",
|
||||||
|
\ 'open': "",
|
||||||
|
\ 'empty': "",
|
||||||
|
\ 'empty_open': "",
|
||||||
|
\ 'symlink': "",
|
||||||
|
\ 'symlink_open': "",
|
||||||
|
\ },
|
||||||
|
\ 'lsp': {
|
||||||
|
\ 'hint': "",
|
||||||
|
\ 'info': "",
|
||||||
|
\ 'warning': "",
|
||||||
|
\ 'error': "",
|
||||||
|
\ }
|
||||||
|
\ }
|
||||||
|
|
||||||
|
nnoremap <C-n> :NvimTreeToggle<CR>
|
||||||
|
nnoremap <leader>r :NvimTreeRefresh<CR>
|
||||||
|
nnoremap <leader>n :NvimTreeFindFile<CR>
|
||||||
|
" NvimTreeOpen and NvimTreeClose are also available if you need them
|
||||||
|
|
||||||
|
|
||||||
|
" a list of groups can be found at `:help nvim_tree_highlight`
|
||||||
|
highlight NvimTreeFolderIcon guibg=blue
|
||||||
|
|
||||||
|
colorscheme onedark
|
||||||
|
|
||||||
|
lua << EOF
|
||||||
|
|
||||||
|
-- NVIM 0.5 LSP Setup
|
||||||
|
|
||||||
|
local nvim_lsp = require'lspconfig'
|
||||||
|
nvim_lsp.pyright.setup{}
|
||||||
|
nvim_lsp.rust_analyzer.setup{}
|
||||||
|
|
||||||
|
-- Tree Sitter Config
|
||||||
|
|
||||||
|
require'nvim-treesitter.configs'.setup {
|
||||||
|
highlight = { enable = true },
|
||||||
|
indent = { enable = true },
|
||||||
|
autotag = { enable = true },
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Telescope Defaults
|
||||||
|
require'telescope'.setup {
|
||||||
|
defaults = {
|
||||||
|
find_command = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'},
|
||||||
|
prompt_position = "bottom",
|
||||||
|
prompt_prefix = " ",
|
||||||
|
border = {},
|
||||||
|
borderchars = {'─', '│', '─', '│', '╭', '╮', '╯', '╰'},
|
||||||
|
color_devicons = true,
|
||||||
|
use_less = true,
|
||||||
|
set_env = {['COLORTERM'] = 'truecolor'},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Barbar Keybinds
|
||||||
|
vim.api.nvim_set_keymap('n', '<TAB>', ':BufferNext<CR>', { noremap = true, silent = true })
|
||||||
|
vim.api.nvim_set_keymap('n', '<S-TAB>', ':BufferPrevious<CR>', { noremap = true, silent = true })
|
||||||
|
vim.api.nvim_set_keymap('n', '<S-x>', ':BufferClose<CR>', { noremap = true, silent = true })
|
||||||
|
|
||||||
|
-- Autopairs setup
|
||||||
|
require'nvim-autopairs'.setup()
|
||||||
|
|
||||||
|
-- Comments
|
||||||
|
require'nvim_comment'.setup()
|
||||||
|
|
||||||
|
-- Autocomplete
|
||||||
|
vim.o.completeopt = "menuone,noselect"
|
||||||
|
|
||||||
|
require'compe'.setup {
|
||||||
|
enabled = true;
|
||||||
|
autocomplete = true;
|
||||||
|
debug = false;
|
||||||
|
min_length = 1;
|
||||||
|
preselect = 'enable';
|
||||||
|
throttle_time = 80;
|
||||||
|
source_timeout = 200;
|
||||||
|
incomplete_delay = 400;
|
||||||
|
max_abbr_width = 100;
|
||||||
|
max_kind_width = 100;
|
||||||
|
max_menu_width = 100;
|
||||||
|
documentation = true;
|
||||||
|
|
||||||
|
source = {
|
||||||
|
path = true;
|
||||||
|
buffer = true;
|
||||||
|
calc = true;
|
||||||
|
nvim_lsp = true;
|
||||||
|
nvim_lua = true;
|
||||||
|
vsnip = true;
|
||||||
|
ultisnips = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
local t = function(str)
|
||||||
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local check_back_space = function()
|
||||||
|
local col = vim.fn.col('.') - 1
|
||||||
|
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use (s-)tab to:
|
||||||
|
--- move to prev/next item in completion menuone
|
||||||
|
--- jump to prev/next snippet's placeholder
|
||||||
|
_G.tab_complete = function()
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
return t "<C-n>"
|
||||||
|
elseif vim.fn.call("vsnip#available", {1}) == 1 then
|
||||||
|
return t "<Plug>(vsnip-expand-or-jump)"
|
||||||
|
elseif check_back_space() then
|
||||||
|
return t "<Tab>"
|
||||||
|
else
|
||||||
|
return vim.fn['compe#complete']()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_G.s_tab_complete = function()
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
return t "<C-p>"
|
||||||
|
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
|
||||||
|
return t "<Plug>(vsnip-jump-prev)"
|
||||||
|
else
|
||||||
|
return t "<S-Tab>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
|
||||||
|
-- lualine Config
|
||||||
|
require'lualine'.setup {
|
||||||
|
options = {
|
||||||
|
theme = "onedark"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Dashboard config
|
||||||
|
vim.g.dashboard_default_executive = 'telescope'
|
||||||
|
vim.g.dashboard_custom_section = {
|
||||||
|
a = {description = {' Find File '}, command = 'Telescope find_files'},
|
||||||
|
b = {description = {' Recently Used Files'}, command = 'Telescope oldfiles'},
|
||||||
|
c = {description = {' Load Last Session '}, command = 'SessionLoad'},
|
||||||
|
d = {description = {' Find Word '}, command = 'Telescope live_grep'},
|
||||||
|
e = {description = {' Settings '}, command = ':e ~/.config/nvim/init.vim'}
|
||||||
|
-- e = {description = {' Marks '}, command = 'Telescope marks'}
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
Loading…
Reference in New Issue