2024-01-27 22:20:35 +00:00
|
|
|
-- Copilot provider
|
|
|
|
require("copilot").setup({
|
|
|
|
suggestion = { enabled = false },
|
|
|
|
panel = { enabled = false },
|
|
|
|
filetypes = {
|
|
|
|
javascript = true,
|
|
|
|
typescript = true,
|
|
|
|
rust = true,
|
2024-02-06 20:22:41 +00:00
|
|
|
go = true,
|
|
|
|
yaml = true,
|
|
|
|
python = true,
|
2024-02-10 13:34:27 +00:00
|
|
|
css = true,
|
|
|
|
tmpl = true,
|
2024-03-01 13:29:59 +00:00
|
|
|
tf = true,
|
|
|
|
terraform = true,
|
2024-01-27 22:20:35 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
require("copilot_cmp").setup()
|
|
|
|
|
|
|
|
-- Codeium provider
|
|
|
|
require("codeium").setup({})
|
|
|
|
|
|
|
|
-- Git providers
|
|
|
|
require("cmp_git").setup()
|
|
|
|
|
|
|
|
local cmp = require("cmp")
|
2024-01-28 17:41:33 +00:00
|
|
|
local lspkind = require("lspkind")
|
|
|
|
lspkind.init({
|
|
|
|
symbol_map = { Copilot = "", Codeium = "" },
|
|
|
|
})
|
|
|
|
vim.opt.completeopt = "menu,menuone,noselect"
|
2024-01-27 22:20:35 +00:00
|
|
|
cmp.setup({
|
2024-01-28 17:41:33 +00:00
|
|
|
formatting = {
|
|
|
|
fields = { "abbr", "kind" },
|
|
|
|
format = lspkind.cmp_format({
|
|
|
|
mode = "symbol_text",
|
|
|
|
maxwidth = function()
|
|
|
|
return math.min(40, math.floor(vim.o.columns * 0.4))
|
|
|
|
end,
|
|
|
|
ellipsis_char = "...",
|
|
|
|
before = function(entry, item)
|
|
|
|
item.menu = ""
|
|
|
|
return item
|
|
|
|
end,
|
|
|
|
}),
|
|
|
|
},
|
2024-01-27 22:20:35 +00:00
|
|
|
snippet = {
|
|
|
|
-- REQUIRED - you must specify a snippet engine
|
|
|
|
expand = function(args)
|
2024-02-29 09:48:46 +00:00
|
|
|
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
2024-01-27 22:20:35 +00:00
|
|
|
-- 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,
|
|
|
|
},
|
|
|
|
window = {
|
|
|
|
-- completion = cmp.config.window.bordered(),
|
|
|
|
-- documentation = cmp.config.window.bordered(),
|
|
|
|
},
|
|
|
|
mapping = cmp.mapping.preset.insert({
|
|
|
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
|
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
|
|
["<C-e>"] = cmp.mapping.abort(),
|
2024-01-28 17:41:33 +00:00
|
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
2024-02-06 20:22:41 +00:00
|
|
|
-- This little snippet will confirm with tab, and if no entry is selected, will confirm the first item
|
2024-01-28 17:41:33 +00:00
|
|
|
if cmp.visible() then
|
2024-02-06 20:22:41 +00:00
|
|
|
local entry = cmp.get_selected_entry()
|
|
|
|
if not entry then
|
|
|
|
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
|
|
|
else
|
|
|
|
cmp.confirm()
|
|
|
|
end
|
2024-01-28 17:41:33 +00:00
|
|
|
else
|
2024-02-06 20:22:41 +00:00
|
|
|
fallback()
|
2024-01-28 17:41:33 +00:00
|
|
|
end
|
2024-02-06 20:22:41 +00:00
|
|
|
end, { "i", "s", "c" }),
|
2024-01-27 22:20:35 +00:00
|
|
|
}),
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = "copilot" },
|
|
|
|
{ name = "codeium" },
|
|
|
|
{ name = "nvim_lsp" },
|
|
|
|
{ name = "git" },
|
|
|
|
-- { name = 'vsnip' }, -- For vsnip users.
|
|
|
|
-- { name = 'luasnip' }, -- For luasnip users.
|
|
|
|
-- { name = 'ultisnips' }, -- For ultisnips users.
|
|
|
|
-- { name = 'snippy' }, -- For snippy users.
|
|
|
|
}, {
|
|
|
|
{ name = "buffer" },
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Set configuration for specific filetype.
|
|
|
|
cmp.setup.filetype("gitcommit", {
|
|
|
|
sources = cmp.config.sources({
|
2024-02-06 20:22:41 +00:00
|
|
|
{ name = "git" },
|
2024-01-27 22:20:35 +00:00
|
|
|
}, {
|
|
|
|
{ name = "buffer" },
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
|
|
|
cmp.setup.cmdline({ "/", "?" }, {
|
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
|
|
sources = {
|
|
|
|
{ name = "buffer" },
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
|
|
|
cmp.setup.cmdline(":", {
|
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = "path" },
|
|
|
|
}, {
|
|
|
|
{ name = "cmdline" },
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
|
|
|
|
-- LSP
|
|
|
|
require("mason").setup({
|
|
|
|
ui = {
|
|
|
|
icons = {
|
|
|
|
package_installed = "✓",
|
|
|
|
package_pending = "➜",
|
|
|
|
package_uninstalled = "✗",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require("mason-lspconfig").setup({
|
|
|
|
ensure_installed = {
|
|
|
|
"typos_lsp", -- all
|
|
|
|
"angularls", -- angular
|
|
|
|
"ansiblels", -- ansible
|
|
|
|
"bashls", -- bash
|
|
|
|
"bufls", -- buf
|
|
|
|
"cssls", -- css
|
2024-02-01 08:17:18 +00:00
|
|
|
-- "denols", -- deno
|
2024-01-27 22:20:35 +00:00
|
|
|
"dockerls", -- docker
|
|
|
|
"docker_compose_language_service", -- docker-compose
|
|
|
|
"eslint", -- eslint
|
|
|
|
"elixirls", -- elixir
|
2024-02-29 09:48:46 +00:00
|
|
|
"gopls", -- golang
|
2024-01-27 22:20:35 +00:00
|
|
|
"graphql", -- graphql
|
|
|
|
"html", -- html
|
|
|
|
"htmx", -- htmx
|
|
|
|
"helm_ls", -- helm
|
|
|
|
"jsonls", -- json
|
|
|
|
"tsserver", -- javascript/typescript
|
|
|
|
"marksman", -- markdown
|
|
|
|
"vale_ls", -- markdown/prose
|
|
|
|
"swift_mesonls", -- meson
|
|
|
|
"prismals", -- prisma
|
|
|
|
"pyright", -- python
|
|
|
|
"rust_analyzer", -- rust
|
|
|
|
"taplo", -- toml
|
|
|
|
"terraformls", -- terraform
|
|
|
|
"tflint", -- terraform
|
|
|
|
"yamlls", -- yaml
|
|
|
|
},
|
|
|
|
automatic_installation = true,
|
|
|
|
})
|
|
|
|
|
|
|
|
require("mason-lspconfig").setup_handlers({
|
2024-02-29 09:48:46 +00:00
|
|
|
function(server_name)
|
2024-01-27 22:20:35 +00:00
|
|
|
require("lspconfig")[server_name].setup({
|
|
|
|
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Formatter
|
|
|
|
local util = require("formatter.util")
|
|
|
|
require("formatter").setup({
|
|
|
|
logging = true,
|
|
|
|
log_level = vim.log.levels.WARN,
|
|
|
|
-- All formatter configurations are opt-in
|
|
|
|
filetype = {
|
|
|
|
lua = {
|
|
|
|
require("formatter.filetypes.lua").stylua,
|
|
|
|
},
|
|
|
|
javascript = {
|
|
|
|
require("formatter.filetypes.javascript").prettier,
|
|
|
|
},
|
|
|
|
typescript = {
|
|
|
|
require("formatter.filetypes.typescript").prettier,
|
|
|
|
},
|
|
|
|
json = {
|
|
|
|
require("formatter.filetypes.json").prettier,
|
|
|
|
},
|
|
|
|
graphql = {
|
|
|
|
require("formatter.filetypes.graphql").prettier,
|
|
|
|
},
|
2024-02-29 11:16:12 +00:00
|
|
|
html = {
|
|
|
|
require("formatter.filetypes.html").prettier,
|
|
|
|
},
|
|
|
|
template = {
|
|
|
|
function()
|
|
|
|
local prettierForGoTemplate = require("formatter.defaults.prettier")()
|
|
|
|
table.insert(prettierForGoTemplate.args, "--plugin")
|
|
|
|
table.insert(prettierForGoTemplate.args, "prettier-plugin-go-template")
|
|
|
|
return prettierForGoTemplate
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
css = {
|
|
|
|
require("formatter.filetypes.css").prettier,
|
|
|
|
},
|
2024-01-27 22:20:35 +00:00
|
|
|
rust = {
|
|
|
|
require("formatter.filetypes.rust").rustfmt,
|
|
|
|
},
|
|
|
|
go = {
|
|
|
|
require("formatter.filetypes.go").gofmt,
|
|
|
|
},
|
|
|
|
python = {
|
|
|
|
require("formatter.filetypes.python").black,
|
|
|
|
},
|
|
|
|
elixir = {
|
|
|
|
require("formatter.filetypes.elixir").mix_format,
|
|
|
|
},
|
|
|
|
sh = {
|
|
|
|
require("formatter.filetypes.sh").shfmt,
|
|
|
|
},
|
|
|
|
proto = {
|
|
|
|
require("formatter.filetypes.proto").buf_format,
|
|
|
|
},
|
2024-03-01 13:29:59 +00:00
|
|
|
terraform = {
|
|
|
|
require("formatter.filetypes.terraform").terraformfmt,
|
|
|
|
},
|
2024-01-27 22:20:35 +00:00
|
|
|
|
|
|
|
-- Use the special "*" filetype for defining formatter configurations on
|
|
|
|
-- any filetype
|
|
|
|
["*"] = {
|
|
|
|
-- "formatter.filetypes.any" defines default configurations for any
|
|
|
|
-- filetype
|
|
|
|
require("formatter.filetypes.any").remove_trailing_whitespace,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
local augroup = vim.api.nvim_create_augroup
|
|
|
|
local autocmd = vim.api.nvim_create_autocmd
|
|
|
|
augroup("__formatter__", { clear = true })
|
|
|
|
autocmd("BufWritePost", {
|
|
|
|
group = "__formatter__",
|
|
|
|
command = ":FormatWrite",
|
|
|
|
})
|
2024-01-28 10:41:46 +00:00
|
|
|
|
|
|
|
require("trouble").setup({})
|
2024-04-25 09:12:44 +00:00
|
|
|
|
|
|
|
-- Git
|
|
|
|
require("neogit").setup({})
|