aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-12-06 14:15:59 +0000
committerJuan J. Martinez <jjm@usebox.net>2022-05-29 22:57:30 +0100
commit98fa2f083062c4f85b0b2f2057b30e76e9b8e309 (patch)
tree8bd53941c7d03f9682812e4d151f02617b464ac3
parent783154e2c1b45238f53527fc02d6ea5a670b7c7f (diff)
downloaddotnvim-98fa2f083062c4f85b0b2f2057b30e76e9b8e309.tar.gz
dotnvim-98fa2f083062c4f85b0b2f2057b30e76e9b8e309.zip
Use CMP
-rw-r--r--cmp.vim36
-rw-r--r--init.vim6
-rw-r--r--metals.vim3
-rw-r--r--vimrc30
4 files changed, 64 insertions, 11 deletions
diff --git a/cmp.vim b/cmp.vim
new file mode 100644
index 0000000..e720e65
--- /dev/null
+++ b/cmp.vim
@@ -0,0 +1,36 @@
+lua <<EOF
+ -- Setup nvim-cmp.
+ local cmp = require'cmp'
+
+ cmp.setup({
+ snippet = {
+ expand = function(args)
+ vim.fn["vsnip#anonymous"](args.body)
+ end,
+ },
+ mapping = {
+ ['<CR>'] = cmp.mapping.confirm({ select = true }),
+ },
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ { name = 'vsnip' },
+ })
+ })
+
+ -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
+ cmp.setup.cmdline('/', {
+ sources = {
+ { name = 'buffer' }
+ }
+ })
+
+ -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
+ cmp.setup.cmdline(':', {
+ sources = cmp.config.sources({
+ { name = 'path' }
+ }, {
+ { name = 'cmdline' }
+ })
+ })
+EOF
+
diff --git a/init.vim b/init.vim
index 69eee22..480385f 100644
--- a/init.vim
+++ b/init.vim
@@ -7,6 +7,10 @@ source ~/.vimrc
"
" general
source ~/.vim/lsc.vim
-"
+
" scala and metals
source ~/.vim/metals.vim
+
+" auto-complete
+source ~/.vim/cmp.vim
+
diff --git a/metals.vim b/metals.vim
index 69590d0..f741203 100644
--- a/metals.vim
+++ b/metals.vim
@@ -51,6 +51,3 @@ endif
"
autocmd FileType scala setlocal omnifunc=v:lua.vim.lsp.omnifunc
-" Set completeopt to have a better completion experience
-set completeopt=menuone,noinsert,noselect
-
diff --git a/vimrc b/vimrc
index 3d198fc..6df528f 100644
--- a/vimrc
+++ b/vimrc
@@ -66,15 +66,23 @@ Plug 'neovimhaskell/haskell-vim'
" nvim 0.5.0 or later
if has('nvim-0.5')
+ " general lua
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
+ " scala
Plug 'scalameta/nvim-metals'
Plug 'nvim-telescope/telescope.nvim'
+ " auto complete
+ Plug 'hrsh7th/nvim-cmp'
+ Plug 'hrsh7th/cmp-nvim-lsp'
+ Plug 'hrsh7th/cmp-vsnip'
+ Plug 'hrsh7th/vim-vsnip'
end
call plug#end()
" crystaline conf
+"
" metals status
function! MetalsStatus() abort
@@ -116,7 +124,8 @@ let g:crystalline_theme = 'gruvbox'
set laststatus=2
-"" vim-autoformat (C-F5)
+" vim-autoformat (C-F5)
+"
noremap <F29> :Autoformat<CR>
au BufWrite *.py,*.c,*.h,*.cpp,*.hs :Autoformat
@@ -153,11 +162,13 @@ set updatetime=500
set autoread
au BufEnter,CursorHold,CursorHoldI * silent! checktime
-" make easier to open NERDTree
+" NERDTree
+"
map <leader>n :NERDTreeToggle<CR>
let NERDTreeQuitOnOpen=1
-" make easier to use telescope
+" Telescope
+"
nnoremap <leader>f <cmd>Telescope find_files<CR>
nnoremap <leader>fb <cmd>Telescope buffers<CR>
@@ -166,11 +177,13 @@ nnoremap <leader>fb <cmd>Telescope buffers<CR>
let g:loaded_gentags#ctags = 1
" vimwiki
+"
let g:vimwiki_list = [{'path': '~/textfiles/',
\ 'syntax': 'markdown', 'ext': '.md'}]
let g:vimwiki_global_ext = 0
" vim-markdown
+"
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_conceal_code_blocks = 0
@@ -179,6 +192,11 @@ autocmd FileType markdown setlocal conceallevel=2
" LSC conf
"
let g:lsc_auto_map = {'defaults': v:true, 'FindImplementations': ''}
+let g:lsc_preview_split_direction = "below"
+
+" haskell syntax
+"
+let g:haskell_classic_highlighting = 1
" Required for operations modifying multiple buffers like rename.
set hidden
@@ -189,8 +207,6 @@ set shortmess+=c
" for lsc erros
set shortmess-=F
-let g:lsc_preview_split_direction = "below"
-
" disable preview when doing auto-complete
set completeopt-=preview
@@ -198,6 +214,6 @@ set completeopt-=preview
highlight link lscDiagnosticError GruvboxRedSign
highlight link lscDiagnosticWarning GruvboxYellowSign
-" haskell syntax
-let g:haskell_classic_highlighting = 1
+" Set completeopt to have a better completion experience
+set completeopt=menuone,noinsert,noselect