chore: fix formatting

This commit is contained in:
2024-04-19 17:25:24 +02:00
parent 7d7699474d
commit 096a4713ae
2 changed files with 48 additions and 52 deletions
+7 -6
View File
@@ -6,18 +6,19 @@ return {
dependencies = { dependencies = {
"python3", "python3",
}, },
py_module_deps = {
"venv",
},
mason = { mason = {
name = "python-lsp-server", name = "python-lsp-server",
post_install = { post_install = {
{ {
command = "./venv/bin/pip", command = "./venv/bin/pip",
-- command = "sh",
args = { args = {
"install", -- "install",
"python-lsp-black", -- "python-lsp-black",
"python-lsp-isort", -- "python-lsp-isort",
"--version",
-- "-c",
-- "./venv/bin/pip --version",
}, },
}, },
-- { -- {
+41 -46
View File
@@ -6,44 +6,47 @@ local function has_words_before()
unpack = unpack or table.unpack unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1] and vim.api
:sub(col, col) .nvim_buf_get_lines(0, line - 1, line, true)[1]
:match(word_pattern) ~= nil :sub(col, col)
:match(word_pattern)
~= nil
end end
local function has_words_after() local function has_words_after()
unpack = unpack or table.unpack unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1] and vim.api
:sub(col + 1, col + 1) .nvim_buf_get_lines(0, line - 1, line, true)[1]
:match(word_pattern) ~= nil :sub(col + 1, col + 1)
:match(word_pattern)
~= nil
end end
local function setup() local function setup()
local module_name = "plugins.config.cmp"
local utils = require("utils") local utils = require("utils")
local cmp = require("cmp") local cmp = require("cmp")
local luasnip = require("luasnip") local luasnip = require("luasnip")
local lspkind = utils.try_require("lspkind", module_name) local lspkind = utils.try_require("lspkind")
local opt = { local opt = {
preselect = cmp.PreselectMode.None, preselect = cmp.PreselectMode.None,
completion = { keyword_length = 0, }, completion = { keyword_length = 0 },
snippet = { snippet = {
expand = function (args) expand = function(args)
luasnip.lsp_expand(args.body) luasnip.lsp_expand(args.body)
end, end,
}, },
formatting = { formatting = {
format = function (entry, vim_item) format = function(entry, vim_item)
if lspkind then if lspkind then
vim_item = lspkind.cmp_format({ vim_item = lspkind.cmp_format({
mode = "symbol", mode = "symbol",
maxwidth = 50, maxwidth = 50,
ellipsis_char = "...", ellipsis_char = "...",
before = function (_, item) before = function(_, item)
item.dup = 0 -- remove duplicates, see nvim-cmp #511 item.dup = 0 -- remove duplicates, see nvim-cmp #511
return item return item
end, end,
})(entry, vim_item) })(entry, vim_item)
@@ -59,36 +62,36 @@ local function setup()
["<C-n>"] = cmp.mapping.select_next_item({ ["<C-n>"] = cmp.mapping.select_next_item({
behavior = cmp.SelectBehavior.Select, behavior = cmp.SelectBehavior.Select,
}), }),
["<C-y>"] = function (fallback) ["<C-y>"] = function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, }) cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace })
else else
fallback() fallback()
end end
end, end,
["<C-x><C-o>"] = cmp.mapping.complete(), ["<C-x><C-o>"] = cmp.mapping.complete(),
["<C-l>"] = function (fallback) ["<C-l>"] = function(fallback)
if luasnip.expand_or_locally_jumpable() then if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
else else
fallback() fallback()
end end
end, end,
["<C-h>"] = function (fallback) ["<C-h>"] = function(fallback)
if luasnip.locally_jumpable(-1) then if luasnip.locally_jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, end,
["<C-b>"] = function (fallback) ["<C-b>"] = function(fallback)
if cmp.visible_docs() then if cmp.visible_docs() then
cmp.scroll_docs(-4) cmp.scroll_docs(-4)
else else
fallback() fallback()
end end
end, end,
["<C-f>"] = function (fallback) ["<C-f>"] = function(fallback)
if cmp.visible_docs() then if cmp.visible_docs() then
cmp.scroll_docs(4) cmp.scroll_docs(4)
else else
@@ -97,47 +100,39 @@ local function setup()
end, end,
}, },
sources = { sources = {
{ name = "nvim_lsp", }, { name = "nvim_lsp" },
-- { name = "luasnip", }, -- { name = "luasnip", },
{ name = "orgmode", }, { name = "orgmode" },
{ name = "path", }, { name = "path" },
}, },
} }
utils.try_require("moonfly", module_name, function (_) if utils.try_require("moonfly") then
local winhighlight = { local winhighlight = {
winhighlight = winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel",
"Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel",
} }
opt.window = { opt.window = {
completion = cmp.config.window.bordered(winhighlight), completion = cmp.config.window.bordered(winhighlight),
documentation = cmp.config.window.bordered(winhighlight), documentation = cmp.config.window.bordered(winhighlight),
} }
end) end
cmp.setup(opt) cmp.setup(opt)
cmp.setup.cmdline( cmp.setup.cmdline("/", {
"/", mapping = cmp.mapping.preset.cmdline(),
{ sources = { { name = "buffer" } },
mapping = cmp.mapping.preset.cmdline(), })
sources = { { name = "buffer", }, },
}
)
cmp.setup.cmdline( cmp.setup.cmdline(":", {
":", mapping = cmp.mapping.preset.cmdline(),
{ sources = cmp.config.sources({ { name = "path" } }, {
mapping = cmp.mapping.preset.cmdline(), {
sources = cmp.config.sources( name = "cmdline",
{ { name = "path", }, }, option = { ignore_cmds = { "Man", "!" } },
{ { },
name = "cmdline", }),
option = { ignore_cmds = { "Man", "!", }, }, })
}, }
),
}
)
end end
return setup return setup