fix: move cmp to its own file

This commit is contained in:
2025-08-18 01:57:27 -07:00
parent d6bc118d05
commit ab3d0c868f
2 changed files with 121 additions and 176 deletions

View File

@@ -1,71 +1,71 @@
local function setup_keybinds() local function setup_keybinds()
vim.keymap.set("n", "gd", vim.lsp.buf.definition) vim.keymap.set("n", "gd", vim.lsp.buf.definition)
vim.keymap.set("n", "ev", function() vim.keymap.set("n", "ev", function()
vim.diagnostic.open_float({ border = "rounded" }) vim.diagnostic.open_float({ border = "rounded" })
end) end)
vim.keymap.set("n", "K", function() vim.keymap.set("n", "K", function()
vim.lsp.buf.hover({ border = "rounded" }) vim.lsp.buf.hover({ border = "rounded" })
end) end)
vim.keymap.set("i", "<C-s>", function() vim.keymap.set("i", "<C-s>", function()
vim.lsp.buf.signature_help({ border = "rounded" }) vim.lsp.buf.signature_help({ border = "rounded" })
end) end)
vim.diagnostic.config({ virtual_text = true }) vim.diagnostic.config({ virtual_text = true })
end end
return { return {
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
dependencies = { "hrsh7th/cmp-cmdline", dependencies = { "hrsh7th/cmp-cmdline",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
},
config = function()
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
}, },
config = function() window = {
local cmp = require("cmp") completion = cmp.config.window.bordered(),
cmp.setup({ documentation = cmp.config.window.bordered(),
snippet = { },
expand = function(args) mapping = cmp.mapping.preset.insert({
require("luasnip").lsp_expand(args.body) ["<C-b>"] = cmp.mapping.scroll_docs(-4),
end, ["<C-f>"] = cmp.mapping.scroll_docs(4),
}, ["<C-Space>"] = cmp.mapping.complete(),
window = { ["<C-e>"] = cmp.mapping.abort(),
completion = cmp.config.window.bordered(), ["<CR>"] = cmp.mapping.confirm({ select = true }),
documentation = cmp.config.window.bordered(), }),
}, sources = cmp.config.sources({
mapping = cmp.mapping.preset.insert({ { name = "nvim_lsp" },
["<C-b>"] = cmp.mapping.scroll_docs(-4), { name = "luasnip" },
["<C-f>"] = cmp.mapping.scroll_docs(4), }, {
["<C-Space>"] = cmp.mapping.complete(), { name = "buffer" },
["<C-e>"] = cmp.mapping.abort(), }),
["<CR>"] = cmp.mapping.confirm({ select = true }), })
}), local capabilities = require("cmp_nvim_lsp").default_capabilities()
sources = cmp.config.sources({ setup_keybinds()
{ name = "nvim_lsp" }, vim.lsp.config("*", {
{ name = "luasnip" }, capabilities = capabilities,
}, { })
{ name = "buffer" }, cmp.setup.cmdline({ "/", "?" }, {
}), mapping = cmp.mapping.preset.cmdline(),
}) sources = {
local capabilities = require("cmp_nvim_lsp").default_capabilities() { name = "buffer" },
setup_keybinds() },
vim.lsp.config("*", { })
capabilities = capabilities, cmp.setup.cmdline(":", {
}) mapping = cmp.mapping.preset.cmdline(),
cmp.setup.cmdline({ "/", "?" }, { sources = cmp.config.sources({
mapping = cmp.mapping.preset.cmdline(), { name = "path" },
sources = { }, {
{ name = "buffer" }, { name = "cmdline" },
}, }),
}) matching = { disallow_symbol_nonprefix_matching = false },
cmp.setup.cmdline(":", { })
mapping = cmp.mapping.preset.cmdline(), end
sources = cmp.config.sources({ }
{ name = "path" },
}, {
{ name = "cmdline" },
}),
matching = { disallow_symbol_nonprefix_matching = false },
})
end
}
} }

View File

@@ -1,117 +1,62 @@
local function setup_luau() local function setup_luau()
require("luau-lsp").setup({ require("luau-lsp").setup({
platform = { platform = {
type = "roblox", type = "roblox",
}, },
types = { types = {
roblox_security_level = "PluginSecurity", roblox_security_level = "PluginSecurity",
}, },
sourcemap = { sourcemap = {
enabled = true, enabled = true,
autogenerate = true, autogenerate = true,
rojo_project_file = "default.project.json", rojo_project_file = "default.project.json",
sourcemap_file = "sourcemap.json", sourcemap_file = "sourcemap.json",
}, },
plugin = { plugin = {
enabled = true, enabled = true,
port = 3667, port = 3667,
}, },
fflags = { fflags = {
enable_new_solver = true, enable_new_solver = true,
sync = true, sync = true,
}, },
}) })
end end
return { return {
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = { dependencies = {
"williamboman/mason.nvim", "williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
"j-hui/fidget.nvim", "j-hui/fidget.nvim",
"lopi-py/luau-lsp.nvim", "lopi-py/luau-lsp.nvim",
},
config = function()
require("mason").setup()
require("fidget").setup({
notification = {
window = {
winblend = 0,
},
},
})
require("mason-lspconfig").setup({
ensure_installed = {
"ts_ls",
"lua_ls",
"luau_lsp",
"rust_analyzer",
"nil_ls",
"tailwindcss",
"svelte",
"html",
"gopls",
"templ",
},
automatic_enable = { exclude = { "luau_lsp" } },
})
setup_luau()
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
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-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
}, {
{ name = "buffer" },
}),
})
local capabilities = require("cmp_nvim_lsp").default_capabilities()
vim.lsp.config("*", {
capabilities = capabilities,
})
vim.keymap.set("n", "gtd", vim.lsp.buf.definition)
vim.keymap.set("n", "ev", function()
vim.diagnostic.open_float({ border = "rounded" })
end)
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover({ border = "rounded" })
end)
vim.keymap.set("i", "<C-s>", function()
vim.lsp.buf.signature_help({ border = "rounded" })
end)
vim.diagnostic.config({ virtual_text = true })
cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
},
})
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
matching = { disallow_symbol_nonprefix_matching = false },
})
end,
}, },
config = function()
require("mason").setup()
require("fidget").setup({
notification = {
window = {
winblend = 0,
},
},
})
require("mason-lspconfig").setup({
ensure_installed = {
"ts_ls",
"lua_ls",
"luau_lsp",
"rust_analyzer",
"nil_ls",
"tailwindcss",
"svelte",
"html",
"gopls",
"templ",
},
automatic_enable = { exclude = { "luau_lsp" } },
})
setup_luau()
end,
},
} }