Compare commits

...

3 Commits

Author SHA1 Message Date
Patrick 2934dd2ed9 refactored editor config 2024-08-23 11:45:45 +02:00
Patrick 7c2d1a4bfb configured nvim-cmp 2024-08-23 11:45:03 +02:00
Patrick 07e6061b84 configured colorizer 2024-08-21 23:40:39 +02:00
5 changed files with 100 additions and 17 deletions

View File

@ -1,4 +1,7 @@
require("config.looks")
require("config.lazy")
require("config.behaviour")
require("config.keymap")

View File

@ -1,22 +1,9 @@
-- Encoding
vim.opt.encoding = "UTF-8"
-- Line numbers
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.cursorline = true
-- Formatting
-- -- Indent
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.autoindent = true
vim.opt.expandtab = false
-- Terminal
vim.opt.wildmenu = true
vim.opt.showcmd = true
vim.opt.showmatch = true
--vim.opt.wildmenu = true
--vim.opt.showmatch = true
-- Mouse
vim.opt.mouse = "a"

19
lua/config/looks.lua Normal file
View File

@ -0,0 +1,19 @@
-- for colorizer.nvim
vim.o.termguicolors = true
-- Line numbers
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.cursorline = true
-- Commands
vim.opt.showcmd = true
-- Formatting
-- -- Indent
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.autoindent = true
vim.opt.expandtab = false
vim.opt.softtabstop = 4

View File

@ -49,18 +49,20 @@ return {
},
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
event = { "InsertEnter", "CmdlineEnter", },
dependencies = {
-- Snippet engine
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
-- Plugins
"hrsh7th/cmp-buffer", -- indexer
"hrsh7th/cmp-path", -- Autocomplete for filesystem paths
"hrsh7th/cmp-cmdline", -- Autocomplete for vims commandline
"hrsh7th/cmp-nvim-lua", -- Autocomplete for vim options
-- Looks
"onsails/lspkind.nvim", -- Add symbols for type
},
config = function()
local cmp = require("cmp")
@ -71,12 +73,63 @@ return {
require("luasnip").lsp_expand(args.body)
end
},
view = {
entries = {
name = 'custom',
selection_order = 'near_cursor'
}
},
formatting = {
format = require("lspkind").cmp_format({
mode = "symbol_text",
maxwidth = 50,
ellipsis_char = "...",
show_labelDetails = true,
}),
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
mapping = {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
if #cmp.get_entries() == 1 then
cmp.confirm({ select = true })
else
cmp.select_next_item()
end
--[[ Replace with your snippet engine (see above sections on this page)
elseif snippy.can_expand_or_advance() then
snippy.expand_or_advance()
elseif has_words_before() then
cmp.complete()
if #cmp.get_entries() == 1 then
cmp.confirm({ select = true })
end]]
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
end
end, { "i", "s", "c" }),
["<CR>"] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
else
fallback()
end
end,
s = cmp.mapping.confirm({ select = true }),
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace }),
}),
},
enabled = function()
local context = require("cmp.config.context")
-- disable in autocomplete in comments
@ -101,5 +154,7 @@ return {
matching = { disallow_symbol_nonprefix_matching = false }
})
end
},
{
}
}

View File

@ -1,6 +1,25 @@
return {
{
-- Package installer (for LSPs)
"williamboman/mason.nvim",
opts = {}
},
{
-- Highlight color codes (like #A3F041)
"norcalli/nvim-colorizer.lua",
-- event = { "BufNew" }, -- will not call autocmd when opening a file the first time
config = function()
require("colorizer").setup({'*'}, { RRGGBBAA = true })
-- trigger highlighting when opening a new buffer
vim.api.nvim_create_autocmd(
{ "BufNew", "BufRead" },
{
callback = function()
local colorizer = require("colorizer")
colorizer.attach_to_buffer(0, colorizer.get_buffer_options(0))
end
})
end,
}
}