summaryrefslogtreecommitdiff
path: root/neovim
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2021-11-11 22:29:38 +0100
committerDaniel Schadt <kingdread@gmx.de>2021-11-11 22:29:38 +0100
commit09e8d2934a225851676c9fe60c47dcac9bb9135f (patch)
treeb1700aa332a66984219db1789dbd648234029697 /neovim
parent0d22a4b855bf1d772a1db1a26b6af4b7898cb942 (diff)
downloaddotfiles-09e8d2934a225851676c9fe60c47dcac9bb9135f.tar.gz
dotfiles-09e8d2934a225851676c9fe60c47dcac9bb9135f.tar.bz2
dotfiles-09e8d2934a225851676c9fe60c47dcac9bb9135f.zip
nvim: cleanup config a bit
Diffstat (limited to 'neovim')
-rw-r--r--neovim/.config/nvim/init.vim103
1 files changed, 48 insertions, 55 deletions
diff --git a/neovim/.config/nvim/init.vim b/neovim/.config/nvim/init.vim
index 3ee0203..55a209e 100644
--- a/neovim/.config/nvim/init.vim
+++ b/neovim/.config/nvim/init.vim
@@ -36,6 +36,8 @@ call plug#begin('~/.config/nvim/plugged')
" Now the actual plugins:
Plug 'ntpeters/vim-better-whitespace'
+
+" Nice support for latex files
Plug 'lervag/vimtex'
" Override configs by directory
@@ -63,33 +65,24 @@ Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Code and files fuzzy finder
-" Plug 'ctrlpvim/ctrlp.vim'
-" Extension to ctrlp, for fuzzy command finder
-" Plug 'fisadev/vim-ctrlp-cmdpalette'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
-" Pending tasks list
-Plug 'fisadev/FixedTaskList.vim'
-
-" Async autocompletion
-"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
-" Completion from other opened files
-"Plug 'Shougo/context_filetype.vim'
-" Python autocompletion
-"Plug 'zchee/deoplete-jedi', { 'do': ':UpdateRemotePlugins' }
-" Just to add the python go-to-definition and similar features, autocompletion
-" from this plugin is disabled
-"Plug 'davidhalter/jedi-vim'
-
+" Pre-built configurations for the neovim LSP client
Plug 'neovim/nvim-lspconfig'
+" List all symbols in the file
Plug 'simrat39/symbols-outline.nvim'
+" Statusline information about the LS state
Plug 'nvim-lua/lsp-status.nvim'
-" Automatically close parenthesis, etc
-"Plug 'Townk/vim-autoclose'
+" Autocomplete, may switch to COQ in the future
+Plug 'hrsh7th/cmp-nvim-lsp', {'branch' : 'main'}
+Plug 'hrsh7th/cmp-path', {'branch' : 'main'}
+Plug 'hrsh7th/nvim-cmp', {'branch' : 'main'}
+Plug 'hrsh7th/cmp-vsnip', {'branch' : 'main'}
+Plug 'hrsh7th/vim-vsnip'
" Surround
Plug 'tpope/vim-surround'
@@ -115,26 +108,15 @@ Plug 'lilydjwg/colorizer'
" Window chooser
Plug 't9md/vim-choosewin'
-" Automatically sort python imports
-Plug 'fisadev/vim-isort'
-
" Highlight matching html tags
Plug 'valloric/MatchTagAlways'
-" Generate html in a simple way
-Plug 'mattn/emmet-vim'
-
" Git integration
Plug 'tpope/vim-fugitive'
" Git/mercurial/others diff icons on the side of the file lines
Plug 'mhinz/vim-signify'
-" Linters
-"Plug 'neomake/neomake'
-" TODO is it running on save? or when?
-" TODO not detecting errors, just style, is it using pylint?
-
" Relative numbering of lines (0 is the current line)
" (disabled by default because is very intrusive and can't be easily toggled
" on/off. When the plugin is present, will always activate the relative
@@ -151,6 +133,7 @@ Plug 'rust-lang/rust.vim'
call plug#end()
lua << EOF
+-- Setup LSP status to display the number of diagnostics in the statusbar
local lsp_status = require('lsp-status')
local kind_labels_mt = {__index = function(_, k) return k end}
local kind_labels = {}
@@ -158,6 +141,7 @@ setmetatable(kind_labels, kind_labels_mt)
lsp_status.register_progress()
lsp_status.config({
+ current_function = false,
kind_labels = kind_labels,
indicator_errors = "×",
indicator_warnings = "!",
@@ -168,6 +152,38 @@ lsp_status.config({
status_symbol = "",
})
+-- Setup nvim-cmp.
+local cmp = require'cmp'
+
+cmp.setup({
+ completion = {
+ autocomplete = false,
+ },
+ snippet = {
+ -- REQUIRED - you must specify a snippet engine
+ expand = function(args)
+ vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
+ end,
+ },
+ mapping = {
+ ['<C-d>'] = 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 }),
+ },
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ }, {
+ { name = 'path' },
+ })
+})
+
+-- Setup the actual language servers
local nvim_lsp = require('lspconfig')
-- Use an on_attach function to only map the following keys
@@ -182,8 +198,6 @@ local on_attach = function(client, bufnr)
-- Mappings.
local opts = { noremap=true, silent=true }
- buf_set_keymap('i', '<c-space>', '<c-x><c-o>', opts)
-
-- 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)
@@ -208,14 +222,14 @@ end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
-local servers = { 'clangd', 'hls', 'rust_analyzer' }
+local servers = { 'clangd', 'hls', 'rust_analyzer', 'texlab' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
flags = {
debounce_text_changes = 150,
},
- capabilities = lsp_status.capabilities
+ capabilities = require('cmp_nvim_lsp').update_capabilities(lsp_status.capabilities)
}
end
@@ -232,15 +246,6 @@ call airline#parts#define_condition('lsp_status', 'luaeval("#vim.lsp.buf_get_cli
let g:airline#extensions#nvimlsp#enabled = 0
let g:airline_section_warning = airline#section#create_right(['lsp_status'])
-
-" ============================================================================
-" Install plugins the first time vim runs
-
-if vim_plug_just_installed
- echo "Installing Bundles, please ignore key map error messages"
- :PlugInstall
-endif
-
" ============================================================================
" Vim settings and mappings
" You can edit them as you wish
@@ -299,15 +304,6 @@ nmap ,t :NERDTreeFind<CR>
" don;t show these file types
let NERDTreeIgnore = ['\.pyc$', '\.pyo$']
-" Tasklist ------------------------------
-
-" show pending tasks list
-map <F2> :TaskList<CR>
-
-" Neomake ------------------------------
-
-" Run linter on write
-"autocmd! BufWritePost * Neomake
" Fzf ------------------------------
@@ -345,7 +341,7 @@ nmap ,c :Commands<CR>
" Ack.vim ------------------------------
" mappings
-nmap ,r :Ack
+nmap ,r :Ack
nmap ,wr :Ack <cword><CR>
" Window Chooser ------------------------------
@@ -410,6 +406,3 @@ function PrintFile(fname)
return v:shell_error
endfunction
set printexpr=PrintFile(v:fname_in)
-
-" TUT:
-" color murphy