Format workspace with CodeFormat

This commit is contained in:
2023-09-02 17:29:59 +02:00
parent 214ffd053d
commit ae3bc212a9
63 changed files with 1205 additions and 1061 deletions
+47 -47
View File
@@ -14,44 +14,44 @@
limitations under the License.
]]
local has_words_before = function()
local has_words_before = function ()
unpack = unpack or table.unpack
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 cmp = require('cmp')
local luasnip = require('luasnip')
local lspkind = require('lspkind')
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
cmp.setup({
enabled = function()
enabled = function ()
-- disable completion in comments
local context = require 'cmp.config.context'
local context = require "cmp.config.context"
-- keep command mode completion enabled when cursor is in a comment
if vim.api.nvim_get_mode().mode == 'c' then
if vim.api.nvim_get_mode().mode == "c" then
return true
else
return not context.in_treesitter_capture('comment') and
not context.in_syntax_group('Comment')
return not context.in_treesitter_capture("comment") and
not context.in_syntax_group("Comment")
end
end,
completion = { keyword_length = 3 },
completion = { keyword_length = 3, },
snippet = {
expand = function(args)
expand = function (args)
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
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
end,
},
formatting = {
format = function(entry, vim_item)
format = function (entry, vim_item)
vim_item = lspkind.cmp_format({
mode = 'text', -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
mode = "text", -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
ellipsis_char =
'...' -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
"...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
-- The function below will be called before any actual modifications from lspkind
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
@@ -64,30 +64,30 @@ cmp.setup({
vim_item.dup = 0
return vim_item
end
end,
},
experimental = { ghost_text = true },
experimental = { ghost_text = true, },
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping(
function(fallback)
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.confirm(
{
behavior = cmp.ConfirmBehavior.Replace,
select = true
select = true,
}
)
-- vim.api.nvim_feedkeys('(', 'i', true)
else
fallback()
end
end, { 'i', 's' }
end, { "i", "s", }
),
-- ['<Down>'] = cmp.mapping(
-- function(fallback)
@@ -112,8 +112,8 @@ cmp.setup({
-- end
-- end, { 'i', 's' }
-- ),
['<Tab>'] = cmp.mapping(
function(fallback)
["<Tab>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls within expand_or_locally_jumpable()
@@ -125,11 +125,11 @@ cmp.setup({
else
fallback()
end
end, { 'i', 's' }
end, { "i", "s", }
),
['<S-Tab>'] = cmp.mapping(
function(fallback)
["<S-Tab>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
@@ -137,20 +137,20 @@ cmp.setup({
else
fallback()
end
end, { 'i', 's' }
)
end, { "i", "s", }
),
},
sources = {
-- { name = 'buffer' },
{ name = 'path' },
{ name = 'nvim_lsp' },
{ name = "path", },
{ name = "nvim_lsp", },
-- { name = 'nvim_lsp_signature_help' },
-- { name = 'nvim_lua' },
-- { name = 'vsnip' }, -- For vsnip users.
{ name = 'luasnip' } -- For luasnip users.
{ name = "luasnip", }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}
},
})
-- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
-- -- gray
@@ -171,26 +171,26 @@ cmp.setup({
-- vim.fn.execute("highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4")
cmp.setup.cmdline(
'/',
"/",
{
mapping = cmp.mapping.preset.cmdline(),
sources = { { name = 'buffer' } }
sources = { { name = "buffer", }, },
}
)
cmp.setup.cmdline(
':',
":",
{
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources(
{ { name = 'path' } },
{ { name = 'cmdline', option = { ignore_cmds = { 'Man', '!' } } } }
)
{ { name = "path", }, },
{ { name = "cmdline", option = { ignore_cmds = { "Man", "!", }, }, }, }
),
}
)
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on(
'confirm_done',
"confirm_done",
cmp_autopairs.on_confirm_done()
)