added neocmake and changed colorizer

This commit is contained in:
Patrick Maschek 2024-08-26 19:46:52 +02:00
parent 2934dd2ed9
commit 659d8fb5d4
2 changed files with 29 additions and 9 deletions

View File

@ -9,7 +9,7 @@ return {
ts_config = { ts_config = {
lua = { "string" }, -- do not add pair in this node lua = { "string" }, -- do not add pair in this node
}, },
-- General config -- General config
map_cr = true, map_cr = true,
}, },
@ -24,8 +24,19 @@ return {
require("mason-lspconfig").setup_handlers { require("mason-lspconfig").setup_handlers {
function(server_name) function(server_name)
require("lspconfig")[server_name].setup { require("lspconfig")[server_name].setup {
capabilities = capabilites, --capabilities = capabilities,
} }
end,
["neocmake"] = function()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require("vim.lsp").set_log_level("TRACE")
require("lspconfig").neocmake.setup({
capabilities = capabilities,
root_dir = function(fname)
return require("lspconfig").util.find_git_ancestor(fname)
end,
})
end end
} }
end end
@ -42,11 +53,12 @@ return {
"asm_lsp", "asm_lsp",
"bashls", "bashls",
"clangd", "clangd",
"lua_ls",
"neocmake", "neocmake",
"pyright", "pyright",
}, },
}, },
}, },
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
event = { "InsertEnter", "CmdlineEnter", }, event = { "InsertEnter", "CmdlineEnter", },
@ -64,7 +76,7 @@ return {
-- Looks -- Looks
"onsails/lspkind.nvim", -- Add symbols for type "onsails/lspkind.nvim", -- Add symbols for type
}, },
config = function() config = function()
local cmp = require("cmp") local cmp = require("cmp")
cmp.setup({ cmp.setup({
@ -73,11 +85,11 @@ return {
require("luasnip").lsp_expand(args.body) require("luasnip").lsp_expand(args.body)
end end
}, },
view = { view = {
entries = { entries = {
name = 'custom', name = 'custom',
selection_order = 'near_cursor' selection_order = 'near_cursor'
} }
}, },
formatting = { formatting = {
format = require("lspkind").cmp_format({ format = require("lspkind").cmp_format({
@ -94,6 +106,7 @@ return {
{ name = "path" }, { name = "path" },
}, },
mapping = { mapping = {
["<C-Space>"] = cmp.mapping.complete(),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
if #cmp.get_entries() == 1 then if #cmp.get_entries() == 1 then
@ -116,7 +129,10 @@ return {
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
else
fallback()
end end
end, { "i", "s", "c" }), end, { "i", "s", "c" }),
["<CR>"] = cmp.mapping({ ["<CR>"] = cmp.mapping({
i = function(fallback) i = function(fallback)

View File

@ -13,11 +13,15 @@ return {
-- trigger highlighting when opening a new buffer -- trigger highlighting when opening a new buffer
vim.api.nvim_create_autocmd( vim.api.nvim_create_autocmd(
{ "BufNew", "BufRead" }, { "BufNew", "BufRead" },
{ {
callback = function() callback = function()
local colorizer = require("colorizer") local colorizer = require("colorizer")
colorizer.attach_to_buffer(0, colorizer.get_buffer_options(0)) local options = nil
if colorizer.is_buffer_attached(0) then
options = colorizer.get_buffer_options(0)
end
colorizer.attach_to_buffer(0, options)
end end
}) })
end, end,