This commit is contained in:
ksyasuda
2023-08-11 18:12:35 -07:00
parent e0a811ea58
commit e582ebeab1
7 changed files with 286 additions and 344 deletions

View File

@@ -15,12 +15,12 @@ require("null-ls").setup({
sources = {
-- null_ls.builtins.completion.spell,
null_ls.builtins.completion.luasnip,
null_ls.builtins.code_actions.gitsigns,
-- null_ls.builtins.code_actions.gitsigns,
null_ls.builtins.code_actions.shellcheck,
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.gitlint,
null_ls.builtins.diagnostics.jsonlint,
-- require("null-ls").builtins.diagnostics.luacheck,
require("null-ls").builtins.diagnostics.luacheck,
null_ls.builtins.diagnostics.markdownlint,
-- null_ls.builtins.diagnostics.sqlfluff.with({
-- extra_args = {
@@ -31,28 +31,26 @@ require("null-ls").setup({
null_ls.builtins.diagnostics.pylint,
null_ls.builtins.diagnostics.pydocstyle.with({
extra_args = { "--config=$ROOT/setup.cfg" }
}),
null_ls.builtins.diagnostics.vint,
}), null_ls.builtins.diagnostics.vint,
null_ls.builtins.diagnostics.shellcheck.with({
extra_args = { "-s", "bash", "-o", "add-default-case, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables" }
}),
null_ls.builtins.diagnostics.ansiblelint,
extra_args = {
"-s", "bash", "-o",
"add-default-case, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables"
}
}), null_ls.builtins.diagnostics.ansiblelint,
null_ls.builtins.formatting.json_tool,
-- require("null-ls").builtins.formatting.lua_format,
require("null-ls").builtins.formatting.lua_format,
null_ls.builtins.formatting.markdownlint,
null_ls.builtins.formatting.prettier,
-- handled by lsp server
null_ls.builtins.formatting.prettier, -- handled by lsp server
-- require("null-ls").builtins.formatting.rustfmt,
null_ls.builtins.formatting.shfmt.with({
filetypes = { "sh", "bash" },
extra_args = { "-i", "0", "-ci", "-sr" }
}),
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.djlint,
}), null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort, null_ls.builtins.formatting.djlint
-- null_ls.builtins.hover.printenv
-- null_ls.builtins.formatting.tidy
},
}
})
-- local markdownlint = {

View File

@@ -7,18 +7,18 @@ local luasnip = require 'luasnip'
local highlight = require('cmp.utils.highlight')
local has_words_before = function()
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match("^%s*$") == nil
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
return false
end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and
vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match(
"^%s*$") == nil
end
lspkind.init({
symbol_map = {
Copilot = "",
},
})
lspkind.init({ symbol_map = { Copilot = "" } })
vim.api.nvim_set_hl(0, "CmpItemKindCopilot", {fg ="#6CC644"})
vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" })
cmp.setup({
snippet = {
@@ -27,7 +27,7 @@ cmp.setup({
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,
end
},
capabilities = capabilities,
mapping = {
@@ -59,7 +59,7 @@ cmp.setup({
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
select = false
},
-- ["<Tab>"] = cmp.mapping(function(fallback)
-- if cmp.visible() then
@@ -69,52 +69,36 @@ cmp.setup({
-- else
-- fallback()
-- end
-- end, { "i", "s" }),
-- end, { "i", "s" }),
["<Tab>"] = vim.schedule_wrap(function(fallback)
if cmp.visible() and has_words_before() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
if cmp.visible() and has_words_before() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end),
['<S-Tab>'] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
end
end, { "i", "s"}),
if cmp.visible() then cmp.select_prev_item() end
end, { "i", "s" })
},
window = {
completion = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
col_offset = -3,
side_padding = 0,
border = "rounded",
borderchars = {
"",
"",
"",
"",
"",
"",
"",
"",
},
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
col_offset = -3,
side_padding = 0,
border = "rounded",
borderchars = {
"", "", "", "", "", "", "", ""
}
},
documentation = {
border = "rounded",
borderchars = {
"",
"",
"",
"",
"",
"",
"",
"",
},
-- padding = 15,
border = "rounded",
borderchars = {
"", "", "", "", "", "", "", ""
}
-- padding = 15,
}
},
formatting = {
@@ -122,43 +106,43 @@ cmp.setup({
-- mode = 'symbol_text',
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = require("lspkind").cmp_format({
mode = "symbol_text",
maxwidth = 75,
symbol_map = {
Copilot = "",
Function = "󰊕",
Text = "󰊄",
Method = "󰆧",
Operator = "󰆕",
Keyword = "󰌋",
Variable = "󰂡",
Field = "󰇽",
Class = "󰠱",
Interface = "",
Module = "",
Property = "󰜢",
Unit = "",
Value = "󰎠",
Enum = "",
Snippet = "",
Color = "󰏘",
File = "󰈙",
Reference = "",
Folder = "󰉋",
EnumMember = "",
Constant = "󰏿",
Struct = "",
Event = "",
TypeParameter = "󰅲",
},
})(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. strings[1] .. " "
kind.menu = " (" .. strings[2] .. ")"
local kind = require("lspkind").cmp_format({
mode = "symbol_text",
maxwidth = 75,
symbol_map = {
Copilot = "",
Function = "󰊕",
Text = "󰊄",
Method = "󰆧",
Operator = "󰆕",
Keyword = "󰌋",
Variable = "󰂡",
Field = "󰇽",
Class = "󰠱",
Interface = "",
Module = "",
Property = "󰜢",
Unit = "",
Value = "󰎠",
Enum = "",
Snippet = "",
Color = "󰏘",
File = "󰈙",
Reference = "",
Folder = "󰉋",
EnumMember = "",
Constant = "󰏿",
Struct = "",
Event = "",
TypeParameter = "󰅲"
}
})(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. strings[1] .. " "
kind.menu = " (" .. strings[2] .. ")"
return kind
end,
return kind
end
-- format = lspkind.cmp_format({
-- mode = 'symbol_text', -- show only symbol annotations
-- menu = ({
@@ -171,89 +155,74 @@ cmp.setup({
-- })
},
sources = cmp.config.sources({
{ name = "copilot", group_index = 2 },
{ name = "path", group_index = 2 },
{ name = 'nvim_lsp', group_index = 2 },
{ name = 'nvim_lsp_signature_help', group_index = 2 },
{ name = "copilot", group_index = 2 }, { name = "path", group_index = 2 },
{ name = 'nvim_lsp', group_index = 2 },
{ name = 'nvim_lsp_signature_help', group_index = 2 },
{ name = 'nvim_lsp_document_symbol', group_index = 2 },
{ name = 'luasnip', group_index = 2 }, -- For luasnip users.
{ name = 'luasnip', group_index = 2 }, -- For luasnip users.
{
name = 'buffer',
option = {
get_bufnrs = function()
local bufs = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
bufs[vim.api.nvim_win_get_buf(win)] = true
end
return vim.tbl_keys(bufs)
end
}
name = 'buffer',
option = {
get_bufnrs = function()
local bufs = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
bufs[vim.api.nvim_win_get_buf(win)] = true
end
return vim.tbl_keys(bufs)
end
}
}
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
}),
}, { { name = 'buffer' } }),
sorting = {
priority_weight = 2,
comparators = {
require("copilot_cmp.comparators").prioritize,
require("copilot_cmp.comparators").score,
require("copilot_cmp.comparators").recently_used,
require("copilot_cmp.comparators").kind,
require("copilot_cmp.comparators").sort_text,
require("copilot_cmp.comparators").length,
require("copilot_cmp.comparators").order,
require("copilot_cmp.comparators").prioritize,
require("copilot_cmp.comparators").score,
require("copilot_cmp.comparators").recently_used,
require("copilot_cmp.comparators").kind,
require("copilot_cmp.comparators").sort_text,
require("copilot_cmp.comparators").length,
require("copilot_cmp.comparators").order,
-- Below is the default comparitor list and order for nvim-cmp
cmp.config.compare.offset,
-- cmp.config.compare.scopes, --this is commented in nvim-cmp too
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.recently_used,
cmp.config.compare.locality,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
-- Below is the default comparitor list and order for nvim-cmp
cmp.config.compare.offset,
-- cmp.config.compare.scopes, --this is commented in nvim-cmp too
cmp.config.compare.exact, cmp.config.compare.score,
cmp.config.compare.recently_used, cmp.config.compare.locality,
cmp.config.compare.kind, cmp.config.compare.sort_text,
cmp.config.compare.length, cmp.config.compare.order
}
}
})
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
mapping = cmp.mapping.preset.cmdline(),
sources = { { name = 'buffer' } }
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{
name = 'cmdline',
option = {
ignore_cmds = { 'Man', '!' }
}
}
})
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ { name = 'path' } }, {
{ name = 'cmdline', option = { ignore_cmds = { 'Man', '!' } } }
})
})
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local servers = { 'bashls', 'jedi_language_server', 'sqlls', 'jsonls', 'yamlls', 'vimls', 'dotls', 'dockerls', 'html', 'cssls', 'lua_ls' }
local servers = {
'bashls', 'jedi_language_server', 'sqlls', 'jsonls', 'yamlls', 'vimls',
'dotls', 'dockerls', 'html', 'cssls', 'lua_ls'
}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
-- on_attach = my_custom_on_attach,
capabilities = capabilities,
capabilities = capabilities
}
end
cmp.event:on("menu_opened", function()
vim.b.copilot_suggestion_hidden = true
end)
cmp.event:on("menu_closed", function()
vim.b.copilot_suggestion_hidden = false
end)
cmp.event:on("menu_opened",
function() vim.b.copilot_suggestion_hidden = true end)
cmp.event:on("menu_closed",
function() vim.b.copilot_suggestion_hidden = false end)

View File

@@ -0,0 +1 @@
require 'colorizer'.setup()

View File

@@ -1,34 +1,48 @@
require 'nvim-treesitter.configs'.setup {
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
-- ensure_installed = "maintained",
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = {
"c", "lua", "vim", "vimdoc", "query", "cpp", "python", "bash", "sql",
"yaml", "toml", "dockerfile", "gitcommit", "gitignore", "html", "css",
"javascript", "typescript", "rust", "go", "json", "regex", "latex",
"comment", "cmake", "graphql", "haskell", "java", "php", "ruby",
"sparql", "vue"
},
-- Install languages synchronously (only applied to `ensure_installed`)
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- List of parsers to ignore installing
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (for "all")
-- ignore_install = { "javascript" },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
-- `false` will disable the whole extension
enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
-- disable = { "c", "rust" },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
-- disable = function(lang, buf)
-- local max_filesize = 100 * 1024 -- 100 KB
-- local ok, stats = pcall(vim.loop.fs_stat,
-- vim.api.nvim_buf_get_name(buf))
-- if ok and stats and stats.size > max_filesize then
-- return true
-- end
-- end,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gnn",
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
},
additional_vim_regex_highlighting = false
}
}