nvim 0.5 plugins
This commit is contained in:
parent
0170055efb
commit
97d8d3d0b4
|
@ -9,3 +9,5 @@ universal-ctags
|
|||
{% if not termux %}
|
||||
highlight
|
||||
{% endif %}
|
||||
{# For nvim's :Telescope live_grep #}
|
||||
ripgrep
|
||||
|
|
|
@ -67,10 +67,15 @@ filetype on
|
|||
filetype plugin on
|
||||
filetype indent on
|
||||
|
||||
set wildmode=longest,list
|
||||
set wildmode=longest:full,full
|
||||
set wildmenu
|
||||
set showcmd
|
||||
|
||||
" Completion
|
||||
|
||||
" Avoid showing message extra message when using completion
|
||||
set shortmess+=c
|
||||
|
||||
" Close the file explorer once you select a file
|
||||
let g:netrw_fastbrowse = 0
|
||||
|
||||
|
|
|
@ -7,13 +7,17 @@
|
|||
" END PLUGIN CONFIG {{ name }}
|
||||
{%- endmacro -%}
|
||||
|
||||
" Theming
|
||||
" Visuals
|
||||
{{ use_plugin('base16') }}
|
||||
{{ use_plugin('airline') }}
|
||||
{{ use_plugin('devicons') }}
|
||||
|
||||
" Goto utilities
|
||||
{% if variant == 'nvim' %}
|
||||
{{ use_plugin('telescope') }}
|
||||
{% else %}
|
||||
{{ use_plugin('fzf') }}
|
||||
{% endif %}
|
||||
|
||||
" Search/replace
|
||||
{{ use_plugin('abolish') }}
|
||||
|
@ -31,11 +35,27 @@
|
|||
{{ use_plugin('vista') }}
|
||||
|
||||
" Language Server Client
|
||||
{% if variant == 'nvim' %}
|
||||
{{ use_plugin('nvim_lspconfig') }}
|
||||
{% else %}
|
||||
{{ use_plugin('vim_lsp') }}
|
||||
{% endif %}
|
||||
|
||||
" Treesitter
|
||||
{% if variant == 'nvim' %}
|
||||
{{ use_plugin('treesitter') }}
|
||||
{% endif %}
|
||||
|
||||
" Snippets
|
||||
{{ use_plugin('vsnip') }}
|
||||
|
||||
" Auto-completion
|
||||
{% if variant == 'nvim' %}
|
||||
{{ use_plugin('nvim_compe') }}
|
||||
{% else %}
|
||||
{{ use_plugin('deoplete') }}
|
||||
{{ use_plugin('supertab') }}
|
||||
{% endif %}
|
||||
|
||||
" Undo management
|
||||
{{ use_plugin('undotree') }}
|
||||
|
@ -51,9 +71,11 @@
|
|||
{% if 'c' in dev_stuffs or 'c++' in dev_stuffs %}
|
||||
{{ use_plugin('vebugger') }}
|
||||
{% endif %}
|
||||
{#
|
||||
{% if 'python' in dev_stuffs and variant == 'nvim' %}
|
||||
{{ use_plugin('semshi') }}
|
||||
{% endif %}
|
||||
#}
|
||||
{% if 'ansible' in dev_stuffs %}
|
||||
{{ use_plugin('ansible') }}
|
||||
{% endif %}
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
{#
|
||||
" nvim plugin doesn't support terminal colors
|
||||
{% if variant == 'nvim' %}
|
||||
{{ add_source('RRethy/nvim-base16') -}}
|
||||
{% else %}
|
||||
#}
|
||||
{{ add_source('chriskempson/base16-vim') -}}
|
||||
{#
|
||||
{% endif %}
|
||||
#}
|
||||
colorscheme base16-default-dark
|
||||
|
||||
" let base16colorspace=256
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{% if variant == 'nvim' %}
|
||||
{{ add_source('kyazdani42/nvim-web-devicons') -}}
|
||||
{% else %}
|
||||
{{ add_source('ryanoasis/vim-devicons') -}}
|
||||
{% endif %}
|
84
config/automatrop/roles/vim/templates/plugins/nvim_compe.j2
Normal file
84
config/automatrop/roles/vim/templates/plugins/nvim_compe.j2
Normal file
|
@ -0,0 +1,84 @@
|
|||
{{ add_source('hrsh7th/nvim-compe') -}}
|
||||
{# I'm a bit lost with all this, so this is the default recommended config,
|
||||
using vim-vsnip because the proposed configuration for tab-completion uses it, so… #}
|
||||
lua << EOF
|
||||
require'compe'.setup {
|
||||
enabled = true;
|
||||
autocomplete = true;
|
||||
debug = false;
|
||||
min_length = 1;
|
||||
preselect = 'enable';
|
||||
throttle_time = 80;
|
||||
source_timeout = 200;
|
||||
resolve_timeout = 800;
|
||||
incomplete_delay = 400;
|
||||
max_abbr_width = 100;
|
||||
max_kind_width = 100;
|
||||
max_menu_width = 100;
|
||||
documentation = {
|
||||
border = { '', '' ,'', ' ', '', '', '', ' ' }, -- the border option is the same as `|help nvim_open_win|`
|
||||
winhighlight = "NormalFloat:CompeDocumentation,FloatBorder:CompeDocumentationBorder",
|
||||
max_width = 120,
|
||||
min_width = 60,
|
||||
max_height = math.floor(vim.o.lines * 0.3),
|
||||
min_height = 1,
|
||||
};
|
||||
|
||||
source = {
|
||||
path = true;
|
||||
buffer = true;
|
||||
calc = true;
|
||||
nvim_lsp = true;
|
||||
vsnip = true;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
set completeopt=menuone,noselect
|
||||
|
||||
|
||||
inoremap <silent><expr> <C-Space> compe#complete()
|
||||
inoremap <silent><expr> <CR> compe#confirm('<CR>')
|
||||
inoremap <silent><expr> <C-e> compe#close('<C-e>')
|
||||
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
|
||||
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
|
||||
|
||||
lua << EOF
|
||||
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
|
||||
|
||||
-- Use (s-)tab to:
|
||||
--- move to prev/next item in completion menuone
|
||||
--- jump to prev/next snippet's placeholder
|
||||
_G.tab_complete = function()
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
return t "<C-n>"
|
||||
elseif vim.fn['vsnip#available'](1) == 1 then
|
||||
return t "<Plug>(vsnip-expand-or-jump)"
|
||||
elseif check_back_space() then
|
||||
return t "<Tab>"
|
||||
else
|
||||
return vim.fn['compe#complete']()
|
||||
end
|
||||
end
|
||||
_G.s_tab_complete = function()
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
return t "<C-p>"
|
||||
elseif vim.fn['vsnip#jumpable'](-1) == 1 then
|
||||
return t "<Plug>(vsnip-jump-prev)"
|
||||
else
|
||||
-- If <S-Tab> is not working in your terminal, change it to <C-h>
|
||||
return t "<S-Tab>"
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
EOF
|
|
@ -0,0 +1,70 @@
|
|||
{# LSP client for neovim ≥ 0.5 #}
|
||||
{{ add_source('neovim/nvim-lspconfig') -}}
|
||||
lua << EOF
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
-- disable virtual text
|
||||
virtual_text = false,
|
||||
|
||||
-- show signs
|
||||
signs = true,
|
||||
|
||||
-- delay update diagnostics
|
||||
update_in_insert = false,
|
||||
}
|
||||
)
|
||||
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
|
||||
--Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
-- 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)
|
||||
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', '<C-K>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
-- buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>d', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||
buf_set_keymap("v", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR><Esc>", opts)
|
||||
|
||||
end
|
||||
|
||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||
-- map buffer local keybindings when the language server attaches
|
||||
local servers = {
|
||||
{% if 'python' in dev_stuffs %}
|
||||
"pyls",
|
||||
{% endif %}
|
||||
}
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
EOF
|
|
@ -1,4 +1,7 @@
|
|||
{# Use TAB for autocompletion #}
|
||||
{{ add_source('ervandew/supertab') -}}
|
||||
let g:SuperTabLongestEnhanced = 1
|
||||
let g:SuperTabLongestHighlight = 1
|
||||
{# TODO longest doesn't work, even when longest is set in completeopt #}
|
||||
let g:SuperTabDefaultCompletionType = "<c-n>" " Go down when completing
|
||||
let g:SuperTabContextDefaultCompletionType = "<c-n>"
|
||||
|
|
39
config/automatrop/roles/vim/templates/plugins/telescope.j2
Normal file
39
config/automatrop/roles/vim/templates/plugins/telescope.j2
Normal file
|
@ -0,0 +1,39 @@
|
|||
{{ add_source('nvim-telescope/telescope.nvim') -}}
|
||||
{# Dependencies #}
|
||||
{{ add_source('nvim-lua/popup.nvim') -}}
|
||||
{{ add_source('nvim-lua/plenary.nvim') -}}
|
||||
|
||||
noremap gF <cmd>Telescope find_files<cr>
|
||||
noremap gf <cmd>Telescope git_files<cr>
|
||||
noremap gb <cmd>Telescope buffers<cr>
|
||||
noremap gl <cmd>Telescope current_buffer_fuzzy_find<cr>
|
||||
noremap gL <cmd>Telescope live_grep<cr>
|
||||
noremap gT <cmd>Telescope tags<cr>
|
||||
noremap gt <cmd>Telescope treesitter<cr>
|
||||
noremap gm <cmd>Telescope marks<cr>
|
||||
noremap gh <cmd>Telescope oldfiles<cr>
|
||||
noremap gH <cmd>Telescope command_history<cr>
|
||||
noremap gS <cmd>Telescope search_history<cr>
|
||||
noremap gc <cmd>Telescope commands<cr>
|
||||
noremap gr <cmd>Telescope lsp_references<cr>
|
||||
noremap ga <cmd>Telescope lsp_code_actions<cr>
|
||||
vnoremap ga <cmd>Telescope lsp_range_code_actions<cr>
|
||||
noremap gq <cmd>Telescope lsp_document_diagnostics<cr>
|
||||
noremap gQ <cmd>Telescope lsp_workspace_diagnostics<cr>
|
||||
noremap gd <cmd>Telescope lsp_definitions<cr>
|
||||
|
||||
lua << EOF
|
||||
require('telescope').setup{
|
||||
defaults = {
|
||||
vimgrep_arguments = {
|
||||
'rg',
|
||||
'--color=never',
|
||||
'--no-heading',
|
||||
'--with-filename',
|
||||
'--line-number',
|
||||
'--column',
|
||||
'--smart-case'
|
||||
},
|
||||
}
|
||||
}
|
||||
EOF
|
|
@ -0,0 +1,6 @@
|
|||
{# Allow for better syntax highlighting. Bit experimental #}
|
||||
{{ add_source('nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}) -}}
|
||||
{# To check if it's really working
|
||||
{{ add_source('nvim-treesitter/playground') -}}
|
||||
#}
|
||||
{# TODO Find a way to run `:TSInstall all` non-interactively #}
|
|
@ -4,14 +4,6 @@
|
|||
" (providers are automatically detected thanks to vim-lsp-settings.
|
||||
" You can even install some locally using :LspInstallServer)
|
||||
|
||||
nnoremap gd :LspDefinition<CR>
|
||||
nnoremap gD :LspDeclaration<CR>
|
||||
nnoremap <F3> :LspDocumentFormat<CR>
|
||||
vnoremap <F3> :LspDocumentRangeFormat<CR>
|
||||
nnoremap gE :LspNextDiagnostic<CR>
|
||||
nnoremap ge :LspNextError<CR>
|
||||
nnoremap <F2> :LspRename<CR>
|
||||
|
||||
let g:lsp_signs_enabled = 1
|
||||
let g:lsp_diagnostics_echo_cursor = 1
|
||||
|
||||
|
@ -21,3 +13,27 @@ let g:lsp_signs_information = {'text': 'ℹ'}
|
|||
let g:lsp_signs_hint = {'text': '?'}
|
||||
|
||||
let g:lsp_highlight_references_enabled = 1
|
||||
|
||||
function! s:on_lsp_buffer_enabled() abort
|
||||
setlocal omnifunc=lsp#complete
|
||||
setlocal signcolumn=yes
|
||||
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
|
||||
nmap <buffer> gd <plug>(lsp-definition)
|
||||
nmap <buffer> gD <plug>(lsp-declaration)
|
||||
nmap <buffer> gr <plug>(lsp-references)
|
||||
nmap <buffer> gi <plug>(lsp-implementation)
|
||||
nmap <buffer> <space>rn <plug>(lsp-rename)
|
||||
nmap <buffer> [d <plug>(lsp-previous-diagnostic)
|
||||
nmap <buffer> ]d <plug>(lsp-next-diagnostic)
|
||||
nmap <buffer> K <plug>(lsp-hover)
|
||||
nmap <buffer> <space>f <plug>(lsp-document-format)
|
||||
vmap <buffer> <space>f <plug>(lsp-document-range-format)
|
||||
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
|
||||
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
|
||||
endfunction
|
||||
|
||||
augroup lsp_install
|
||||
au!
|
||||
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
|
||||
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
|
||||
augroup END
|
||||
|
|
3
config/automatrop/roles/vim/templates/plugins/vsnip.j2
Normal file
3
config/automatrop/roles/vim/templates/plugins/vsnip.j2
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{ add_source('hrsh7th/vim-vsnip') -}}
|
||||
{{ add_source('hrsh7th/vim-vsnip-integ') -}}
|
||||
{{ add_source('rafamadriz/friendly-snippets') -}}
|
Loading…
Reference in a new issue