Created
November 21, 2021 17:42
-
-
Save moali87/d2bf1a7aa9236c7906fd91fb5a026191 to your computer and use it in GitHub Desktop.
medium init.vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Leader key | |
let mapleader = "," | |
" Default key mapping | |
nnoremap <F3> :tabprevious <CR> | |
nnoremap <F4> :tabnext <CR> | |
" RTP | |
set rtp+=/Users/akhterali/config/nvim/plugged | |
" LazyGit | |
nnoremap <silent> <leader>gg :LazyGit<CR> | |
" Spacing | |
filetype plugin indent on | |
" show existing tab with 4 spaces width | |
set tabstop=2 | |
" when indenting with '>', use 4 spaces width | |
set shiftwidth=2 | |
" On pressing tab, insert 4 spaces | |
set expandtab | |
call plug#begin('/Users/akhterali/.config/nvim/plugged') | |
" Declare the list of plugins. | |
Plug '907th/vim-auto-save' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'https://github.com/rafi/awesome-vim-colorschemes.git' | |
Plug 'lukelbd/vim-tagtools' | |
Plug 'tpope/vim-sensible' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'preservim/nerdcommenter' | |
Plug 'lukas-reineke/indent-blankline.nvim' | |
Plug 'ibhagwan/fzf-lua' | |
Plug 'vijaymarupudi/nvim-fzf' | |
Plug 'kdheepak/lazygit.nvim' | |
Plug 'folke/lsp-colors.nvim' | |
Plug 'ntpeters/vim-better-whitespace' | |
Plug 'kyazdani42/nvim-web-devicons' | |
Plug 'williamboman/nvim-lsp-installer' | |
Plug 'neovim/nvim-lspconfig' | |
Plug 'ms-jpq/coq_nvim', {'branch': 'coq'} | |
Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'} | |
Plug 'ms-jpq/coq.thirdparty', {'branch': '3p'} | |
" Initialize plugin system | |
call plug#end() | |
" coq | |
let g:coq_settings = { 'auto_start': 'shut-up' } | |
" AutoSave | |
let g:auto_save = 1 | |
set completeopt=menu,menuone,noselect | |
lua <<EOF | |
-- Setup lspconfig. | |
require'lspconfig'.pyright.setup{} | |
require'lspconfig'.tsserver.setup{} | |
EOF | |
" Color Scheme | |
set termguicolors | |
let g:airline#extensions#tabline#enabled = 1 | |
colorscheme OceanicNext | |
syntax on | |
" air-line | |
let g:airline_powerline_fonts = 1 | |
if !exists('g:airline_symbols') | |
let g:airline_symbols = {} | |
endif | |
" unicode symbols | |
let g:airline_left_sep = '»' | |
let g:airline_left_sep = '▶' | |
let g:airline_right_sep = '«' | |
let g:airline_right_sep = '◀' | |
let g:airline_symbols.linenr = '␊' | |
let g:airline_symbols.linenr = '' | |
let g:airline_symbols.linenr = '¶' | |
let g:airline_symbols.branch = '⎇' | |
let g:airline_symbols.paste = 'ρ' | |
let g:airline_symbols.paste = 'Þ' | |
let g:airline_symbols.paste = '∥' | |
let g:airline_symbols.whitespace = 'Ξ' | |
" airline symbols | |
let g:airline_left_sep = '' | |
let g:airline_left_alt_sep = '' | |
let g:airline_right_sep = '' | |
let g:airline_right_alt_sep = '' | |
let g:airline_symbols.branch = '' | |
let g:airline_symbols.readonly = '' | |
let g:airline_symbols.linenr = '' | |
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' | |
if empty(glob(data_dir . '/autoload/plug.vim')) | |
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' | |
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC | |
endif | |
" FZF | |
set rtp+=/opt/homebrew/opt/fzf | |
nnoremap <c-O> <cmd>lua require('fzf-lua').files()<CR> | |
nnoremap <c-P> <cmd>lua require('fzf-lua').grep_visual()<CR> | |
" custom fzf handling lets me implement always jumping to the chosen file if already open somewhere | |
function! s:open_with_fzf(files) | |
let x = split(execute('ls a'), "[\n\r]") | |
let alreadyOpened = [] | |
for l:line in x | |
" these are open ("active") filenames | |
let filename = split(l:line, '"')[1] | |
let index = index(a:files, filename) | |
if index != -1 | |
call add(alreadyOpened, [index, filename]) | |
endif | |
endfor | |
" if multiple requested files are already opened, we end up going to the earliest one in the | |
" buffer list | |
if len(alreadyOpened) > 0 | |
execute("tab drop ".alreadyOpened[0][1]) | |
else | |
" split (my personal perference), unless in empty buffer in which case replaces | |
if @% == "" | |
" was in empty buffer | |
" echom 'empty buf, making new' | |
let last = a:files->remove(-1) | |
execute("e ".last) | |
endif | |
" if greater than 3 items, open them all as tabs | |
for l:fileToOpen in a:files | |
if (len(a:files) > 3) | |
echom 'tabe '.l:fileToOpen | |
execute("tabe ".l:fileToOpen) | |
else | |
execute("split ".l:fileToOpen) | |
endif | |
endfor | |
endif | |
endfunction | |
let g:fzf_action = { | |
\ 'enter': function('s:open_with_fzf'), | |
\ 'ctrl-t': 'tab split', | |
\ 'ctrl-s': 'split', | |
\ 'ctrl-v': 'vsplit' } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment