Feat | Plugin update, speed optimizations.
coq is bloated and does not play well with other plugins, nvim-cmp is a better solution despite it is slightly slower. I optimized the startup sequence, start time: 80ms -> 120ms -> 65ms Next up, I will try to work on my zk workflow.
This commit is contained in:
parent
8ce8e942ba
commit
9087e563d8
35
lua/core.lua
35
lua/core.lua
@ -1,35 +1,30 @@
|
||||
-- CORE SETTINGS
|
||||
local opt = vim.o
|
||||
local o = vim.o
|
||||
local global = vim.g
|
||||
|
||||
-- look and feel
|
||||
vim.opt.shortmess:append({I = true}) -- remove intro message
|
||||
opt.termguicolors = true
|
||||
opt.ruler = true
|
||||
opt.relativenumber = true
|
||||
opt.number = true
|
||||
opt.showmode = false
|
||||
opt.scrolloff = 10
|
||||
opt.softtabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
o.termguicolors = true
|
||||
o.ruler = true
|
||||
o.relativenumber = true
|
||||
o.number = true
|
||||
o.showmode = false
|
||||
o.scrolloff = 10
|
||||
o.softtabstop = 2
|
||||
o.shiftwidth = 2
|
||||
|
||||
-- controlling
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.smartindent = true
|
||||
opt.mouse = "i"
|
||||
opt.autoindent = true
|
||||
|
||||
-- completion for lua
|
||||
opt.completeopt = 'noinsert'
|
||||
vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
|
||||
o.ignorecase = true
|
||||
o.smartcase = true
|
||||
o.smartindent = true
|
||||
o.mouse = "i"
|
||||
o.autoindent = true
|
||||
|
||||
-- neoformat settings.
|
||||
global.neoformat_basic_format_align = 1
|
||||
global.neoformat_basic_format_trim = 1
|
||||
|
||||
-- glow settings
|
||||
global.glow_border = "rounded"
|
||||
|
||||
-- leader settings
|
||||
global.mapleader = ' '
|
||||
|
||||
|
110
lua/mappings.lua
110
lua/mappings.lua
@ -1,52 +1,100 @@
|
||||
local map = vim.api.nvim_set_keymap
|
||||
|
||||
-- generic mappings
|
||||
vim.api.nvim_set_keymap('v', '<', '<gv', {noremap = true})
|
||||
vim.api.nvim_set_keymap('v', '>', '>gv', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', 'Y', 'y$', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', 'n', 'nzzzv', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', 'N', 'Nzzzv', {noremap = true})
|
||||
map('v', '<', '<gv', {noremap = true})
|
||||
map('v', '>', '>gv', {noremap = true})
|
||||
map('n', 'Y', 'y$', {noremap = true})
|
||||
map('n', 'n', 'nzzzv', {noremap = true})
|
||||
map('n', 'N', 'Nzzzv', {noremap = true})
|
||||
|
||||
-- Shortcutting split navigation
|
||||
vim.api.nvim_set_keymap('', '<A-h>', '<C-w>h', {})
|
||||
vim.api.nvim_set_keymap('', '<A-j>', '<C-w>j', {})
|
||||
vim.api.nvim_set_keymap('', '<A-k>', '<C-w>k', {})
|
||||
vim.api.nvim_set_keymap('', '<A-l>', '<C-w>l', {})
|
||||
vim.api.nvim_set_keymap('', '<A-H>', '<C-w>H', {})
|
||||
vim.api.nvim_set_keymap('', '<A-J>', '<C-w>J', {})
|
||||
vim.api.nvim_set_keymap('', '<A-K>', '<C-w>K', {})
|
||||
vim.api.nvim_set_keymap('', '<A-L>', '<C-w>L', {})
|
||||
vim.api.nvim_set_keymap('', '<A->>', '<C-w>>', {})
|
||||
vim.api.nvim_set_keymap('', '<A-<>', '<C-w><', {})
|
||||
vim.api.nvim_set_keymap('', '<A-T>', '<C-w>T', {})
|
||||
map('', '<A-h>', '<C-w>h', {})
|
||||
map('', '<A-j>', '<C-w>j', {})
|
||||
map('', '<A-k>', '<C-w>k', {})
|
||||
map('', '<A-l>', '<C-w>l', {})
|
||||
map('', '<A-H>', '<C-w>H', {})
|
||||
map('', '<A-J>', '<C-w>J', {})
|
||||
map('', '<A-K>', '<C-w>K', {})
|
||||
map('', '<A-L>', '<C-w>L', {})
|
||||
map('', '<A->>', '<C-w>>', {})
|
||||
map('', '<A-<>', '<C-w><', {})
|
||||
map('', '<A-T>', '<C-w>T', {})
|
||||
|
||||
-- undo to the last , . or !
|
||||
vim.api.nvim_set_keymap('i', ',', ',<c-g>u', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '.', '.<c-g>u', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '!', '!<c-g>u', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '?', '?<c-g>u', {noremap = true})
|
||||
map('i', ',', ',<c-g>u', {noremap = true})
|
||||
map('i', '.', '.<c-g>u', {noremap = true})
|
||||
map('i', '!', '!<c-g>u', {noremap = true})
|
||||
map('i', '?', '?<c-g>u', {noremap = true})
|
||||
|
||||
-- plugin mappings
|
||||
-- gitsigns
|
||||
vim.api.nvim_set_keymap('', '<leader>gs', ':Gitsigns toggle_signs<cr>',
|
||||
map('', '<leader>gs', ':Gitsigns toggle_signs<cr>',
|
||||
{silent = true})
|
||||
-- lsp stuff
|
||||
vim.api.nvim_buf_set_keymap(0, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>',
|
||||
{noremap = true})
|
||||
vim.api.nvim_set_keymap('', '<leader>K',
|
||||
map('', '<leader>K',
|
||||
'<cmd>lua vim.diagnostic.open_float()<CR>',
|
||||
{noremap = true})
|
||||
vim.api.nvim_set_keymap('', '<leader>qf',
|
||||
map('', '<leader>qf',
|
||||
'<cmd>lua vim.diagnostic.setqflist({open = false})<cr><cmd>Telescope quickfix<cr>',
|
||||
{silent = true})
|
||||
|
||||
-- toggle tagbar
|
||||
vim.api.nvim_set_keymap('', '<leader>tt', ':TagbarToggle<cr>', {silent = true})
|
||||
map('', '<leader>tt', ':TagbarToggle<cr>', {silent = true})
|
||||
|
||||
-- toggle NvimTree
|
||||
vim.api.nvim_set_keymap('', '<C-n>', ':NvimTreeToggle<cr>', {silent = true})
|
||||
map('', '<C-n>', ':NvimTreeToggle<cr>', {silent = true})
|
||||
|
||||
-- toggle formatter
|
||||
vim.api.nvim_set_keymap('', '<leader>fm', ':Neoformat<cr>', {silent = true})
|
||||
map('', '<leader>fm', ':Neoformat<cr>', {silent = true})
|
||||
|
||||
-- toggle Hop
|
||||
vim.api.nvim_set_keymap('', '<leader>b', ':HopWordBC<cr>', {silent = true})
|
||||
vim.api.nvim_set_keymap('', '<leader>w', ':HopWordAC<cr>', {silent = true})
|
||||
vim.api.nvim_set_keymap('', '<leader>l', ':HopWordCurrentLine<cr>',
|
||||
map('', '<leader>b', ':HopWordBC<cr>', {silent = true})
|
||||
map('', '<leader>w', ':HopWordAC<cr>', {silent = true})
|
||||
map('', '<leader>l', ':HopWordCurrentLine<cr>',
|
||||
{silent = true})
|
||||
|
||||
-- telescope stuff
|
||||
vim.api.nvim_set_keymap('', '<leader>fd', ':Telescope fd<cr>', {silent = true})
|
||||
vim.api.nvim_set_keymap('', '<leader>tb', ':Telescope buffers<cr>',
|
||||
map('', '<leader>fd', ':Telescope fd<cr>', {silent = true})
|
||||
map('', '<leader>tb', ':Telescope buffers<cr>',
|
||||
{silent = true})
|
||||
|
||||
-- Barbar controls
|
||||
local opts = { noremap = true, silent = true }
|
||||
-- Move to previous/next
|
||||
map('n', '<A-,>', '<Cmd>BufferPrevious<CR>', opts)
|
||||
map('n', '<A-.>', '<Cmd>BufferNext<CR>', opts)
|
||||
-- Re-order to previous/next
|
||||
map('n', '<A-P>', '<Cmd>BufferMovePrevious<CR>', opts)
|
||||
map('n', '<A-N>', '<Cmd>BufferMoveNext<CR>', opts)
|
||||
-- Goto buffer in position...
|
||||
map('n', '<A-1>', '<Cmd>BufferGoto 1<CR>', opts)
|
||||
map('n', '<A-2>', '<Cmd>BufferGoto 2<CR>', opts)
|
||||
map('n', '<A-3>', '<Cmd>BufferGoto 3<CR>', opts)
|
||||
map('n', '<A-4>', '<Cmd>BufferGoto 4<CR>', opts)
|
||||
map('n', '<A-5>', '<Cmd>BufferGoto 5<CR>', opts)
|
||||
map('n', '<A-6>', '<Cmd>BufferGoto 6<CR>', opts)
|
||||
map('n', '<A-7>', '<Cmd>BufferGoto 7<CR>', opts)
|
||||
map('n', '<A-8>', '<Cmd>BufferGoto 8<CR>', opts)
|
||||
map('n', '<A-9>', '<Cmd>BufferGoto 9<CR>', opts)
|
||||
map('n', '<A-0>', '<Cmd>BufferLast<CR>', opts)
|
||||
-- Pin/unpin buffer
|
||||
map('n', '<A-p>', '<Cmd>BufferPin<CR>', opts)
|
||||
-- Close buffer
|
||||
map('n', '<A-w>', '<Cmd>BufferClose<CR>', opts)
|
||||
-- Wipeout buffer
|
||||
-- :BufferWipeout
|
||||
-- Close commands
|
||||
-- :BufferCloseAllButCurrent
|
||||
-- :BufferCloseAllButPinned
|
||||
-- :BufferCloseAllButCurrentOrPinned
|
||||
-- :BufferCloseBuffersLeft
|
||||
-- :BufferCloseBuffersRight
|
||||
-- Magic buffer-picking mode
|
||||
map('n', '<C-p>', '<Cmd>BufferPick<CR>', opts)
|
||||
-- Sort automatically by...
|
||||
map('n', '<Space>bb', '<Cmd>BufferOrderByBufferNumber<CR>', opts)
|
||||
map('n', '<Space>bd', '<Cmd>BufferOrderByDirectory<CR>', opts)
|
||||
map('n', '<Space>bl', '<Cmd>BufferOrderByLanguage<CR>', opts)
|
||||
map('n', '<Space>bw', '<Cmd>BufferOrderByWindowNumber<CR>', opts)
|
||||
|
@ -17,12 +17,11 @@ require('packer').init {
|
||||
}
|
||||
|
||||
return require('packer').startup(function(use)
|
||||
use {'wbthomason/packer.nvim', event = "VimEnter"}
|
||||
use {'wbthomason/packer.nvim'}
|
||||
|
||||
-- core UI
|
||||
use {
|
||||
'b4skyx/serenade',
|
||||
after = 'packer.nvim',
|
||||
config = function()
|
||||
vim.g.serenade_enable_italic = 1
|
||||
vim.g.serenade_sign_column_background = 'none'
|
||||
@ -30,15 +29,22 @@ return require('packer').startup(function(use)
|
||||
vim.cmd("colorscheme serenade")
|
||||
end
|
||||
}
|
||||
use {'kyazdani42/nvim-web-devicons', after = 'packer.nvim'}
|
||||
use {'kyazdani42/nvim-web-devicons'}
|
||||
use {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
after = {'serenade', 'nvim-web-devicons'},
|
||||
config = function() require "plugins.statusline" end
|
||||
}
|
||||
use {
|
||||
'romgrk/barbar.nvim',
|
||||
requires = {'kyazdani42/nvim-web-devicons'},
|
||||
event = 'BufAdd',
|
||||
after = {'nvim-web-devicons', 'serenade'},
|
||||
config = function() require "plugins.barbar" end
|
||||
}
|
||||
|
||||
-- lsp stuff
|
||||
use {'neovim/nvim-lspconfig', event = "BufEnter"}
|
||||
use {'neovim/nvim-lspconfig', event = "UIEnter"}
|
||||
use {
|
||||
'williamboman/nvim-lsp-installer',
|
||||
config = function() require "plugins.lspinstall" end,
|
||||
@ -47,7 +53,7 @@ return require('packer').startup(function(use)
|
||||
use {
|
||||
"ray-x/lsp_signature.nvim",
|
||||
after = "nvim-lsp-installer",
|
||||
config = function() require "plugins.lsp_signature" end
|
||||
config = function() require "plugins.lsp-signature" end
|
||||
}
|
||||
|
||||
-- tree sitter
|
||||
@ -59,45 +65,47 @@ return require('packer').startup(function(use)
|
||||
}
|
||||
|
||||
-- completer
|
||||
use {'L3MON4D3/LuaSnip', event = "UIEnter"}
|
||||
use {
|
||||
'ms-jpq/coq_nvim',
|
||||
branch = 'coq',
|
||||
-- after = 'nvim-lsp-installer',
|
||||
run = ':COQdeps',
|
||||
config = function() require "plugins.coq" end
|
||||
}
|
||||
use {'ms-jpq/coq.artifacts', after = 'coq_nvim', branch = 'artifacts'}
|
||||
use {
|
||||
'ms-jpq/coq.thirdparty',
|
||||
branch = '3p',
|
||||
after = 'coq_nvim',
|
||||
config = function()
|
||||
require("coq_3p") {
|
||||
{src = "nvimlua", short_name = "nLUA"}, {src = "repl"},
|
||||
{src = "vimtex", short_name = "vTEX"}
|
||||
}
|
||||
|
||||
end
|
||||
event = "InsertEnter",
|
||||
after = {'nvim-lsp-installer', 'nvim-treesitter', 'LuaSnip'},
|
||||
"hrsh7th/nvim-cmp",
|
||||
config = function() require "plugins.cmp" end,
|
||||
requires = {
|
||||
-- local
|
||||
{'hrsh7th/cmp-cmdline', after = 'nvim-cmp'},
|
||||
{'hrsh7th/cmp-buffer', after = 'nvim-cmp'},
|
||||
{'hrsh7th/cmp-path', after = 'nvim-cmp'},
|
||||
{'petertriho/cmp-git', after = 'nvim-cmp'}, -- end
|
||||
-- lsp
|
||||
{'hrsh7th/cmp-nvim-lsp-document-symbol', after = 'nvim-cmp'},
|
||||
{'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp'}, -- end
|
||||
-- TS
|
||||
{'ray-x/cmp-treesitter', after = 'nvim-cmp'}, -- end
|
||||
-- Snip
|
||||
{'saadparwaiz1/cmp_luasnip', after = {'nvim-cmp', 'LuaSnip'}}
|
||||
}
|
||||
}
|
||||
|
||||
-- formating and editing
|
||||
use {
|
||||
"windwp/nvim-autopairs",
|
||||
after = 'nvim-cmp',
|
||||
config = function() require("plugins.nvim-autopairs") end
|
||||
}
|
||||
use {"sbdchd/neoformat", cmd = "Neoformat"}
|
||||
use {
|
||||
"mattn/emmet-vim",
|
||||
ft = {'html', 'htmldjango', 'css', 'markdown'},
|
||||
setup = function() require "plugins.emmet" end
|
||||
}
|
||||
use {"machakann/vim-sandwich", event = "BufEnter"}
|
||||
use {"machakann/vim-sandwich", event = "UIEnter"}
|
||||
|
||||
use {
|
||||
'numToStr/Comment.nvim',
|
||||
event = "UIEnter",
|
||||
config = function() require('Comment').setup() end
|
||||
}
|
||||
use {
|
||||
"windwp/nvim-autopairs",
|
||||
event = "BufEnter",
|
||||
config = function() require("plugins.nvim-autopairs") end
|
||||
}
|
||||
|
||||
-- navigation
|
||||
use {
|
||||
@ -114,7 +122,7 @@ return require('packer').startup(function(use)
|
||||
use {
|
||||
'abecodes/tabout.nvim',
|
||||
config = function() require('tabout').setup {} end,
|
||||
after = {'nvim-treesitter', 'nvim-autopairs', 'coq_nvim'} -- if a completion plugin is using tabs load it before
|
||||
after = {'nvim-treesitter', 'nvim-autopairs', 'nvim-cmp'} -- if a completion plugin is using tabs load it before
|
||||
}
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
@ -135,8 +143,7 @@ return require('packer').startup(function(use)
|
||||
-- eye-candy
|
||||
use {
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
after = {"nvim-treesitter", "nvim-treesitter-context"},
|
||||
event = "UIEnter",
|
||||
after = {"nvim-treesitter"},
|
||||
config = function() require "plugins.indent-blankline" end
|
||||
}
|
||||
use {
|
||||
@ -177,7 +184,7 @@ return require('packer').startup(function(use)
|
||||
}
|
||||
use {
|
||||
'norcalli/nvim-colorizer.lua',
|
||||
after = "packer.nvim",
|
||||
event = "BufEnter",
|
||||
config = function() require "plugins.nvim-colorizer" end
|
||||
}
|
||||
|
||||
@ -186,12 +193,12 @@ return require('packer').startup(function(use)
|
||||
use {
|
||||
"mickael-menu/zk-nvim",
|
||||
requires = {"nvim-telescope/telescope.nvim"},
|
||||
after = {"nvim-telescope/telescope.nvim"},
|
||||
after = {"telescope.nvim"},
|
||||
ft = {'markdown'},
|
||||
config = function() require "plugins.zk" end
|
||||
}
|
||||
|
||||
-- fixes and misc. stuff
|
||||
use {"antoinemadec/FixCursorHold.nvim"}
|
||||
use {"antoinemadec/FixCursorHold.nvim", event = "UIEnter"}
|
||||
end)
|
||||
-- vim:set shiftwidth=4 tabstop=4:
|
||||
|
91
lua/plugins/barbar.lua
Normal file
91
lua/plugins/barbar.lua
Normal file
@ -0,0 +1,91 @@
|
||||
-- Set barbar's options
|
||||
require'bufferline'.setup {
|
||||
-- Enable/disable animations
|
||||
animation = false,
|
||||
|
||||
-- Enable/disable auto-hiding the tab bar when there is a single buffer
|
||||
auto_hide = false,
|
||||
|
||||
-- Enable/disable current/total tabpages indicator (top right corner)
|
||||
tabpages = true,
|
||||
|
||||
-- Enable/disable close button
|
||||
closable = true,
|
||||
|
||||
-- Enables/disable clickable tabs
|
||||
-- - left-click: go to buffer
|
||||
-- - middle-click: delete buffer
|
||||
clickable = true,
|
||||
|
||||
-- Enable/disable icons
|
||||
-- if set to 'numbers', will show buffer index in the tabline
|
||||
-- if set to 'both', will show buffer index and icons in the tabline
|
||||
icons = true,
|
||||
|
||||
-- If set, the icon color will follow its corresponding buffer
|
||||
-- highlight group. By default, the Buffer*Icon group is linked to the
|
||||
-- Buffer* group (see Highlighting below). Otherwise, it will take its
|
||||
-- default value as defined by devicons.
|
||||
icon_custom_colors = true,
|
||||
|
||||
-- Configure icons on the bufferline.
|
||||
icon_separator_active = '▎',
|
||||
icon_separator_inactive = '▎',
|
||||
icon_close_tab = '',
|
||||
icon_close_tab_modified = '●',
|
||||
icon_pinned = '車',
|
||||
|
||||
-- If true, new buffers will be inserted at the start/end of the list.
|
||||
-- Default is to insert after current buffer.
|
||||
insert_at_end = false,
|
||||
insert_at_start = false,
|
||||
|
||||
-- Sets the maximum padding width with which to surround each tab
|
||||
maximum_padding = 1,
|
||||
|
||||
-- Sets the maximum buffer name length.
|
||||
maximum_length = 30,
|
||||
|
||||
-- If set, the letters for each buffer in buffer-pick mode will be
|
||||
-- assigned based on their name. Otherwise or in case all letters are
|
||||
-- already assigned, the behavior is to assign letters in order of
|
||||
-- usability (see order below)
|
||||
semantic_letters = true,
|
||||
|
||||
-- New buffer letters are assigned in this order. This order is
|
||||
-- optimal for the qwerty keyboard layout but might need adjustement
|
||||
-- for other layouts.
|
||||
letters = 'asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP',
|
||||
|
||||
-- Sets the name of unnamed buffers. By default format is "[Buffer X]"
|
||||
-- where X is the buffer number. But only a static string is accepted here.
|
||||
no_name_title = nil
|
||||
}
|
||||
|
||||
-- nvim-tree integration
|
||||
local nvim_tree_events = require('nvim-tree.events')
|
||||
local bufferline_state = require('bufferline.state')
|
||||
|
||||
-- track the window id of nvim-tree
|
||||
local id
|
||||
|
||||
local function get_tree_size() return vim.api.nvim_win_get_width(id) end
|
||||
|
||||
nvim_tree_events.on_tree_open(function()
|
||||
id = vim.api.nvim_eval('win_getid()')
|
||||
bufferline_state.set_offset(get_tree_size())
|
||||
end)
|
||||
|
||||
nvim_tree_events.on_tree_resize(function()
|
||||
if id ~= nil then
|
||||
if vim.api.nvim_eval('win_gettype(' .. id .. ')') ~= 'unknown' then
|
||||
bufferline_state.set_offset(get_tree_size())
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
nvim_tree_events.on_tree_close(function()
|
||||
id = nil
|
||||
bufferline_state.set_offset(0)
|
||||
end)
|
||||
|
79
lua/plugins/cmp.lua
Normal file
79
lua/plugins/cmp.lua
Normal file
@ -0,0 +1,79 @@
|
||||
local cmp = require 'cmp'
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
local has_words_before = function()
|
||||
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
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
end
|
||||
},
|
||||
window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
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}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {"i", "s"}),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {"i", "s"})
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{name = 'nvim_lsp'}, {name = 'treesitter'}, {name = 'luasnip'} -- For luasnip users.
|
||||
}, {{name = 'buffer'}, {name = 'path'}})
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline('/', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {{name = 'nvim_lsp_document_symbol'}, {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'}})
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{name = 'cmp_git'} -- You can specify the `cmp_git` source if you were installed it.
|
||||
}, {{name = 'buffer'}})
|
||||
})
|
||||
|
||||
-- Set config for neovim config file
|
||||
cmp.setup.filetype('lua', {
|
||||
sources = cmp.config.sources({{name = 'plugins'}}, {{name = 'buffer'}})
|
||||
})
|
@ -1,6 +0,0 @@
|
||||
vim.g.coq_settings = {
|
||||
keymap = {recommended = false}, -- pre_select = true need a way to make tab enter
|
||||
auto_start = true,
|
||||
display = {ghost_text = {enabled = false}, icons = {mode = "none"}, preview = {border = "rounded" }}
|
||||
}
|
||||
vim.cmd('COQnow -s')
|
@ -1,42 +1,8 @@
|
||||
local remap = vim.api.nvim_set_keymap
|
||||
local npairs = require('nvim-autopairs')
|
||||
|
||||
npairs.setup({map_bs = true, map_cr = true})
|
||||
npairs.setup({map_bs = true, map_cr = true, map_c_w = true})
|
||||
|
||||
vim.g.coq_settings = {keymap = {recommended = false}}
|
||||
|
||||
-- these mappings are coq recommended mappings unrelated to nvim-autopairs
|
||||
remap('i', '<esc>', [[pumvisible() ? "<c-e><esc>" : "<esc>"]],
|
||||
{expr = true, noremap = true})
|
||||
remap('i', '<c-c>', [[pumvisible() ? "<c-e><c-c>" : "<c-c>"]],
|
||||
{expr = true, noremap = true})
|
||||
remap('i', '<tab>', [[pumvisible() ? "<c-n>" : "<tab>"]],
|
||||
{expr = true, noremap = true})
|
||||
remap('i', '<s-tab>', [[pumvisible() ? "<c-p>" : "<bs>"]],
|
||||
{expr = true, noremap = true})
|
||||
|
||||
-- skip it, if you use another global object
|
||||
_G.MUtils = {}
|
||||
|
||||
MUtils.CR = function()
|
||||
if vim.fn.pumvisible() ~= 0 then
|
||||
if vim.fn.complete_info({'selected'}).selected ~= -1 then
|
||||
return npairs.esc('<c-y>')
|
||||
else
|
||||
return npairs.esc('<c-e>') .. npairs.autopairs_cr()
|
||||
end
|
||||
else
|
||||
return npairs.autopairs_cr()
|
||||
end
|
||||
end
|
||||
remap('i', '<cr>', 'v:lua.MUtils.CR()', {expr = true, noremap = true})
|
||||
|
||||
MUtils.BS = function()
|
||||
if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({'mode'}).mode ==
|
||||
'eval' then
|
||||
return npairs.esc('<c-e>') .. npairs.autopairs_bs()
|
||||
else
|
||||
return npairs.autopairs_bs()
|
||||
end
|
||||
end
|
||||
remap('i', '<bs>', 'v:lua.MUtils.BS()', {expr = true, noremap = true})
|
||||
-- If you want insert `(` after select function or method item
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
local cmp = require('cmp')
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||
|
@ -1,3 +1,4 @@
|
||||
-- vim:set shiftwidth=4 tabstop=4:
|
||||
-- following options are the default
|
||||
-- each of these are documented in `:help nvim-tree.OPTION_NAME`
|
||||
require'nvim-tree'.setup {
|
||||
@ -14,11 +15,5 @@ require'nvim-tree'.setup {
|
||||
icons = {hint = "", info = "", warning = "", error = ""}
|
||||
},
|
||||
system_open = {cmd = nil, args = {}},
|
||||
view = {
|
||||
width = 30,
|
||||
height = 30,
|
||||
hide_root_folder = false,
|
||||
side = 'left',
|
||||
}
|
||||
view = {width = 30, height = 30, hide_root_folder = false, side = 'left'}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user