initial commit

This commit is contained in:
2026-04-08 22:34:08 +02:00
commit 2a102a0ee1
14 changed files with 596 additions and 0 deletions

5
init.lua Normal file
View File

@ -0,0 +1,5 @@
require("config")
require("plugins")
require('vim._core.ui2').enable()

82
lua/config.lua Normal file
View File

@ -0,0 +1,82 @@
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Prevents showing extra messages when using completion
vim.opt.shortmess:append("c")
-- Sets the height of the command line area at the bottom
vim.opt.cmdheight = 2
-- Displays the line number for the current line
vim.opt.number = true
-- Displays line numbers relative to the current cursor position
vim.opt.relativenumber = true
-- Time in milliseconds to wait for a mapped sequence to complete
vim.opt.timeoutlen = 500
-- Time in milliseconds of inactivity before calling CursorHold or writing to swap
vim.opt.updatetime = 4000
-- Ignores case when searching patterns
vim.opt.ignorecase = true
-- Automatically switches to case-sensitive search if a capital letter is used
vim.opt.smartcase = true
-- Enables 24-bit RGB colors in the terminal
vim.opt.termguicolors = true
-- Configures the behavior of the insert mode completion menu
vim.opt.completeopt = "menu,menuone,noselect,popup"
-- Number of spaces that a <Tab> character represents
vim.opt.tabstop = 4
-- Number of spaces to use for each step of automatic indentation
vim.opt.shiftwidth = 4
-- Number of spaces that a <Tab> counts for during editing operations
vim.opt.softtabstop = 4
-- Converts tabs into spaces when typing
vim.opt.expandtab = true
-- Automatically inserts an extra level of indentation in some cases
vim.opt.smartindent = true
-- Makes <Tab> insert 'shiftwidth' number of spaces at the start of a line
vim.opt.smarttab = true
-- Incremental and highlight search
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.signcolumn = "yes"
-- Transparent terminal
vim.cmd("highlight Normal ctermbg=NONE")
vim.cmd("highlight NonText ctermbg=NONE")
-- ******
-- REMAPS
-- ******
-- netrw
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
-- move
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
-- del line
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
-- Center when moving
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")

127
lua/plugins/cmp.lua Normal file
View File

@ -0,0 +1,127 @@
-- To use mini icons with blink.cmp
local function get_mini_icon(ctx)
if ctx.source_name == "Path" then
local is_unknown_type = vim.tbl_contains(
{ "link", "socket", "fifo", "char", "block", "unknown" },
ctx.item.data.type
)
local mini_icon, mini_hl, _ = require("mini.icons").get(
is_unknown_type and "os" or ctx.item.data.type,
is_unknown_type and "" or ctx.label
)
if mini_icon then
return mini_icon, mini_hl
end
end
local mini_icon, mini_hl, _ = require("mini.icons").get("lsp", ctx.kind)
return mini_icon, mini_hl
end
vim.api.nvim_create_autocmd('PackChanged', {
callback = function(ev)
print("mqsidjfmqoisdfj")
if ev.data.spec.name == 'blink.cmp' then
local res = vim.system({ 'cargo', 'build', '--release' }, { cwd = ev.data.path })
if vim.v.shell_error ~= 0 then
vim.notify('Failed to compile blink.cmp: ' .. res, vim.log.levels.ERROR)
else
vim.notify('Successfully compiled blink.cmp', vim.log.levels.INFO)
end
end
end,
})
vim.pack.add({
"https://github.com/xzbdmw/colorful-menu.nvim",
{ src = "https://github.com/saghen/blink.cmp", verion = vim.version.range("1.x") },
})
-- You don't need to set these options.
require("colorful-menu").setup({
ls = {
["rust-analyzer"] = {
-- Such as (as Iterator), (use std::io).
extra_info_hl = "@comment",
-- Similar to the same setting of gopls.
align_type_to_right = true,
-- See https://github.com/xzbdmw/colorful-menu.nvim/pull/36
preserve_type_when_truncate = true,
},
clangd = {
-- Such as "From <stdio.h>".
extra_info_hl = "@comment",
-- Similar to the same setting of gopls.
align_type_to_right = true,
-- the hl group of leading dot of "•std::filesystem::permissions(..)"
import_dot_hl = "@comment",
-- See https://github.com/xzbdmw/colorful-menu.nvim/pull/36
preserve_type_when_truncate = true,
},
-- If true, try to highlight "not supported" languages.
fallback = true,
-- this will be applied to label description for unsupport languages
fallback_extra_info_hl = "@comment",
},
-- If the built-in logic fails to find a suitable highlight group for a label,
-- this highlight is applied to the label.
fallback_highlight = "@variable",
-- If provided, the plugin truncates the final displayed text to
-- this width (measured in display cells). Any highlights that extend
-- beyond the truncation point are ignored. When set to a float
-- between 0 and 1, it'll be treated as percentage of the width of
-- the window: math.floor(max_width * vim.api.nvim_win_get_width(0))
-- Default 60.
max_width = 60,
})
vim.api.nvim_set_hl(0, "BlinkCmpMenu", { link = "NormalFloat" })
vim.api.nvim_set_hl(0, "BlinkCmpMenuBorder", { link = "FloatBorder" })
vim.api.nvim_set_hl(0, "BlinkCmpDoc", { link = "NormalFloat" })
vim.api.nvim_set_hl(0, "BlinkCmpDocBorder", { link = "FloatBorder" })
require("blink.cmp").setup({
keymap = { preset = "super-tab" },
signature = { enabled = true },
sources = {
default = { "lsp", "path", "buffer" },
},
completion = {
documentation = { auto_show = false },
menu = {
-- border = "single",
draw = {
-- We don't need label_description now because label and label_description are already
-- combined together in label by colorful-menu.nvim.
columns = { { "kind_icon" }, { "label", gap = 1 } },
components = {
label = {
text = function(ctx)
return require("colorful-menu").blink_components_text(ctx)
end,
highlight = function(ctx)
return require("colorful-menu").blink_components_highlight(ctx)
end,
},
kind_icon = {
text = function(ctx)
local mini_icon, _mini_hl = get_mini_icon(ctx)
return mini_icon
end,
highlight = function(ctx)
local _mini_icon, mini_hl = get_mini_icon(ctx)
return mini_hl
end,
},
kind = {
-- (optional) use highlights from mini.icons
highlight = function(ctx)
local _mini_icon, mini_hl = get_mini_icon(ctx)
return mini_hl
end,
},
},
},
},
},
})

View File

@ -0,0 +1,7 @@
vim.pack.add({"https://github.com/rktjmp/lush.nvim"})
vim.pack.add({"https://github.com/savq/melange-nvim" })
-- vim.g.melange_enable_font_variants = 0 -- disable font variants
-- require("lush") -- make sure Lush is installed
-- require("melange.build").build() -- Compile to vimscript
vim.cmd.colorscheme("melange")

19
lua/plugins/flash.lua Normal file
View File

@ -0,0 +1,19 @@
vim.pack.add({ "https://github.com/folke/flash.nvim" })
require("flash").setup({
modes =
{
search =
{
enabled = true
}
}
})
vim.keymap.set({ "n", "x", "o" }, "s", function() require("flash").jump() end)
vim.keymap.set({ "n", "x", "o" }, "S", function() require("flash").treesitter() end)
vim.keymap.set({ "o" }, "r", function() require("flash").remote() end)
vim.keymap.set({ "o", "x" }, "R", function() require("flash").treesitter_search() end)
vim.keymap.set({ "c" }, "<c-s>", function() require("flash").toggle() end)

10
lua/plugins/init.lua Normal file
View File

@ -0,0 +1,10 @@
require("plugins.colorscheme")
require("plugins.telescope")
require("plugins.treesitter")
require("plugins.lsp")
require("plugins.oil")
require("plugins.cmp")
require("plugins.multicursor")
require("plugins.lsplines")
require("plugins.mini")
require("plugins.flash")

41
lua/plugins/lsp.lua Normal file
View File

@ -0,0 +1,41 @@
vim.pack.add({ 'https://github.com/neovim/nvim-lspconfig' })
vim.lsp.enable({ 'lua_ls' })
vim.lsp.enable({ 'clangd' })
vim.lsp.config("rust_analyzer", {
settings = {
["rust-analyzer"] = {
completion =
{
postfix = { enable = false, },
},
}
},
})
vim.lsp.enable('rust_analyzer', {
settings = {
['rust-analyzer'] = {
completion = {
postfix = {
enable = true, -- Postfix snippets
},
},
check = {
command = "clippy",
},
},
},
})
vim.keymap.set("n", "<leader>t", vim.diagnostic.open_float)
vim.keymap.set("n", "<leader>sr", vim.lsp.buf.rename)
vim.keymap.set("n", "<leader>gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "<leader>gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("v", "<leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<leader>f", function()
vim.lsp.buf.format({ async = true })
end, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.lsp.inlay_hint.enable(false, nil)

4
lua/plugins/lsplines.lua Normal file
View File

@ -0,0 +1,4 @@
vim.pack.add({ "https://git.sr.ht/~whynothugo/lsp_lines.nvim" })
require("lsp_lines").setup()
vim.diagnostic.config({ virtual_lines = { only_current_line = true } })

6
lua/plugins/mini.lua Normal file
View File

@ -0,0 +1,6 @@
vim.pack.add({"https://github.com/nvim-mini/mini.surround"})
require('mini.surround').setup()
-- Comments
vim.pack.add({"https://github.com/nvim-mini/mini.comment"})
require('mini.comment').setup()

View File

@ -0,0 +1,87 @@
vim.pack.add({ "https://github.com/jake-stewart/multicursor.nvim" })
local mc = require("multicursor-nvim")
mc.setup()
local set = vim.keymap.set
-- Add or skip cursor above/below the main cursor.
set({ "n", "x" }, "<C-M-k>", function()
mc.lineAddCursor(-1)
end)
set({ "n", "x" }, "<C-M-j>", function()
mc.lineAddCursor(1)
end)
set({ "n", "x" }, "<C-M-S-k>", function()
mc.lineSkipCursor(-1)
end)
set({ "n", "x" }, "<C-M-S-j>", function()
mc.lineSkipCursor(1)
end)
-- Add or skip adding a new cursor by matching word/selection
set({ "n", "x" }, "<C-j>", function()
mc.matchAddCursor(1)
end)
set({ "n", "x" }, "<C-S-j>", function()
mc.matchSkipCursor(1)
end)
set({ "n", "x" }, "<C-k>", function()
mc.matchAddCursor(-1)
end)
set({ "n", "x" }, "<C-S-k>", function()
mc.matchSkipCursor(-1)
end)
-- Add and remove cursors with control + left click.
set("n", "<c-leftmouse>", mc.handleMouse)
set("n", "<c-leftdrag>", mc.handleMouseDrag)
set("n", "<c-leftrelease>", mc.handleMouseRelease)
-- Disable and enable cursors.
set({ "n", "x" }, "<c-q>", mc.toggleCursor)
-- Mappings defined in a keymap layer only apply when there are
-- multiple cursors. This lets you have overlapping mappings.
mc.addKeymapLayer(function(layerSet)
-- Select a different cursor as the main one.
layerSet({ "n", "x" }, "<left>", mc.prevCursor)
layerSet({ "n", "x" }, "<right>", mc.nextCursor)
-- Delete the main cursor.
layerSet({ "n", "x" }, "<leader>x", mc.deleteCursor)
-- Enable and clear cursors using escape.
layerSet("n", "<esc>", function()
if not mc.cursorsEnabled() then
mc.enableCursors()
else
mc.clearCursors()
end
end)
end)
-- Customize how cursors look.
local hl = vim.api.nvim_set_hl
hl(0, "MultiCursorCursor", { reverse = true, fg = "#aaaaff" })
hl(0, "MultiCursorVisual", { link = "Visual" })
hl(0, "MultiCursorSign", { link = "SignColumn" })
hl(0, "MultiCursorMatchPreview", { link = "Search" })
hl(0, "MultiCursorDisabledCursor", { reverse = true })
hl(0, "MultiCursorDisabledVisual", { link = "Visual" })
hl(0, "MultiCursorDisabledSign", { link = "SignColumn" })
-- Autocmds to change main cursor color when multicursors is active
vim.api.nvim_create_autocmd("User", {
pattern = "MultiCursorStart",
callback = function()
vim.api.nvim_set_hl(0, "Cursor", { bg = "#000000", fg = "#ffffff" }) -- bright red
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MultiCursorExit",
callback = function()
vim.api.nvim_set_hl(0, "Cursor", { link = "Cursor" }) -- restore default
end,
})

18
lua/plugins/oil.lua Normal file
View File

@ -0,0 +1,18 @@
vim.pack.add({
"https://github.com/nvim-mini/mini.icons",
"https://github.com/stevearc/oil.nvim"
})
require('mini.icons').setup()
require("oil").setup({
default_file_explorer = true,
columns = {
"icon",
},
skip_confirm_for_simple_edits = true,
constrain_cursor = "editable",
})
-- Open oil
vim.keymap.set("n", "<leader>pv", vim.cmd.Oil)

36
lua/plugins/telescope.lua Normal file
View File

@ -0,0 +1,36 @@
local hooks = function(ev)
local name, kind = ev.data.spec.name, ev.data.kind
if name == 'telescope-fzf-native.nvim' and (kind == 'install' or kind == 'update') then
vim.system({ 'make' }, { cwd = ev.data.path }):wait()
end
end
vim.api.nvim_create_autocmd('PackChanged', { callback = hooks })
vim.pack.add({
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/nvim-lua/telescope.nvim",
"https://github.com/nvim-telescope/telescope-fzf-native.nvim",
})
-- Keymaps
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>pf", builtin.find_files, {})
vim.keymap.set("n", "<leader>pb", builtin.buffers, {})
vim.keymap.set("n", "<leader>ps", builtin.live_grep, {})
vim.keymap.set("n", "<leader>pd", builtin.diagnostics, {})
-- fzf
require("telescope").load_extension("fzf")
-- telescope setup
require("telescope").setup({
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case"
},
},
})

View File

@ -0,0 +1,81 @@
vim.api.nvim_create_autocmd('PackChanged', {
callback = function(ev)
local name, kind = ev.data.spec.name, ev.data.kind
if name == 'nvim-treesitter' and kind == 'update' then
if not ev.data.active then vim.cmd.packadd('nvim-treesitter') end
vim.cmd(':TSUpdate')
end
end
})
vim.pack.add(
{ { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" } }
)
local ts = require('nvim-treesitter')
ts.setup {
-- Directory to install parsers and queries to (prepended to `runtimepath` to have priority)
install_dir = vim.fn.stdpath('data') .. '/site',
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = { enable = false },
}
local languages =
{
"bash",
"c",
"diff",
"html",
"javascript",
"json",
"lua",
"markdown",
"markdown_inline",
"python",
"query",
"regex",
"rust",
"toml",
"vim",
"vimdoc",
"yaml",
"wgsl",
}
ts.install(languages):wait(300000)
for _, lang in pairs(languages) do
vim.api.nvim_create_autocmd('FileType', {
pattern = { lang },
callback = function() vim.treesitter.start() end,
})
end
-- Incremental selection keybindings
vim.keymap.set({ 'x' }, '<c-p>', function()
require 'vim.treesitter._select'.select_prev(vim.v.count1)
end, { desc = 'Select previous treesitter node' })
vim.keymap.set({ 'x' }, '<c-n>', function()
require 'vim.treesitter._select'.select_next(vim.v.count1)
end, { desc = 'Select next treesitter node' })
vim.keymap.set({ 'x', 'o' }, 'v', function()
if vim.treesitter.get_parser(nil, nil, { error = false }) then
require 'vim.treesitter._select'.select_parent(vim.v.count1)
else
vim.lsp.buf.selection_range(vim.v.count1)
end
end, { desc = 'Select parent treesitter node or outer incremental lsp selections' })
vim.keymap.set({ 'x', 'o' }, 'V', function()
if vim.treesitter.get_parser(nil, nil, { error = false }) then
require 'vim.treesitter._select'.select_child(vim.v.count1)
else
vim.lsp.buf.selection_range(-vim.v.count1)
end
end, { desc = 'Select child treesitter node or inner incremental lsp selections' })

73
nvim-pack-lock.json Normal file
View File

@ -0,0 +1,73 @@
{
"plugins": {
"Comment.nvim": {
"rev": "e30b7f2008e52442154b66f7c519bfd2f1e32acb",
"src": "https://github.com/numToStr/Comment.nvim"
},
"blink.cmp": {
"rev": "a327b19a419347084074cce77f6cd074f54705ac",
"src": "https://github.com/saghen/blink.cmp"
},
"colorful-menu.nvim": {
"rev": "b51a659459df8d078201aefc995db8175ed55e84",
"src": "https://github.com/xzbdmw/colorful-menu.nvim"
},
"flash.nvim": {
"rev": "fcea7ff883235d9024dc41e638f164a450c14ca2",
"src": "https://github.com/folke/flash.nvim"
},
"lsp_lines.nvim": {
"rev": "a92c755f182b89ea91bd8a6a2227208026f27b4d",
"src": "https://git.sr.ht/~whynothugo/lsp_lines.nvim"
},
"lush.nvim": {
"rev": "9c60ec2279d62487d942ce095e49006af28eed6e",
"src": "https://github.com/rktjmp/lush.nvim"
},
"melange-nvim": {
"rev": "ce42f6b629beeaa00591ba73a77d3eeac4cf28ce",
"src": "https://github.com/savq/melange-nvim"
},
"mini.comment": {
"rev": "8e5ff3ed3cc0e8f216617aae01020c00c20f7a87",
"src": "https://github.com/nvim-mini/mini.comment"
},
"mini.icons": {
"rev": "7fdae2443a0e2910015ca39ad74b50524ee682d3",
"src": "https://github.com/nvim-mini/mini.icons"
},
"mini.surround": {
"rev": "2715e04bea3ec9244f15b421dc5b18c0fe326210",
"src": "https://github.com/nvim-mini/mini.surround"
},
"multicursor.nvim": {
"rev": "704b99f10a72cc05d370cfeb294ff83412a8ab55",
"src": "https://github.com/jake-stewart/multicursor.nvim"
},
"nvim-lspconfig": {
"rev": "bedca8b426b2fee0ccac596d167d71bbe971253f",
"src": "https://github.com/neovim/nvim-lspconfig"
},
"nvim-treesitter": {
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
"src": "https://github.com/nvim-treesitter/nvim-treesitter",
"version": "'main'"
},
"oil.nvim": {
"rev": "0fcc83805ad11cf714a949c98c605ed717e0b83e",
"src": "https://github.com/stevearc/oil.nvim"
},
"plenary.nvim": {
"rev": "b9fd5226c2f76c951fc8ed5923d85e4de065e509",
"src": "https://github.com/nvim-lua/plenary.nvim"
},
"telescope-fzf-native.nvim": {
"rev": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c",
"src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
},
"telescope.nvim": {
"rev": "7ef4d6dccb78ee71e552bbd866176762ad328afa",
"src": "https://github.com/nvim-lua/telescope.nvim"
}
}
}