Skip to content

Commit

Permalink
refactor(nvim): clean cmp config
Browse files Browse the repository at this point in the history
  • Loading branch information
kutsan committed Apr 18, 2024
1 parent 527c559 commit 9ab4b86
Showing 1 changed file with 41 additions and 32 deletions.
73 changes: 41 additions & 32 deletions .config/nvim/plugin/packages/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ local luasnip = require('luasnip')
local fn = vim.fn

local kind_icons = {
Text = "",
Method = "󰆧",
Function = "󰊕",
Constructor = "",
Field = "󰇽",
Variable = "󰀫",
Class = "󰠱",
Interface = "",
Module = "",
Property = "󰜢",
Unit = "",
Value = "󰎠",
Enum = "",
Keyword = "󰌋",
Snippet = "",
Color = "󰏘",
File = "󰈙",
Reference = "",
Folder = "󰉋",
EnumMember = "",
Constant = "󰏿",
Struct = "",
Event = "",
Operator = "󰆕",
TypeParameter = "󰅲",
Text = '',
Method = '󰆧',
Function = '󰊕',
Constructor = '',
Field = '󰇽',
Variable = '󰀫',
Class = '󰠱',
Interface = '',
Module = '',
Property = '󰜢',
Unit = '',
Value = '󰎠',
Enum = '',
Keyword = '󰌋',
Snippet = '',
Color = '󰏘',
File = '󰈙',
Reference = '',
Folder = '󰉋',
EnumMember = '',
Constant = '󰏿',
Struct = '',
Event = '',
Operator = '󰆕',
TypeParameter = '󰅲',
}

cmp.setup({
Expand Down Expand Up @@ -80,14 +80,23 @@ cmp.setup({
}),
['<Tab>'] = cmp.mapping(function(fallback)
local function has_words_before()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
local row_position, column_position =
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
if column_position == 0 then
return false
end

local current_line = vim.api.nvim_buf_get_lines(
0,
row_position - 1,
row_position,
false
)[1]
local character_at_cursor =
current_line:sub(column_position + 1, column_position + 1)

return character_at_cursor:match('%s') == nil
end

if cmp.visible() then
Expand Down

0 comments on commit 9ab4b86

Please sign in to comment.