Feat: comp with tab and lsp for vue python and js
This commit is contained in:
parent
6a15552112
commit
653e869e1c
@ -1,5 +1,5 @@
|
|||||||
" Use completion-nvim in every buffer
|
" Use completion-nvim in every buffer
|
||||||
autocmd BufEnter * lua require'completion'.on_attach()
|
autocmd BufEnter * lua require'nvim-comp'.on_attach()
|
||||||
|
|
||||||
let g:completion_enable_snippet = 'UltiSnips'
|
let g:completion_enable_snippet = 'UltiSnips'
|
||||||
let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
|
let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
|
||||||
|
@ -61,7 +61,7 @@ colorscheme zenburn
|
|||||||
|
|
||||||
" Set completeopt to have a better completion experience
|
" Set completeopt to have a better completion experience
|
||||||
" set completeopt=menuone,noinsert,noselect
|
" set completeopt=menuone,noinsert,noselect
|
||||||
set completeopt=menuone,noselect
|
" set completeopt=menuone,noselect
|
||||||
|
|
||||||
" Avoid showing message extra message when using completion
|
" Avoid showing message extra message when using completion
|
||||||
set shortmess+=c
|
set shortmess+=c
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
source $HOME/.config/nvim/plugins/plugins.vim
|
source $HOME/.config/nvim/plugins/plugins.vim
|
||||||
source $HOME/.config/nvim/general/settings.vim
|
source $HOME/.config/nvim/general/settings.vim
|
||||||
source $HOME/.config/nvim/general/mappings.vim
|
source $HOME/.config/nvim/general/mappings.vim
|
||||||
" source $HOME/.confia/vim/general/completion.vim
|
" source $HOME/.config/nvim/general/completion.vim
|
||||||
|
|
||||||
source $HOME/.config/nvim/plugins/lightline.vim
|
source $HOME/.config/nvim/plugins/lightline.vim
|
||||||
source $HOME/.config/nvim/plugins/nvim-comp.vim
|
source $HOME/.config/nvim/plugins/nvim-comp.vim
|
||||||
@ -10,6 +10,8 @@ lua <<EOF
|
|||||||
require("lsp")
|
require("lsp")
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
" require("comp")
|
||||||
|
|
||||||
" bug fix with telescope and insert mode https://GitHub.com/vim telescope/telescope.vim/issues/82
|
" bug fix with telescope and insert mode https://GitHub.com/vim telescope/telescope.vim/issues/82
|
||||||
autocmd FileType TelescopePrompt
|
autocmd FileType TelescopePrompt
|
||||||
\ call deoplete#custom#buffer_option('auto_complete', v:false)
|
\ call deoplete#custom#buffer_option('auto_complete', v:false)
|
||||||
|
78
nvim/.config/nvim/lua/comp.lua
Normal file
78
nvim/.config/nvim/lua/comp.lua
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
-- Configuration for nvim-compe
|
||||||
|
|
||||||
|
local utils = require('utils')
|
||||||
|
|
||||||
|
vim.cmd [[set shortmess+=c]]
|
||||||
|
utils.opt('o', 'completeopt', 'menuone,noselect')
|
||||||
|
|
||||||
|
require'compe'.setup {
|
||||||
|
enabled = true;
|
||||||
|
autocomplete = true;
|
||||||
|
debug = false;
|
||||||
|
min_length = 1;
|
||||||
|
preselect = 'enable';
|
||||||
|
throttle_time = 80;
|
||||||
|
source_timeout = 200;
|
||||||
|
incomplete_delay = 400;
|
||||||
|
allow_prefix_unmatch = false;
|
||||||
|
max_abbr_width = 1000;
|
||||||
|
max_kind_width = 1000;
|
||||||
|
max_menu_width = 1000000;
|
||||||
|
documentation = true;
|
||||||
|
|
||||||
|
|
||||||
|
source = {
|
||||||
|
path = true;
|
||||||
|
buffer = true;
|
||||||
|
calc = false;
|
||||||
|
vsnip = true;
|
||||||
|
nvim_lsp = true;
|
||||||
|
nvim_lua = true;
|
||||||
|
spell = true;
|
||||||
|
tags = true;
|
||||||
|
snippets_nvim = true;
|
||||||
|
treesitter = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
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.call("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.call("vsnip#jumpable", {-1}) == 1 then
|
||||||
|
return t "<Plug>(vsnip-jump-prev)"
|
||||||
|
else
|
||||||
|
return t "<S-Tab>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.map("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||||
|
utils.map("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||||
|
utils.map("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||||
|
utils.map("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
@ -1,6 +1,4 @@
|
|||||||
|
|
||||||
require'lspconfig'.pyright.setup{}
|
|
||||||
|
|
||||||
local nvim_lsp = require('lspconfig')
|
local nvim_lsp = require('lspconfig')
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
-- Use an on_attach function to only map the following keys
|
||||||
@ -47,7 +45,7 @@ end
|
|||||||
|
|
||||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||||
-- map buffer local keybindings when the language server attaches
|
-- map buffer local keybindings when the language server attaches
|
||||||
local servers = { "pyright" }
|
local servers = { "texlab", "pyright", "vuels", "tsserver" }
|
||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
nvim_lsp[lsp].setup {
|
nvim_lsp[lsp].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
@ -56,3 +54,9 @@ for _, lsp in ipairs(servers) do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nvim_lsp.vuels.setup{
|
||||||
|
on_attach = function(client)
|
||||||
|
client.resolved_capabilities.document_formatting = true
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
@ -26,6 +26,7 @@ let g:compe.source.emoji = v:false
|
|||||||
|
|
||||||
" NOTE: You can use other key to expand snippet.
|
" NOTE: You can use other key to expand snippet.
|
||||||
|
|
||||||
|
|
||||||
" Expand
|
" Expand
|
||||||
imap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>'
|
imap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>'
|
||||||
smap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>'
|
smap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>'
|
||||||
@ -51,3 +52,47 @@ xmap S <Plug>(vsnip-cut-text)
|
|||||||
" let g:vsnip_filetypes = {}
|
" let g:vsnip_filetypes = {}
|
||||||
" let g:vsnip_filetypes.javascriptreact = ['javascript']
|
" let g:vsnip_filetypes.javascriptreact = ['javascript']
|
||||||
" let g:vsnip_filetypes.typescriptreact = ['typescript']
|
" let g:vsnip_filetypes.typescriptreact = ['typescript']
|
||||||
|
|
||||||
|
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
|
||||||
|
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
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 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>"
|
||||||
|
else
|
||||||
|
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})
|
||||||
|
|
||||||
|
--This line is important for auto-import
|
||||||
|
vim.api.nvim_set_keymap('i', '<cr>', 'compe#confirm("<cr>")', { expr = true })
|
||||||
|
vim.api.nvim_set_keymap('i', '<c-space>', 'compe#complete()', { expr = true })
|
||||||
|
EOF
|
||||||
|
@ -13,6 +13,7 @@ call plug#begin('~/.config/nvim/autoload/plugged')
|
|||||||
|
|
||||||
"Plug 'tpope/vim-sensible'
|
"Plug 'tpope/vim-sensible'
|
||||||
Plug 'tpope/vim-fugitive'
|
Plug 'tpope/vim-fugitive'
|
||||||
|
Plug 'mhinz/vim-signify'
|
||||||
Plug 'tpope/vim-surround'
|
Plug 'tpope/vim-surround'
|
||||||
Plug 'tpope/vim-repeat'
|
Plug 'tpope/vim-repeat'
|
||||||
|
|
||||||
@ -20,10 +21,14 @@ call plug#begin('~/.config/nvim/autoload/plugged')
|
|||||||
Plug 'christoomey/vim-tmux-navigator'
|
Plug 'christoomey/vim-tmux-navigator'
|
||||||
Plug 'Yggdroot/indentLine'
|
Plug 'Yggdroot/indentLine'
|
||||||
|
|
||||||
|
" Plug 'SirVer/ultisnips'
|
||||||
|
" Plug 'honza/vim-snippets'
|
||||||
Plug 'neovim/nvim-lspconfig'
|
Plug 'neovim/nvim-lspconfig'
|
||||||
Plug 'hrsh7th/nvim-compe'
|
Plug 'hrsh7th/nvim-compe'
|
||||||
Plug 'hrsh7th/vim-vsnip'
|
Plug 'hrsh7th/vim-vsnip'
|
||||||
Plug 'hrsh7th/vim-vsnip-integ'
|
Plug 'hrsh7th/vim-vsnip-integ'
|
||||||
|
Plug 'rafamadriz/friendly-snippets'
|
||||||
|
|
||||||
" Plug 'nvim-lua/completion-nvim'
|
" Plug 'nvim-lua/completion-nvim'
|
||||||
|
|
||||||
Plug 'nvim-lua/popup.nvim'
|
Plug 'nvim-lua/popup.nvim'
|
||||||
@ -32,12 +37,6 @@ call plug#begin('~/.config/nvim/autoload/plugged')
|
|||||||
|
|
||||||
"Plug 'lervag/vimtex'
|
"Plug 'lervag/vimtex'
|
||||||
|
|
||||||
Plug 'SirVer/ultisnips'
|
" Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||||
Plug 'honza/vim-snippets'
|
|
||||||
|
|
||||||
Plug 'mhinz/vim-signify'
|
|
||||||
Plug 'tpope/vim-fugitive'
|
|
||||||
|
|
||||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
Loading…
Reference in New Issue
Block a user