Skip to content

Commit

Permalink
Improve regex handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsh7th committed Nov 9, 2021
1 parent c7a1b9f commit a62375e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lua/cmp/context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ end
---@return number|nil
context.get_offset = function(self, keyword_pattern)
return self.cache:ensure({ 'get_offset', keyword_pattern, self.cursor_before_line }, function()
return pattern.offset(keyword_pattern .. '$', self.cursor_before_line) or self.cursor.col
return pattern.offset(keyword_pattern .. '\\m$', self.cursor_before_line) or self.cursor.col
end)
end

Expand Down
31 changes: 14 additions & 17 deletions plugin/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,31 @@ vim.cmd [[
autocmd CompleteDone * lua require'cmp.utils.autocmd'.emit('CompleteDone')
autocmd ColorScheme * call v:lua.cmp.plugin.colorscheme()
autocmd CmdlineEnter * call v:lua.cmp.plugin.cmdline.enter()
autocmd CmdlineLeave * call v:lua.cmp.plugin.cmdline.leave()
augroup END
]]

misc.set(_G, { 'cmp', 'plugin', 'cmdline', 'enter' }, function()
if config.get().experimental.native_menu then
return
end
local cmdtype = vim.fn.expand('<afile>')
if cmdtype ~= '=' then
if api.is_cmdline_mode() then
vim.cmd [[
augroup cmp-cmdline
autocmd!
autocmd CmdlineChanged * lua require'cmp.utils.autocmd'.emit('TextChanged')
augroup END
]]
require('cmp.utils.autocmd').emit('CmdlineEnter')
end
if vim.fn.expand('<afile>')~= '=' then
vim.schedule(function()
if api.is_cmdline_mode() then
vim.cmd [[
augroup cmp-cmdline
autocmd!
autocmd CmdlineChanged * lua require'cmp.utils.autocmd'.emit('TextChanged')
autocmd CmdlineLeave * call v:lua.cmp.plugin.cmdline.leave()
augroup END
]]
require('cmp.utils.autocmd').emit('CmdlineEnter')
end
end)
end
end)

misc.set(_G, { 'cmp', 'plugin', 'cmdline', 'leave' }, function()
if config.get().experimental.native_menu then
return
end
local cmdtype = vim.fn.expand('<afile>')
if cmdtype ~= '=' then
if vim.fn.expand('<afile>') ~= '=' then
vim.cmd [[
augroup cmp-cmdline
autocmd!
Expand Down

0 comments on commit a62375e

Please sign in to comment.