mirror of
https://github.com/kmein/niveum
synced 2026-03-20 03:51:07 +01:00
feat(neovim): completion via cmp
This commit is contained in:
@@ -1,3 +1,39 @@
|
|||||||
|
local cmp = require'cmp'
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
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 = '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' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
|
||||||
local opts = { noremap=true, silent=true }
|
local opts = { noremap=true, silent=true }
|
||||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||||
@@ -37,18 +73,18 @@ local lsp_flags = {
|
|||||||
|
|
||||||
language_servers = {
|
language_servers = {
|
||||||
pyright = {}, -- pyright
|
pyright = {}, -- pyright
|
||||||
-- tsserver = {}, -- typescript-language-server
|
tsserver = {}, -- typescript-language-server
|
||||||
-- elmls = {}, -- elm-language-server
|
elmls = {}, -- elm-language-server
|
||||||
-- denols = {}, -- deno built in
|
-- denols = {}, -- deno built in
|
||||||
-- bashls = {}, -- bash-language-server
|
-- bashls = {}, -- bash-language-server
|
||||||
hls = {}, -- haskell-language-server
|
hls = {}, -- haskell-language-server
|
||||||
-- html = {}, -- vscode-langservers-extracted
|
html = {}, -- vscode-langservers-extracted
|
||||||
-- jsonls = {}, -- vscode-langservers-extracted
|
jsonls = {}, -- vscode-langservers-extracted
|
||||||
nil_ls = {}, -- github:oxalica/nil
|
nil_ls = {}, -- github:oxalica/nil
|
||||||
-- rnix = {}, -- rnix-lsp
|
-- rnix = {}, -- rnix-lsp
|
||||||
-- jqls = {}, -- jq-lsp
|
-- jqls = {}, -- jq-lsp
|
||||||
rust_analyzer = { ["rust-analyzer"] = {} },
|
rust_analyzer = { ["rust-analyzer"] = {} },
|
||||||
-- eslint?
|
eslint = {},
|
||||||
-- volar? vls?
|
-- volar? vls?
|
||||||
texlab = {
|
texlab = {
|
||||||
texlab = {
|
texlab = {
|
||||||
@@ -82,5 +118,6 @@ for server, settings in pairs(language_servers) do
|
|||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
flags = lsp_flags,
|
flags = lsp_flags,
|
||||||
settings = settings,
|
settings = settings,
|
||||||
|
capabilities = capabilities
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ noremap <leader>i mzgg=G`z
|
|||||||
" replace all
|
" replace all
|
||||||
nnoremap S :%s//g<Left><Left>
|
nnoremap S :%s//g<Left><Left>
|
||||||
|
|
||||||
nnoremap <Leader>a <Plug>(ale_hover)
|
|
||||||
nnoremap <Leader>d <Plug>(ale_go_to_definition_in_tab)
|
|
||||||
nnoremap <Leader>rf <Plug>(ale_find_references)
|
|
||||||
|
|
||||||
" Hit `%` on `if` to jump to `else`.
|
" Hit `%` on `if` to jump to `else`.
|
||||||
runtime macros/matchit.vim
|
runtime macros/matchit.vim
|
||||||
|
|
||||||
@@ -67,6 +63,16 @@ set foldlevelstart=30
|
|||||||
iabbrev ddate <C-R>=strftime("%F")<CR>
|
iabbrev ddate <C-R>=strftime("%F")<CR>
|
||||||
iabbrev dtime <C-R>=strftime("%F %T")<CR>
|
iabbrev dtime <C-R>=strftime("%F %T")<CR>
|
||||||
|
|
||||||
|
fun! TrimWhitespace()
|
||||||
|
let l:save = winsaveview()
|
||||||
|
keeppatterns %s/\s\+$//e
|
||||||
|
call winrestview(l:save)
|
||||||
|
endfun
|
||||||
|
command! TrimWhitespace call TrimWhitespace()
|
||||||
|
autocmd BufWritePre * if !&binary && &ft !=# 'mail'
|
||||||
|
\| call TrimWhitespace()
|
||||||
|
\| endif
|
||||||
|
|
||||||
let g:netrw_banner=0
|
let g:netrw_banner=0
|
||||||
let g:netrw_browse_split=4
|
let g:netrw_browse_split=4
|
||||||
let g:netrw_altv=1 " open splits to the right
|
let g:netrw_altv=1 " open splits to the right
|
||||||
@@ -152,8 +158,6 @@ autocmd bufreadpre * setlocal foldmethod=indent
|
|||||||
set completeopt=noinsert,menuone,noselect
|
set completeopt=noinsert,menuone,noselect
|
||||||
set complete+=kspell
|
set complete+=kspell
|
||||||
|
|
||||||
let g:SuperTabDefaultCompletionType = 'context'
|
|
||||||
|
|
||||||
let g:haskell_enable_quantification = 1
|
let g:haskell_enable_quantification = 1
|
||||||
let g:haskell_enable_recursivedo = 1
|
let g:haskell_enable_recursivedo = 1
|
||||||
let g:haskell_enable_arrowsyntax = 1
|
let g:haskell_enable_arrowsyntax = 1
|
||||||
@@ -162,34 +166,3 @@ let g:haskell_enable_pattern_synonyms = 1
|
|||||||
let g:pandoc#syntax#conceal#use = 0
|
let g:pandoc#syntax#conceal#use = 0
|
||||||
let g:pandoc#modules#disabled = []
|
let g:pandoc#modules#disabled = []
|
||||||
let g:pandoc#spell#default_langs = ['en', 'de']
|
let g:pandoc#spell#default_langs = ['en', 'de']
|
||||||
|
|
||||||
let g:ale_linters = {
|
|
||||||
\ 'css': ['csslint'],
|
|
||||||
\ 'haskell': ['ghc', 'cabal-ghc', 'hlint', 'ormolu'],
|
|
||||||
\ 'html': ['tidy', 'proselint'],
|
|
||||||
\ 'latex': ['lacheck', 'chktex', 'proselint'],
|
|
||||||
\ 'pandoc': ['proselint'],
|
|
||||||
\ 'ruby': ['rubocop'],
|
|
||||||
\ 'json': ['jsonlint'],
|
|
||||||
\ 'rust': ['cargo'],
|
|
||||||
\ 'python': ['pyls'],
|
|
||||||
\}
|
|
||||||
let g:ale_fixers = {
|
|
||||||
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
|
||||||
\ 'javascript': ['prettier'],
|
|
||||||
\ 'typescript': ['prettier'],
|
|
||||||
\ 'css': ['prettier'],
|
|
||||||
\ 'html': ['prettier'],
|
|
||||||
\ 'json': ['jq'],
|
|
||||||
\ 'python': ['black'],
|
|
||||||
\ 'rust': ['rustfmt']
|
|
||||||
\}
|
|
||||||
let g:ale_set_quickfix = 1
|
|
||||||
|
|
||||||
let g:ale_fix_on_save = 1
|
|
||||||
autocmd bufnewfile,bufread elm.json let g:ale_fix_on_save = 0
|
|
||||||
|
|
||||||
let g:ale_completion_enabled = 1
|
|
||||||
|
|
||||||
let g:vimwiki_list = [{'path': '~/notes/',
|
|
||||||
\ 'syntax': 'markdown', 'ext': '.md'}]
|
|
||||||
|
|||||||
@@ -8,13 +8,18 @@
|
|||||||
}: (neovim.override {
|
}: (neovim.override {
|
||||||
configure = {
|
configure = {
|
||||||
customRC = ''
|
customRC = ''
|
||||||
source ${../lib/vim/init.vim}
|
|
||||||
|
|
||||||
luafile ${../lib/vim/init.lua}
|
luafile ${../lib/vim/init.lua}
|
||||||
|
|
||||||
|
source ${../lib/vim/init.vim}
|
||||||
'';
|
'';
|
||||||
packages.nvim = with vimPlugins; {
|
packages.nvim = with vimPlugins; {
|
||||||
start = [
|
start = [
|
||||||
ale
|
nvim-cmp
|
||||||
|
cmp-buffer
|
||||||
|
cmp-path
|
||||||
|
cmp-nvim-lsp
|
||||||
|
cmp-cmdline
|
||||||
|
|
||||||
fzf-vim
|
fzf-vim
|
||||||
fzfWrapper
|
fzfWrapper
|
||||||
supertab
|
supertab
|
||||||
|
|||||||
Reference in New Issue
Block a user