Compare commits
2 Commits
99f81ebf0a
...
23ba611075
Author | SHA1 | Date | |
---|---|---|---|
23ba611075 | |||
bd11e06a19 |
@ -1 +1,5 @@
|
||||
require('plugins')
|
||||
require('settings')
|
||||
require('mappings')
|
||||
|
||||
require('lsp')
|
||||
|
@ -1,18 +0,0 @@
|
||||
source $HOME/.config/nvim/plugins/plugins.vim
|
||||
source $HOME/.config/nvim/general/settings.vim
|
||||
source $HOME/.config/nvim/general/mappings.vim
|
||||
" source $HOME/.config/nvim/general/completion.vim
|
||||
|
||||
source $HOME/.config/nvim/plugins/lightline.vim
|
||||
source $HOME/.config/nvim/plugins/nvim-comp.vim
|
||||
source $HOME/.config/nvim/plugins/vimtex.vim
|
||||
|
||||
lua <<EOF
|
||||
require("lsp")
|
||||
EOF
|
||||
|
||||
" require("comp")
|
||||
|
||||
" bug fix with telescope and insert mode https://GitHub.com/vim telescope/telescope.vim/issues/82
|
||||
autocmd FileType TelescopePrompt
|
||||
\ call deoplete#custom#buffer_option('auto_complete', v:false)
|
@ -1,78 +0,0 @@
|
||||
-- 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 = false;
|
||||
spell = true;
|
||||
tags = true;
|
||||
snippets_nvim = false;
|
||||
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})
|
98
nvim/.config/nvim/lua/completion.lua
Normal file
98
nvim/.config/nvim/lua/completion.lua
Normal file
@ -0,0 +1,98 @@
|
||||
local has_words_before = function()
|
||||
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
|
||||
return false
|
||||
end
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local feedkey = function(key, mode)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||
end
|
||||
|
||||
local lsp_symbols = {
|
||||
Text = " (Text) ",
|
||||
Method = " (Method)",
|
||||
Function = " (Function)",
|
||||
Constructor = " (Constructor)",
|
||||
Field = " ﴲ (Field)",
|
||||
Variable = "[] (Variable)",
|
||||
Class = " (Class)",
|
||||
Interface = " ﰮ (Interface)",
|
||||
Module = " (Module)",
|
||||
Property = " 襁 (Property)",
|
||||
Unit = " (Unit)",
|
||||
Value = " (Value)",
|
||||
Enum = " 練 (Enum)",
|
||||
Keyword = " (Keyword)",
|
||||
Snippet = " (Snippet)",
|
||||
Color = " (Color)",
|
||||
File = " (File)",
|
||||
Reference = " (Reference)",
|
||||
Folder = " (Folder)",
|
||||
EnumMember = " (EnumMember)",
|
||||
Constant = " ﲀ (Constant)",
|
||||
Struct = " ﳤ (Struct)",
|
||||
Event = " (Event)",
|
||||
Operator = " (Operator)",
|
||||
TypeParameter = " (TypeParameter)",
|
||||
}
|
||||
|
||||
local cmp = require'cmp'
|
||||
cmp.setup{
|
||||
completion = {
|
||||
completeopt = "menuone,noinsert,noselect",
|
||||
},
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
-- fancy icons and a name of kind
|
||||
vim_item.kind = lsp_symbols[vim_item.kind]
|
||||
-- set a name for each source
|
||||
vim_item.menu = ({
|
||||
buffer = "[Buffer]",
|
||||
nvim_lsp = "[LSP]",
|
||||
vsnip = "[vSnip]",
|
||||
path = "[Path]",
|
||||
spell = "[Spell]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
-- ["<cr>"] = cmp.mapping.confirm({select = true, behavior = cmp.ConfirmBehavior.Replace}),
|
||||
["<cr>"] = cmp.mapping.confirm({select = true, behavior = cmp.ConfirmBehavior.Insert}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
feedkey("<C-n>", "n")
|
||||
elseif vim.fn["vsnip#available"]() == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function()
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
feedkey("<C-p>", "n")
|
||||
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
source = {
|
||||
{ name = 'buffer' },
|
||||
{ name = 'vsnip' },
|
||||
{ name = 'path' },
|
||||
{ name = 'spell' },
|
||||
}
|
||||
}
|
||||
|
||||
vim.cmd [[autocmd FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false }]]
|
||||
vim.g.vsnip_snippet_dir = '~/.config/nvim/vsnips'
|
@ -16,7 +16,7 @@ map('v', '>', '>gv', {})
|
||||
map('i', '<c-f>', '<c-g>u<Esc>[s1z=`]a<c-g>u', default_opts)
|
||||
|
||||
-- Find files using Telescope command-line sugar.
|
||||
map('n', '<leader>e', '<cmd>Telescope find_files<cr>')
|
||||
map('n', '<leader>g', '<cmd>Telescope live_grep<cr>')
|
||||
map('n', '<leader>b', '<cmd>Telescope buffers<cr>')
|
||||
map('n', '<leader>h', '<cmd>Telescope help_tags<cr>')
|
||||
map('n', '<leader>e', '<cmd>Telescope find_files<cr>', {})
|
||||
map('n', '<leader>g', '<cmd>Telescope live_grep<cr>', {})
|
||||
map('n', '<leader>b', '<cmd>Telescope buffers<cr>', {})
|
||||
map('n', '<leader>h', '<cmd>Telescope help_tags<cr>', {})
|
||||
|
85
nvim/.config/nvim/lua/plugins.lua
Normal file
85
nvim/.config/nvim/lua/plugins.lua
Normal file
@ -0,0 +1,85 @@
|
||||
-- Only required if you have packer configured as `opt`
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
|
||||
return require('packer').startup(function()
|
||||
use 'morhetz/gruvbox'
|
||||
|
||||
-- Status line
|
||||
use {
|
||||
'hoob3rt/lualine.nvim',
|
||||
config = function ()
|
||||
require('lualine').setup{
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'gruvbox',
|
||||
component_separators = {'', ''},
|
||||
section_separators = {'', ''},
|
||||
disabled_filetypes = {}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch'},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {
|
||||
{ 'diagnostics', sources = {"nvim_lsp"}, symbols = {error = ' ', warn = ' ', info = ' ', hint = ' '} },
|
||||
'encoding',
|
||||
'filetype'
|
||||
},
|
||||
lualine_y = {'progress'},
|
||||
lualine_z = {'location'}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'location'},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {}
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'mhinz/vim-signify'
|
||||
|
||||
use 'tpope/vim-surround'
|
||||
use 'tpope/vim-repeat'
|
||||
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use {
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = 'InsertEnter',
|
||||
config = [[require('completion')]],
|
||||
requires = {
|
||||
-- 'hrsh7th/vim-vsnip-integ',
|
||||
'rafamadriz/friendly-snippets',
|
||||
},
|
||||
}
|
||||
use {"hrsh7th/vim-vsnip", after = "nvim-cmp"}
|
||||
use {"hrsh7th/cmp-vsnip", after = "nvim-cmp"}
|
||||
use {"hrsh7th/cmp-buffer", after = "nvim-cmp"}
|
||||
use {'hrsh7th/cmp-path', after = "nvim-cmp"}
|
||||
use {"hrsh7th/cmp-nvim-lsp", after = "nvim-cmp"}
|
||||
use {'f3fora/cmp-spell', after = "nvim-cmp"}
|
||||
|
||||
use 'nvim-lua/popup.nvim'
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = { {'nvim-lua/plenary.nvim'} }
|
||||
}
|
||||
|
||||
use {
|
||||
'lervag/vimtex',
|
||||
}
|
||||
|
||||
-- Highlight on Yank
|
||||
use 'machakann/vim-highlightedyank'
|
||||
-- Autoclose parenthesis
|
||||
use 'jiangmiao/auto-pairs'
|
||||
|
||||
use 'kyazdani42/nvim-web-devicons'
|
||||
|
||||
end)
|
@ -26,8 +26,7 @@ opt.cursorline = true -- highlight current line
|
||||
opt.ignorecase = true -- Ignore case on search
|
||||
opt.smartcase = true -- ignore lowercse for the whoel pattern
|
||||
|
||||
opt.completeopt = 'menuone,noselect,noinsert' -- completion options
|
||||
opt.shortmess = 'c' -- don't show completion messages
|
||||
-- opt.completeopt = 'menu,noselect,noinsert' -- completion options
|
||||
|
||||
opt.spell = true
|
||||
opt.spelllang = {'fr', 'en'}
|
||||
@ -49,4 +48,4 @@ exec([[
|
||||
augroup end
|
||||
]], false)
|
||||
|
||||
|
||||
cmd('colorscheme gruvbox')
|
||||
|
Loading…
Reference in New Issue
Block a user