commit 871cc8515bd47a072dfeddca7231318f069fa2cb
parent b8db67444428be0ba7a061a447095567bf101a49
Author: tongong <tongong@gmx.net>
Date: Sun, 13 Feb 2022 14:26:36 +0100
[nvim] added treesitter and lsp support
Diffstat:
3 files changed, 69 insertions(+), 5 deletions(-)
diff --git a/config/nvim/colors/dim.vim b/config/nvim/colors/dim.vim
@@ -135,3 +135,7 @@ highligh SpellLocal ctermfg=0 ctermbg=1
highlight clear Error
highlight Error ctermfg=0 ctermbg=1
highlight Todo ctermfg=0 ctermbg=3
+
+"### AUTO-COMPLETION ###################################################
+highlight Pmenu ctermfg=15 ctermbg=8
+highlight Pmenusel ctermfg=8 ctermbg=3
diff --git a/config/nvim/init.vim b/config/nvim/init.vim
@@ -44,26 +44,38 @@ set hidden " keep buffers open in background
set scrolloff=8
set updatetime=100 " for vim-gitgutter
+set completeopt=menu,menuone,noselect,preview
+set pumheight=10
"### PLUGINS ###############################################################
call plug#begin('~/.vim/plugged')
-Plug 'ARM9/arm-syntax-vim'
Plug 'airblade/vim-gitgutter'
-Plug 'ap/vim-css-color'
Plug 'axvr/zepl.vim'
Plug 'embear/vim-localvimrc'
Plug 'godlygeek/tabular'
-Plug 'guns/vim-clojure-static'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/goyo.vim'
Plug 'mbbill/undotree'
-Plug 'tpope/vim-classpath'
Plug 'tpope/vim-commentary'
-Plug 'tpope/vim-fireplace'
Plug 'tpope/vim-fugitive'
+Plug 'ARM9/arm-syntax-vim'
+Plug 'ap/vim-css-color'
+Plug 'guns/vim-clojure-static'
+Plug 'tpope/vim-classpath'
+Plug 'tpope/vim-fireplace'
+
+Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
+
+Plug 'neovim/nvim-lspconfig'
+Plug 'hrsh7th/cmp-nvim-lsp'
+Plug 'hrsh7th/cmp-path'
+Plug 'hrsh7th/nvim-cmp'
+Plug 'hrsh7th/cmp-vsnip'
+Plug 'hrsh7th/vim-vsnip'
+
call plug#end()
@@ -112,6 +124,8 @@ source $HOME/.config/nvim/notes.vim
source $HOME/.config/nvim/init-private.vim
+lua require("config")
+
"### REMAPS ################################################################
let mapleader = " "
" without this gitgutter overwrites <leader>h... making <leader>h unusable
@@ -185,6 +199,12 @@ function! NextClosedFold(dir)
endif
endfunction
+" snippets for autocomplete
+imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
+smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
+imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
+smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
+
"### AUTOCOMMANDS ##########################################################
fun! TrimWhitespace()
diff --git a/config/nvim/lua/config.lua b/config/nvim/lua/config.lua
@@ -0,0 +1,40 @@
+require("nvim-treesitter.configs").setup {
+ ensure_installed = "maintained",
+ highlight = {
+ enable = true,
+ },
+}
+
+-- Setup nvim-cmp.
+local cmp = require'cmp'
+
+cmp.setup({
+ snippet = {
+ expand = function(args)
+ vim.fn["vsnip#anonymous"](args.body)
+ end,
+ },
+ mapping = {
+ ['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
+ ['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
+ ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
+ ['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
+ ['<C-e>'] = cmp.mapping({
+ i = cmp.mapping.abort(),
+ c = cmp.mapping.close(),
+ }),
+ ['<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' },
+ }, {
+ { name = 'buffer' },
+ })
+})
+
+-- Setup lspconfig.
+local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
+require('lspconfig')["ccls"].setup { capabilities = capabilities }
+require('lspconfig')["texlab"].setup { capabilities = capabilities }
+require('lspconfig')["tsserver"].setup { capabilities = capabilities }