Last active
October 6, 2022 10:37
-
-
Save sathishmanohar/7c571691bd2c0e30fff1e6d9a843c5f9 to your computer and use it in GitHub Desktop.
This file contains 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
call plug#begin('~/.vim/plugged') | |
" Gruvbox theme | |
Plug 'gruvbox-community/gruvbox' | |
" Papercolor theme | |
Plug 'NLKNguyen/papercolor-theme' | |
" Everforest theme | |
Plug 'sainnhe/everforest' | |
" VS Code like dark theme | |
Plug 'tomasiser/vim-code-dark' | |
" Automatically show Vim's complete menu while typing. | |
" Plug 'vim-scripts/AutoComplPop' | |
" Integrate fzf with Vim. | |
Plug '$XDG_DATA_HOME/fzf' | |
Plug 'junegunn/fzf' | |
Plug 'junegunn/fzf.vim' | |
" Search within files | |
" Install ag or ack in via apt-get for this to work | |
Plug 'dyng/ctrlsf.vim' | |
" vim airline status line | |
Plug 'vim-airline/vim-airline' | |
" Airline themes | |
Plug 'vim-airline/vim-airline-themes' | |
" Easymotion for jumping within the buffer | |
Plug 'easymotion/vim-easymotion' | |
" Show git file changes in the gutter. | |
Plug 'mhinz/vim-signify' | |
" A git wrapper. | |
Plug 'tpope/vim-fugitive' | |
" Navigate and manipulate files in a tree view. | |
Plug 'lambdalisue/fern.vim' | |
Plug 'lambdalisue/fern-mapping-mark-children.vim' | |
Plug 'lambdalisue/nerdfont.vim' | |
" Comments | |
Plug 'tpope/vim-commentary' | |
" Generate tags / ctags automatically | |
" Exuberant ctags should be installed in system to work | |
Plug 'craigemery/vim-autotag' | |
" Editor config plugin | |
Plug 'editorconfig/editorconfig-vim' | |
" Plugin for new line at end of file setting to work in vim | |
Plug 'vim-scripts/PreserveNoEOL' | |
" Languages and file types. | |
Plug 'cakebaker/scss-syntax.vim' | |
Plug 'chr4/nginx.vim' | |
Plug 'chrisbra/csv.vim' | |
Plug 'ekalinin/dockerfile.vim' | |
Plug 'elixir-editors/vim-elixir' | |
Plug 'Glench/Vim-Jinja2-Syntax' | |
Plug 'fatih/vim-go' | |
Plug 'cespare/vim-toml', { 'branch': 'main' } | |
Plug 'godlygeek/tabular' | Plug 'tpope/vim-markdown' | |
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' } | |
Plug 'jvirtanen/vim-hcl' | |
Plug 'lifepillar/pgsql.vim' | |
Plug 'othree/html5.vim' | |
Plug 'pangloss/vim-javascript' | |
Plug 'MaxMEllon/vim-jsx-pretty' | |
Plug 'PotatoesMaster/i3-vim-syntax' | |
Plug 'stephpy/vim-yaml' | |
Plug 'tmux-plugins/vim-tmux' | |
Plug 'tpope/vim-git' | |
Plug 'tpope/vim-liquid' | |
Plug 'tpope/vim-rails' | |
Plug 'vim-python/python-syntax' | |
Plug 'vim-ruby/vim-ruby' | |
Plug 'wgwoods/vim-systemd-syntax' | |
Plug 'towolf/vim-helm' | |
Plug 'hashivim/vim-terraform' | |
" Snipmate | |
" Plug 'MarcWeber/vim-addon-mw-utils' | |
" Plug 'tomtom/tlib_vim' | |
" Plug 'garbas/vim-snipmate' | |
" A bunch of useful language related snippets (ultisnips is the engine). | |
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' | |
" Snipmate snippets | |
" Plug 'honza/vim-snippets' | |
" Sathish settings | |
Plug 'tpope/vim-surround' | |
Plug 'adelarsq/vim-matchit' | |
Plug 'yegappan/mru' | |
" Drastically improve insert mode performance in files with folds. | |
Plug 'Konfekt/FastFold' | |
" Show indent line | |
Plug 'Yggdroot/indentLine' | |
" Sathish nertree but try Fern later, it is faster | |
" Plug 'preservim/nerdtree' | |
" https://bluz71.github.io/2017/05/21/vim-plugins-i-like.html | |
" https://moduletux.gitlab.io/posts/setting-up-a-ruby-development-environment-in-vim/ | |
" This part doesn't fully work | |
" Language Server support | |
" Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()} } | |
" Vim icons | |
Plug 'ryanoasis/vim-devicons' | |
" Display icons in fern | |
Plug 'lambdalisue/fern-renderer-devicons.vim' | |
" Treesitter | |
" Plug 'nvim-treesitter/nvim-treesitter' | |
" For function names to be fixed on scroll for long functions | |
" Requires nvim-treesitter | |
" Plug 'nvim-treesitter/nvim-treesitter-context' | |
" Easily install and manage LSP servers, DAP servers, linters, and formatters | |
Plug 'williamboman/mason.nvim' | |
" For Neovim | |
" Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
" LSP config | |
Plug 'neovim/nvim-lspconfig' | |
" Nvim autocomplete plugings | |
Plug 'hrsh7th/nvim-cmp' | |
Plug 'hrsh7th/cmp-buffer' | |
Plug 'hrsh7th/cmp-path' | |
Plug 'saadparwaiz1/cmp_luasnip' | |
Plug 'hrsh7th/cmp-nvim-lsp' | |
Plug 'hrsh7th/cmp-nvim-lua' | |
" NVIM specific | |
" Plug 'mfussenegger/nvim-lint' | |
call plug#end() | |
" For nvim-cmp | |
set completeopt=menu,menuone,noselect | |
" ----------------------------------------------------------------------------- | |
" Color settings | |
" ----------------------------------------------------------------------------- | |
" From Sathish .vimrc | |
filetype plugin on | |
filetype indent on | |
" Setfont | |
" set guifont=Monaco:h12 | |
" Enable 24-bit true colors if your terminal supports it. | |
if (has("termguicolors")) | |
" https://github.com/vim/vim/issues/993#issuecomment-255651605 | |
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" | |
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" | |
set termguicolors | |
endif | |
" Enable syntax highlighting. | |
syntax on | |
" Specific colorscheme settings (must come before setting your colorscheme). | |
if !exists('g:gruvbox_contrast_light') | |
let g:gruvbox_contrast_light='hard' | |
endif | |
" Set the color scheme. | |
colorscheme everforest | |
set background=dark | |
" Specific colorscheme settings (must come after setting your colorscheme). | |
if (g:colors_name == 'gruvbox') | |
if (&background == 'dark') | |
hi Visual cterm=NONE ctermfg=NONE ctermbg=237 guibg=#3a3a3a | |
else | |
hi Visual cterm=NONE ctermfg=NONE ctermbg=228 guibg=#f2e5bc | |
hi CursorLine cterm=NONE ctermfg=NONE ctermbg=228 guibg=#f2e5bc | |
hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=228 guibg=#f2e5bc | |
endif | |
endif | |
" Spelling mistakes will be colored up red. | |
hi SpellBad cterm=underline ctermfg=203 guifg=#ff5f5f | |
hi SpellLocal cterm=underline ctermfg=203 guifg=#ff5f5f | |
hi SpellRare cterm=underline ctermfg=203 guifg=#ff5f5f | |
hi SpellCap cterm=underline ctermfg=203 guifg=#ff5f5f | |
" Airline theme | |
let g:airline_theme='google_dark' | |
" Show only filename in airline | |
let g:airline_section_c = '%t' | |
let g:airline_section_a = '' | |
let g:airline_section_z = '' | |
" Below line disables branch name | |
" let g:airline#extensions#branch#enabled = 0 | |
" Tab bar airline | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#fnamemod = ':t' | |
" Show buffer numbers in tab | |
let g:airline#extensions#tabline#buffer_nr_show = 1 | |
" ----------------------------------------------------------------------------- | |
" Status line | |
" ----------------------------------------------------------------------------- | |
" Heavily inspired by: https://github.com/junegunn/dotfiles/blob/master/vimrc | |
function! s:statusline_expr() | |
let mod = "%{&modified ? '[+] ' : !&modifiable ? '[x] ' : ''}" | |
let ro = "%{&readonly ? '[RO] ' : ''}" | |
let ft = "%{len(&filetype) ? '['.&filetype.'] ' : ''}" | |
let fug = "%{exists('g:loaded_fugitive') ? fugitive#statusline() : ''}" | |
let sep = ' %= ' | |
let pos = ' %-12(%l : %c%V%) ' | |
let pct = ' %P' | |
return '[%n] %f %<'.mod.ro.ft.fug.sep.pos.'%*'.pct | |
endfunction | |
let &statusline = s:statusline_expr() | |
" Use a line cursor within insert mode and a block cursor everywhere else. | |
" | |
" Using iTerm2? Go-to preferences / profile / colors and disable the smart bar | |
" cursor color. Then pick a cursor and highlight color that matches your theme. | |
" That will ensure your cursor is always visible within insert mode. | |
" | |
" Reference chart of values: | |
" Ps = 0 -> blinking block. | |
" Ps = 1 -> blinking block (default). | |
" Ps = 2 -> steady block. | |
" Ps = 3 -> blinking underline. | |
" Ps = 4 -> steady underline. | |
" Ps = 5 -> blinking bar (xterm). | |
" Ps = 6 -> steady bar (xterm). | |
let &t_SI = "\e[6 q" | |
let &t_EI = "\e[2 q" | |
" ............................................................................. | |
" lambdalisue/fern.vim | |
" ............................................................................. | |
" Disable netrw. | |
let g:loaded_netrw = 1 | |
let g:loaded_netrwPlugin = 1 | |
let g:loaded_netrwSettings = 1 | |
let g:loaded_netrwFileHandlers = 1 | |
augroup my-fern-hijack | |
autocmd! | |
autocmd BufEnter * ++nested call s:hijack_directory() | |
augroup END | |
function! s:hijack_directory() abort | |
let path = expand('%:p') | |
if !isdirectory(path) | |
return | |
endif | |
bwipeout % | |
execute printf('Fern %s', fnameescape(path)) | |
endfunction | |
" Custom settings and mappings. | |
let g:fern#disable_default_mappings = 1 | |
let g:fern#default_hidden = 0 | |
" Settings for nerdfont | |
" let g:fern#renderer = "nerdfont" | |
let g:fern#renderer = "devicons" | |
nnoremap ,fl :Fern . -drawer -reveal=% -toggle -width=30<CR> | |
function! FernInit() abort | |
nmap <buffer><expr> | |
\ <Plug>(fern-my-open-expand-collapse) | |
\ fern#smart#leaf( | |
\ "\<Plug>(fern-action-open:select)", | |
\ "\<Plug>(fern-action-expand)", | |
\ "\<Plug>(fern-action-collapse)", | |
\ ) | |
nmap <buffer> o <Plug>(fern-my-open-expand-collapse) | |
nmap <buffer> <2-LeftMouse> <Plug>(fern-my-open-expand-collapse) | |
nmap <buffer> n <Plug>(fern-action-new-path) | |
nmap <buffer> d <Plug>(fern-action-remove) | |
nmap <buffer> m <Plug>(fern-action-move) | |
nmap <buffer> M <Plug>(fern-action-rename) | |
nmap <buffer> y <Plug>(fern-action-hidden:toggle) | |
nmap <buffer> r <Plug>(fern-action-reload) | |
nmap <buffer> x <Plug>(fern-action-mark) | |
nmap <buffer> X <Plug>(fern-action-mark-children:leaf) | |
nmap <buffer> b <Plug>(fern-action-open:split) | |
nmap <buffer> v <Plug>(fern-action-open:vsplit) | |
nmap <buffer><nowait> < <Plug>(fern-action-leave) | |
nmap <buffer><nowait> > <Plug>(fern-action-enter) | |
nmap <buffer> p <Plug>(fern-action-focus:parent) | |
endfunction | |
augroup FernGroup | |
autocmd! | |
autocmd FileType fern setlocal norelativenumber | setlocal nonumber | call FernInit() | |
augroup END | |
" End Fern | |
" ............................................................................. | |
" Konfekt/FastFold | |
" ............................................................................. | |
" let g:fastfold_savehook=0 | |
" let g:fastfold_fold_command_suffixes=[] | |
set nofoldenable | |
set foldmethod=syntax | |
set foldlevelstart=1 | |
nmap ,ft zMzr | |
" End FastFold | |
" Set the indent indicator character for Yggdroot/indentLine plugin | |
let g:indentLine_char_list = ['|'] | |
" GVim | |
" let g:indentLine_color_gui = '#666666' | |
" Background (Vim, GVim) | |
" let g:indentLine_bgcolor_term = 202 | |
" let g:indentLine_bgcolor_gui = '#888' | |
" End indentLine settings | |
nmap ,sp <Plug>CtrlSFPrompt | |
nnoremap <C-F>o :CtrlSFOpen<CR> | |
nnoremap <C-F>t :CtrlSFToggle<CR> | |
let g:ctrlsf_mapping = {"vsplit": "v"} | |
" ----------------------------------------------------------------------------- | |
" Plugin settings, mappings and autocommands | |
" ----------------------------------------------------------------------------- | |
" ............................................................................. | |
" junegunn/fzf.vim | |
" ............................................................................. | |
let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all' | |
" Customize fzf colors to match your color scheme. | |
let g:fzf_colors = | |
\ { 'fg': ['fg', 'Normal'], | |
\ 'bg': ['bg', 'Normal'], | |
\ 'hl': ['fg', 'Comment'], | |
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], | |
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], | |
\ 'hl+': ['fg', 'Statement'], | |
\ 'info': ['fg', 'PreProc'], | |
\ 'prompt': ['fg', 'Conditional'], | |
\ 'pointer': ['fg', 'Exception'], | |
\ 'marker': ['fg', 'Keyword'], | |
\ 'spinner': ['fg', 'Label'], | |
\ 'header': ['fg', 'Comment'] } | |
let g:fzf_action = { | |
\ 'ctrl-t': 'tab split', | |
\ 'ctrl-n': 'split', | |
\ 'ctrl-v': 'vsplit', | |
\ 'ctrl-y': {lines -> setreg('*', join(lines, "\n"))}} | |
" Launch fzf with CTRL+P. | |
nnoremap <silent> <C-p> :FZF -m<CR> | |
" Map a few common things to do with FZF. | |
nnoremap <silent> <Leader><Enter> :Buffers<CR> | |
nnoremap <silent> <Leader>l :Lines<CR> | |
" Allow passing optional flags into the Rg command. | |
" Example: :Rg myterm -g '*.md' | |
command! -bang -nargs=* Rg | |
\ call fzf#vim#grep( | |
\ "rg --column --line-number --no-heading --color=always --smart-case " . | |
\ <q-args>, 1, fzf#vim#with_preview(), <bang>0) | |
" Sathish go to definition | |
" Exuberant ctags should be installed in system to work | |
nnoremap ,fd <C-]> zz | |
" Git commands like blame diff and log inside vim | |
" Requires timpope fugitive plugin | |
nnoremap ,gb :Git blame<CR> | |
nnoremap ,gd :Git diff<CR> | |
nnoremap ,gs :Git status<CR> | |
nnoremap ,gsh :Git stash<CR> | |
nnoremap ,gshp :Git stash pop<CR> | |
" Sathish | |
set colorcolumn=80 | |
" Sathish: New Splits are opened below or right of current splits | |
set splitbelow | |
set splitright | |
"Sathish: space types : in normal mode | |
nmap <space> : | |
"Sathish: Go to last Edited Part | |
nnoremap ,le `. | |
"Dont press escape, press jj | |
inoremap jj <ESC> | |
" inoremap jk <ESC> | |
" inoremap kj <ESC> | |
inoremap uu <C-o>u | |
"Sathish: Easy motion shortcuts | |
nmap ,jt H<Leader><Leader>w | |
" Scroll up and down with m M and t and T | |
nmap M <C-d> | |
nmap T <C-u> | |
nmap m <C-e> | |
nmap t <C-y> | |
" Sathish: Maxmize and Minimize Splits | |
nmap ,mm <C-w>\| | |
nmap ,nn <C-w>1\| | |
nmap ,ee <C-w>= | |
" Sathish: Resize panes | |
nmap ,pb <C-w>+<C-w>+<C-w>+<C-w>+ | |
nmap ,ps <C-w>-<C-w>-<C-w>-<C-w>- | |
" Sathish: Opens Vertical Split and Switches Over | |
nnoremap <leader>v <C-w>v<C-w>l | |
nnoremap <leader>n <C-w>n<C-w>j | |
" Sathish: New split with new buffer | |
nmap ,sv :vnew<cr><C-w>l | |
nmap ,sn :new<cr><C-w>l | |
" Previous and text tabs | |
map ,ct :tabnew<cr> | |
map ,tn :tabnext<cr> | |
map ,tp :tabprevious<cr> | |
set guitablabel=%t | |
" Previous and next Buffers | |
map ,bn :bn<cr> | |
map ,bp :bp<cr> | |
" Use tabs in normal mode to jump buffers | |
nnoremap <Tab> :bnext<CR> | |
nnoremap <S-Tab> :bprevious<CR> | |
" Deleted Current Buffer | |
nmap ,bd :bd<cr> | |
"Sathish: Closes Split or Tab on ,ll | |
nnoremap ,ll :close<cr> | |
"Sathish: Shortcuts for line numbers | |
set nonumber | |
nnoremap ,nl :set nonumber<cr> | |
nnoremap ,ln :set number<cr> | |
nnoremap ,rl :set relativenumber<cr> | |
nnoremap ,nr :set norelativenumber<cr> | |
" Sathish: Highlight current line | |
set cursorline | |
" Sathish: tell vim Not to Save .swp files | |
set noswapfile | |
"Sathish: Shortcut for editing vimrc file | |
" nmap ,ev :tabedit $MYVIMRC<cr> | |
nmap ,ev :tabedit ~/.vimrc<cr> | |
" Sathish: Loads Last Saved Version, Discards all changes done. | |
nnoremap ,ls :e!<cr> | |
" Sathish: copy to clipboard | |
" Install vim-gui-common (apt-get) for this to work | |
set clipboard=unnamedplus | |
" When pasting over a visual selection send existing visual selection | |
" to the black hole register and not to any named or numbered register | |
xnoremap ,p "_dp | |
xnoremap ,d "_dd<Esc> | |
xnoremap ,x "_d<Esc> | |
xnoremap ,c "_c | |
nnoremap ,d "_dd | |
nnoremap ,c "_C | |
nnoremap ,cw "_cw | |
nnoremap ,yp "0p<Esc> | |
" Insert mode keymaps | |
inoremap <C-m> <C-o>D | |
inoremap <C-j> <C-o>o | |
inoremap <C-k> <C-o>O | |
" Suspend VIM | |
nmap ,ss <C-z> | |
" Sathish: Open most recently used files | |
nmap ,mr :MRU<cr> | |
" Sathish: For ruby make ctags searches search for methods ending with ? and ! | |
" https://stackoverflow.com/a/45314261 | |
:set iskeyword+=! | |
:set iskeyword+=? | |
" Toggle virtual line suggestions ( Nvim ) | |
nmap ,el :lua vim.diagnostic.enable()<cr> | |
nmap ,dl :lua vim.diagnostic.disable()<cr> |
This file contains 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
set runtimepath^=~/.vim runtimepath+=~/.vim/after | |
let &packpath = &runtimepath | |
source ~/.vimrc | |
lua <<EOF | |
local nvim_lsp = require('lspconfig') | |
-- Use an on_attach function to only map the following keys | |
-- after the language server attaches to the current buffer | |
local on_attach = function(client, bufnr) | |
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end | |
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end | |
--Enable completion triggered by <c-x><c-o> | |
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') | |
-- Mappings. | |
local opts = { noremap=true, silent=true } | |
-- See `:help vim.lsp.*` for documentation on any of the below functions | |
--- buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts) | |
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts) | |
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts) | |
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) | |
--- buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) | |
--- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts) | |
--- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts) | |
--- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts) | |
--- buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) | |
buf_set_keymap('n', ',rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) | |
buf_set_keymap('n', '<C-a>', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) | |
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) | |
buf_set_keymap('n', '<C-s>', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts) | |
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) | |
buf_set_keymap('n', '<C-j>', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts) | |
--- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts) | |
buf_set_keymap("n", "<C-f>", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) | |
end | |
--- Enable solargraph | |
--- require'lspconfig'.solargraph.setup{} | |
--- Use a loop to conveniently call 'setup' on multiple servers and | |
--- map buffer local keybindings when the language server attaches | |
local servers = { "solargraph", "html", "cssls", "tsserver", "sqlls", "sorbet" } | |
for _, lsp in ipairs(servers) do | |
nvim_lsp[lsp].setup { | |
on_attach = on_attach, | |
flags = { | |
debounce_text_changes = 150, | |
} | |
} | |
end | |
--- Enable mason.vim | |
require("mason").setup() | |
-- פּ ﯟ some other good icons | |
local kind_icons = { | |
Text = "", | |
Method = "m", | |
Function = "", | |
Constructor = "", | |
Field = "", | |
Variable = "", | |
Class = "", | |
Interface = "", | |
Module = "", | |
Property = "", | |
Unit = "", | |
Value = "", | |
Enum = "", | |
Keyword = "", | |
Snippet = "", | |
Color = "", | |
File = "", | |
Reference = "", | |
Folder = "", | |
EnumMember = "", | |
Constant = "", | |
Struct = "", | |
Event = "", | |
Operator = "", | |
TypeParameter = "", | |
} | |
--- Nvim cmp settings | |
-- Set up nvim-cmp. | |
local cmp = require'cmp' | |
cmp.setup({ | |
snippet = { | |
-- REQUIRED - you must specify a snippet engine | |
expand = function(args) | |
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. | |
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. | |
-- require('snippy').expand_snippet(args.body) -- For `snippy` users. | |
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. | |
end, | |
}, | |
formatting = { | |
fields = { "kind", "abbr", "menu" }, | |
format = function(entry, vim_item) | |
-- Kind icons | |
vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) | |
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind | |
vim_item.menu = ({ | |
nvim_lsp = "[LSP]", | |
luasnip = "[Snippet]", | |
buffer = "[Buffer]", | |
path = "[Path]", | |
})[entry.source.name] | |
return vim_item | |
end, | |
}, | |
window = { | |
documentation = { | |
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, | |
}, | |
-- completion = cmp.config.window.bordered(), | |
-- documentation = cmp.config.window.bordered(), | |
}, | |
mapping = cmp.mapping.preset.insert({ | |
['<C-b>'] = cmp.mapping.scroll_docs(-4), | |
['<C-f>'] = cmp.mapping.scroll_docs(4), | |
['<C-Space>'] = cmp.mapping.complete(), | |
['<C-e>'] = cmp.mapping.abort(), | |
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. | |
}), | |
sources = cmp.config.sources({ | |
{ name = 'nvim_lsp' }, | |
{ name = 'vsnip' }, -- For vsnip users. | |
-- { name = 'luasnip' }, -- For luasnip users. | |
-- { name = 'ultisnips' }, -- For ultisnips users. | |
-- { name = 'snippy' }, -- For snippy users. | |
}, { | |
{ name = 'buffer' }, | |
}) | |
}) | |
-- Set configuration for specific filetype. | |
cmp.setup.filetype('gitcommit', { | |
sources = cmp.config.sources({ | |
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. | |
}, { | |
{ name = 'buffer' }, | |
}) | |
}) | |
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). | |
cmp.setup.cmdline({ '/', '?' }, { | |
mapping = cmp.mapping.preset.cmdline(), | |
sources = { | |
{ name = 'buffer' } | |
} | |
}) | |
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). | |
cmp.setup.cmdline(':', { | |
mapping = cmp.mapping.preset.cmdline(), | |
sources = cmp.config.sources({ | |
{ name = 'path' } | |
}, { | |
{ name = 'cmdline' } | |
}) | |
}) | |
-- Set up lspconfig. | |
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) | |
--- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled. | |
require('lspconfig')['html'].setup { | |
capabilities = capabilities, | |
filetypes = { 'html', 'eruby' } | |
} | |
require('lspconfig')['sorbet'].setup { | |
cmd = { 'srb', 'tc', '--lsp', '--disable-watchman'} | |
} | |
--- End Nvim cmp settings | |
EOF | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment