working nvim config with nice autocomplete
This commit is contained in:
parent
64056cd4a9
commit
cc77bf697a
|
@ -21,18 +21,8 @@ let
|
|||
sha256 = "000000000000000000000000PJ023iJyMz6vak3qh4=";
|
||||
};
|
||||
};
|
||||
taskwiki-t = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
||||
pname = "taskwiki";
|
||||
version = "2021-09-22";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "tools-life";
|
||||
repo = "taskwiki";
|
||||
rev = "c4392c36c01cfffcb06f460d722990b98bc53bdb";
|
||||
sha256 = "QrxFqu/Y6FykXGqIlK52+nDwmnBhubURl6v2Zc/KwPw=";
|
||||
};
|
||||
meta.homepage = "https://github.com/tools-life/taskwiki/";
|
||||
};
|
||||
};
|
||||
|
||||
my-python-packages = python-packages: with python-packages; [
|
||||
tasklib
|
||||
pynvim
|
||||
|
@ -65,6 +55,7 @@ in
|
|||
configure = {
|
||||
packages.myPlugins = with pkgs.vimPlugins; {
|
||||
start = [
|
||||
# general
|
||||
vim-nix
|
||||
fzf-vim
|
||||
vim-elixir
|
||||
|
@ -77,6 +68,9 @@ in
|
|||
rainbow_parentheses-vim
|
||||
vim-surround
|
||||
vim-devicons
|
||||
nvim-web-devicons
|
||||
direnv-vim
|
||||
|
||||
# kitaab stuff
|
||||
vimwiki
|
||||
taskwiki
|
||||
|
@ -84,6 +78,7 @@ in
|
|||
telescope-nvim
|
||||
plenary-nvim
|
||||
bufferline-nvim
|
||||
|
||||
# lsp stuff
|
||||
ale
|
||||
nvim-lspconfig
|
||||
|
@ -94,10 +89,15 @@ in
|
|||
cmp-buffer
|
||||
cmp-tabnine
|
||||
lspkind-nvim
|
||||
cmp-path
|
||||
cmp-spell
|
||||
nvim-autopairs
|
||||
|
||||
# git stuff
|
||||
vim-fugitive
|
||||
gitsigns-nvim
|
||||
fzf-checkout-vim
|
||||
|
||||
# Clojure stuff
|
||||
conjure
|
||||
vim-sexp
|
||||
|
@ -133,6 +133,22 @@ in
|
|||
|
||||
" set spell
|
||||
set spelllang=en_gb
|
||||
set ignorecase
|
||||
set smartcase
|
||||
set incsearch
|
||||
" if hidden is not set, TextEdit might fail.
|
||||
set hidden
|
||||
" Some servers have issues with backup files, see #649
|
||||
set nobackup
|
||||
set nowritebackup
|
||||
" Better display for messages
|
||||
set cmdheight=2
|
||||
" You will have bad experience for diagnostic messages when it's default 4000.
|
||||
set updatetime=300
|
||||
" don't give |ins-completion-menu| messages.
|
||||
set shortmess+=c
|
||||
" always show signcolumns
|
||||
set signcolumn=yes
|
||||
|
||||
" window
|
||||
nmap <leader>wh :topleft vnew<CR>
|
||||
|
@ -168,6 +184,7 @@ in
|
|||
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
|
||||
nnoremap <leader>fb <cmd>Telescope buffers<cr>
|
||||
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
|
||||
nnoremap <leader>ft <cmd>Telescope tags<cr>
|
||||
|
||||
" exit normal mode in terminal
|
||||
:tnoremap <C-n> <C-\><C-n>
|
||||
|
@ -176,7 +193,7 @@ in
|
|||
" let g:sexp_filetypes = [ "fennel" ]
|
||||
|
||||
let g:rainbow_active = 0
|
||||
autocmd BufReadPost,BufNewFile c,py,nix RainbowParenthesesToggleAll
|
||||
autocmd BufReadPost,BufNewFile c,clj,cljs RainbowParenthesesToggleAll
|
||||
|
||||
" general commands
|
||||
map <leader>t :NERDTreeToggle<CR>
|
||||
|
@ -234,29 +251,9 @@ in
|
|||
" fzf
|
||||
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 } }
|
||||
|
||||
" ALE + clj-kondo
|
||||
" ALE
|
||||
let g:ale_linters = {'clojure': ['clj-kondo'], 'python': ['black', 'pylint']}
|
||||
|
||||
" if hidden is not set, TextEdit might fail.
|
||||
set hidden
|
||||
|
||||
" Some servers have issues with backup files, see #649
|
||||
set nobackup
|
||||
set nowritebackup
|
||||
|
||||
" Better display for messages
|
||||
set cmdheight=2
|
||||
|
||||
" You will have bad experience for diagnostic messages when it's default 4000.
|
||||
set updatetime=300
|
||||
|
||||
" don't give |ins-completion-menu| messages.
|
||||
set shortmess+=c
|
||||
|
||||
" always show signcolumns
|
||||
set signcolumn=yes
|
||||
|
||||
|
||||
" lsp commands
|
||||
nnoremap <leader>vd :lua vim.lsp.buf.definition()<CR>
|
||||
nnoremap <leader>vi :lua vim.lsp.buf.implementation()<CR>
|
||||
|
@ -277,51 +274,80 @@ in
|
|||
" lua config
|
||||
lua <<EOF
|
||||
-- Setup nvim-cmp.
|
||||
local cmp = require'cmp'
|
||||
cmp.setup({
|
||||
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 = 'buffer' },
|
||||
})
|
||||
})
|
||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' },
|
||||
{ name = "nvim_lsp"},
|
||||
{ name = "path" },
|
||||
{ name = 'conjure'},
|
||||
{ name = 'cmp_tabnine'},
|
||||
}
|
||||
})
|
||||
-- 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' }
|
||||
})
|
||||
})
|
||||
local cmp = require('cmp')
|
||||
local t = function(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
end
|
||||
local check_back_space = function()
|
||||
local col = vim.fn.col(".") - 1
|
||||
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") ~= nil
|
||||
end
|
||||
cmp.setup {
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
-- fancy icons and a name of kind
|
||||
vim_item.kind = require("lspkind").presets.default[vim_item.kind] ..
|
||||
" " .. vim_item.kind
|
||||
-- set a name for each source
|
||||
vim_item.menu = ({
|
||||
buffer = "[Buffer]",
|
||||
nvim_lsp = "[LSP]",
|
||||
cmp_tabnine = "[TabNine]",
|
||||
look = "[Look]",
|
||||
path = "[Path]",
|
||||
spell = "[Spell]",
|
||||
calc = "[Calc]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end
|
||||
},
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {"i", "s"}),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = {
|
||||
{name = 'buffer'}, {name = 'nvim_lsp'},
|
||||
{name = "look"}, {name = "path"},
|
||||
{name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"},
|
||||
{name = 'cmp-conjure'}
|
||||
},
|
||||
completion = {completeopt = 'menu,menuone,noinsert'}
|
||||
}
|
||||
-- TabNine cmp
|
||||
local tabnine = require('cmp_tabnine.config')
|
||||
tabnine:setup({max_lines = 1000, max_num_results = 20, sort = true})
|
||||
|
||||
-- Setup lspconfig.
|
||||
-- local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
-- require'lspconfig'nvim_lsp.setup {}
|
||||
-- require'lspconfig'clojure_lsp.setup {}
|
||||
-- require'lspconfig'rnix.setup {}
|
||||
-- require'lspconfig'pylsp.setup {}
|
||||
-- require'lspconfig'terraform_lsp.setup {}
|
||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
require'lspconfig'nvim_lsp.setup {}
|
||||
require'lspconfig'clojure_lsp.setup {}
|
||||
require'lspconfig'rnix.setup {}
|
||||
require'lspconfig'pylsp.setup {}
|
||||
require'lspconfig'terraform_lsp.setup {}
|
||||
|
||||
-- Bufferline
|
||||
require('bufferline').setup {}
|
||||
|
|
Loading…
Reference in a new issue