vim: clean unused defaults + compe
This commit is contained in:
141
vim/.vimrc
141
vim/.vimrc
@@ -7,22 +7,9 @@
|
|||||||
" -> General
|
" -> General
|
||||||
" ========================================================
|
" ========================================================
|
||||||
|
|
||||||
" Turn off vi-compatible mode
|
|
||||||
set nocompatible
|
|
||||||
" Encoding
|
|
||||||
set encoding=utf-8
|
|
||||||
set fileencoding=utf-8
|
set fileencoding=utf-8
|
||||||
" History length
|
|
||||||
set history=1000
|
|
||||||
" Remap the <leader> to <Space>
|
|
||||||
nnoremap <Space> <Nop>
|
nnoremap <Space> <Nop>
|
||||||
let mapleader=' '
|
let mapleader=' '
|
||||||
" Includes ftplugin.vim which is responsible for filetype detection
|
|
||||||
filetype plugin indent on
|
|
||||||
" Set syntax highlighting
|
|
||||||
syntax on
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" ========================================================
|
" ========================================================
|
||||||
" -> Plugins
|
" -> Plugins
|
||||||
@@ -65,7 +52,7 @@ Plug 'vim-utils/vim-interruptless'
|
|||||||
|
|
||||||
" ======== Snippets & Autocomplete ======================
|
" ======== Snippets & Autocomplete ======================
|
||||||
|
|
||||||
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||||
|
|
||||||
" ======== Appearence ===================================
|
" ======== Appearence ===================================
|
||||||
|
|
||||||
@@ -88,13 +75,16 @@ Plug 'tpope/vim-rhubarb'
|
|||||||
" ======== Experimental =================================
|
" ======== Experimental =================================
|
||||||
Plug 'christoomey/vim-tmux-navigator'
|
Plug 'christoomey/vim-tmux-navigator'
|
||||||
|
|
||||||
Plug 'nvim-lua/popup.nvim'
|
" Plug 'nvim-lua/popup.nvim'
|
||||||
Plug 'nvim-lua/plenary.nvim'
|
" Plug 'nvim-lua/plenary.nvim'
|
||||||
Plug 'nvim-telescope/telescope.nvim'
|
" Plug 'nvim-telescope/telescope.nvim'
|
||||||
|
|
||||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||||
Plug 'neovim/nvim-lspconfig'
|
Plug 'neovim/nvim-lspconfig'
|
||||||
|
|
||||||
|
Plug 'hrsh7th/nvim-compe'
|
||||||
|
Plug 'hrsh7th/vim-vsnip'
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
|
|
||||||
@@ -333,27 +323,15 @@ endif
|
|||||||
" -> User Interface
|
" -> User Interface
|
||||||
" ========================================================
|
" ========================================================
|
||||||
|
|
||||||
" Enables menu at the bottom
|
|
||||||
set wildmenu
|
|
||||||
" Highlight search
|
|
||||||
set hlsearch
|
|
||||||
" Nicer separators
|
" Nicer separators
|
||||||
set fillchars=diff:⣿,vert:│
|
set fillchars=diff:⣿,vert:│
|
||||||
" Don't try to highlight lines longer than 800 characters.
|
" Don't try to highlight lines longer than 800 characters.
|
||||||
set synmaxcol=200
|
set synmaxcol=200
|
||||||
" When a file has been detected to have been changed outside of Vim and
|
|
||||||
" it has not been changed inside of Vim, automatically read it again.
|
|
||||||
set autoread
|
|
||||||
" Do not redraw while running macros
|
" Do not redraw while running macros
|
||||||
set lazyredraw
|
set lazyredraw
|
||||||
" Tab label - requires vim-madundead
|
" Tab label - requires vim-madundead
|
||||||
set tabline=%!Tabline()
|
set tabline=%!Tabline()
|
||||||
" Show status even for single buffer displayed
|
" Number rows
|
||||||
set laststatus=2
|
|
||||||
" NB: cursorline seems to slow down things quite a bit
|
|
||||||
" highlight current line https://github.com/tmux/tmux/issues/353#issuecomment-364588634
|
|
||||||
" set cursorline
|
|
||||||
" number rows
|
|
||||||
set number
|
set number
|
||||||
" Disable welcome message
|
" Disable welcome message
|
||||||
set shortmess+=I
|
set shortmess+=I
|
||||||
@@ -361,10 +339,6 @@ set shortmess+=I
|
|||||||
set showmatch
|
set showmatch
|
||||||
" Shows when you are in insert mode
|
" Shows when you are in insert mode
|
||||||
set showmode
|
set showmode
|
||||||
" Shows commands in right bottom corner
|
|
||||||
set showcmd
|
|
||||||
" Show cursor position all the tiem
|
|
||||||
set ruler
|
|
||||||
" Show title in console status bar
|
" Show title in console status bar
|
||||||
set title
|
set title
|
||||||
" Dont wrap lines
|
" Dont wrap lines
|
||||||
@@ -408,10 +382,6 @@ command! W w !sudo tee % > /dev/null
|
|||||||
set clipboard=unnamed
|
set clipboard=unnamed
|
||||||
" Tenths of a second to show the matching paren
|
" Tenths of a second to show the matching paren
|
||||||
set matchtime=2
|
set matchtime=2
|
||||||
" Force backspace to behave like in any other editor
|
|
||||||
set backspace=2
|
|
||||||
" Start searching as soon as you type first letter
|
|
||||||
set incsearch
|
|
||||||
" Turn off visualbell
|
" Turn off visualbell
|
||||||
set novisualbell
|
set novisualbell
|
||||||
" Fuck backups
|
" Fuck backups
|
||||||
@@ -429,16 +399,10 @@ set scrolloff=8
|
|||||||
" The minimal number of screen columns to keep to the left and to the
|
" The minimal number of screen columns to keep to the left and to the
|
||||||
" right of the cursor if 'nowrap' is set.
|
" right of the cursor if 'nowrap' is set.
|
||||||
set sidescrolloff=15
|
set sidescrolloff=15
|
||||||
" The minimal number of columns to scroll horizontally
|
|
||||||
set sidescroll=1
|
|
||||||
" Vertical splits in diff mode
|
" Vertical splits in diff mode
|
||||||
set diffopt+=vertical
|
set diffopt+=vertical
|
||||||
" Reduce delay between modes
|
" Reduce delay between modes
|
||||||
set timeoutlen=1000 ttimeoutlen=0
|
set timeoutlen=1000 ttimeoutlen=0
|
||||||
" Delete comment character when joining commented lines
|
|
||||||
if v:version > 703 || v:version == 703 && has("patch541")
|
|
||||||
set formatoptions+=j
|
|
||||||
endif
|
|
||||||
" Use ripgrep if possible
|
" Use ripgrep if possible
|
||||||
if executable('rg')
|
if executable('rg')
|
||||||
set grepprg=rg\ -i\ --vimgrep
|
set grepprg=rg\ -i\ --vimgrep
|
||||||
@@ -454,8 +418,6 @@ set shellcmdflag=-ic
|
|||||||
|
|
||||||
" Automatically inserts one extra level of indentation in some cases
|
" Automatically inserts one extra level of indentation in some cases
|
||||||
set smartindent
|
set smartindent
|
||||||
" Affects how <TAB> key presses are interpreted depending on where the cursor is
|
|
||||||
set smarttab
|
|
||||||
" Tab counts as 2 columns
|
" Tab counts as 2 columns
|
||||||
set tabstop=2
|
set tabstop=2
|
||||||
" Numbers of spaces to (auto)indent
|
" Numbers of spaces to (auto)indent
|
||||||
@@ -502,15 +464,12 @@ nnoremap <silent><leader>= <C-w>=
|
|||||||
nnoremap <silent><leader><space> :nohlsearch<CR>
|
nnoremap <silent><leader><space> :nohlsearch<CR>
|
||||||
|
|
||||||
nnoremap <silent><leader>ga :Gwrite<CR>
|
nnoremap <silent><leader>ga :Gwrite<CR>
|
||||||
nnoremap <silent><leader>gc :Gcommit<CR>
|
nnoremap <silent><leader>gs :Git<CR>
|
||||||
nnoremap <silent><leader>gp :Gpush<CR>
|
nnoremap <silent><leader>gb :Git blame<CR>
|
||||||
nnoremap <silent><leader>gup :Gpull<CR>
|
|
||||||
nnoremap <silent><leader>gs :Gstatus<CR>
|
|
||||||
nnoremap <silent><leader>gd :Gvdiff<CR>
|
|
||||||
nnoremap <silent><leader>gb :Gblame<CR>
|
|
||||||
|
|
||||||
nnoremap <silent><Tab> :tabnext<CR>
|
nnoremap <silent><Tab> :tabnext<CR>
|
||||||
nnoremap <silent><S-Tab> :tabprevious<CR>
|
nnoremap <silent><S-Tab> :tabprevious<CR>
|
||||||
|
|
||||||
" nnoremap <silent>vv <c-w>v
|
" nnoremap <silent>vv <c-w>v
|
||||||
nnoremap <silent>vv :sp <CR>
|
nnoremap <silent>vv :sp <CR>
|
||||||
nnoremap <silent><C-w> :call StripTrailingWhitespace()<CR>
|
nnoremap <silent><C-w> :call StripTrailingWhitespace()<CR>
|
||||||
@@ -552,6 +511,7 @@ nmap ga <Plug>(EasyAlign)
|
|||||||
nnoremap <silent><expr><leader>e (expand('%') =~ 'NERD_tree' ? "\<C-w>\<C-w>" : '').":Files ~/Tmp\<CR>"
|
nnoremap <silent><expr><leader>e (expand('%') =~ 'NERD_tree' ? "\<C-w>\<C-w>" : '').":Files ~/Tmp\<CR>"
|
||||||
nnoremap <leader>E :e ~/Tmp/
|
nnoremap <leader>E :e ~/Tmp/
|
||||||
|
|
||||||
|
" TODO Ignore .obsidian/
|
||||||
nnoremap <silent><expr><leader>o (expand('%') =~ 'NERD_tree' ? "\<C-w>\<C-w>" : '').":Files ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Personal\<CR>"
|
nnoremap <silent><expr><leader>o (expand('%') =~ 'NERD_tree' ? "\<C-w>\<C-w>" : '').":Files ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Personal\<CR>"
|
||||||
nnoremap <leader>O :e ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Personal
|
nnoremap <leader>O :e ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Personal
|
||||||
|
|
||||||
@@ -575,6 +535,7 @@ require'nvim-treesitter.configs'.setup {
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
lua << EOF
|
lua << EOF
|
||||||
|
require'lspconfig'.solargraph.setup{}
|
||||||
local nvim_lsp = require('lspconfig')
|
local nvim_lsp = require('lspconfig')
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
-- Use an on_attach function to only map the following keys
|
||||||
@@ -622,3 +583,79 @@ for _, lsp in ipairs(servers) do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
lua << EOF
|
||||||
|
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 = false;
|
||||||
|
|
||||||
|
source = {
|
||||||
|
path = true;
|
||||||
|
buffer = true;
|
||||||
|
calc = true;
|
||||||
|
vsnip = true;
|
||||||
|
nvim_lsp = true;
|
||||||
|
nvim_lua = true;
|
||||||
|
spell = true;
|
||||||
|
tags = true;
|
||||||
|
snippets_nvim = true;
|
||||||
|
treesitter = 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
|
||||||
|
-- If <S-Tab> is not working in your terminal, change it to <C-h>
|
||||||
|
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})
|
||||||
|
EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user