mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-03-25 10:52:03 +01:00
106 lines
3.0 KiB
Lua
106 lines
3.0 KiB
Lua
local package = require('core.pack').package
|
|
local conf = require('modules.completion.config')
|
|
|
|
package({
|
|
'neovim/nvim-lspconfig',
|
|
-- used filetype to lazyload lsp
|
|
-- config your language filetype in here
|
|
ft = { 'lua', 'rust', 'c', 'cpp', 'go', 'py', 'nix', 'c', 'cpp', 'js' },
|
|
config = conf.nvim_lsp,
|
|
})
|
|
|
|
package({
|
|
'glepnir/lspsaga.nvim',
|
|
event = 'BufRead',
|
|
dev = false,
|
|
config = conf.lspsaga,
|
|
})
|
|
|
|
package({
|
|
'hrsh7th/nvim-cmp',
|
|
event = 'InsertEnter',
|
|
config = conf.nvim_cmp,
|
|
dependencies = {
|
|
{ 'hrsh7th/cmp-nvim-lsp' },
|
|
{ 'hrsh7th/cmp-path' },
|
|
{ 'hrsh7th/cmp-buffer' },
|
|
{ 'saadparwaiz1/cmp_luasnip' },
|
|
},
|
|
})
|
|
|
|
package({ 'L3MON4D3/LuaSnip', event = 'InsertCharPre', config = conf.lua_snip })
|
|
|
|
-- Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
|
|
package({
|
|
"jose-elias-alvarez/null-ls.nvim",
|
|
dependencies = { "nvim-lua/plenary.nvim" },
|
|
config = function()
|
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
|
require("null-ls").setup({
|
|
sources = {
|
|
-- you must download code formatter by yourself!
|
|
require("null-ls").builtins.formatting.stylua,
|
|
require("null-ls").builtins.formatting.black, -- python
|
|
require("null-ls").builtins.formatting.prettier,
|
|
require("null-ls").builtins.formatting.gofmt, -- provide by go itself
|
|
require("null-ls").builtins.formatting.nixpkgs_fmt,
|
|
require("null-ls").builtins.formatting.beautysh,
|
|
require("null-ls").builtins.formatting.rustfmt,
|
|
},
|
|
-- you can reuse a shared lspconfig on_attach callback here
|
|
on_attach = function(client, bufnr)
|
|
if client.supports_method("textDocument/formatting") then
|
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
group = augroup,
|
|
buffer = bufnr,
|
|
callback = function()
|
|
vim.lsp.buf.format({ async = false })
|
|
end,
|
|
})
|
|
end
|
|
end,
|
|
})
|
|
end,
|
|
})
|
|
|
|
-- A super powerful autopair plugin for Neovim that supports multiple characters.
|
|
package({
|
|
"windwp/nvim-autopairs",
|
|
dependencies = { "hrsh7th/nvim-cmp" },
|
|
event = "InsertEnter",
|
|
config = function()
|
|
local status_ok, npairs = pcall(require, "nvim-autopairs")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
npairs.setup({
|
|
check_ts = true,
|
|
ts_config = {
|
|
lua = { "string", "source" },
|
|
javascript = { "string", "template_string" },
|
|
java = false,
|
|
},
|
|
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
|
fast_wrap = {
|
|
map = "<M-e>",
|
|
chars = { "{", "[", "(", '"', "'" },
|
|
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
|
|
offset = 0, -- Offset from pattern match
|
|
end_key = "$",
|
|
keys = "qwertyuiopzxcvbnmasdfghjkl",
|
|
check_comma = true,
|
|
highlight = "PmenuSel",
|
|
highlight_grey = "LineNr",
|
|
},
|
|
})
|
|
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
|
local cmp_status_ok, cmp = pcall(require, "cmp")
|
|
if not cmp_status_ok then
|
|
return
|
|
end
|
|
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
|
|
end,
|
|
})
|