Compare commits

...

3 commits

Author SHA1 Message Date
41327778ea add keymaps to vim unstable 2025-04-01 13:16:03 -03:00
a3a262c576 restore ghostty config 2025-04-01 10:26:07 -03:00
895b404943 start rewrite nvim config for v0.11 from scratch 2025-03-31 10:37:49 -03:00
12 changed files with 505 additions and 0 deletions

View file

@ -50,6 +50,7 @@ depends = ["rust"]
[nvim.files]
"config/nvim" = "~/.config/nvim"
"config/nvim_unstable" = "~/.config/nvim-unstable"
[nvim.files."config/nvim/lua/aleidk/lazy.lua"]
target = "~/.config/nvim/lua/aleidk/lazy.lua"
type = "template"

12
.stylua.toml Normal file
View file

@ -0,0 +1,12 @@
syntax = "All"
column_width = 120
line_endings = "Unix"
indent_type = "indent_type"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "Always"
collapse_simple_statement = "ConditionalOnly"
space_after_function_names = "Never"
[sort_requires]
enabled = true

View file

@ -1 +1,92 @@
theme = catppuccin-macchiato
# Common
keybind = ctrl+space>o=write_selection_file:open
keybind = ctrl+space>shift+o=write_selection_file:paste
keybind = ctrl+space>alt+o=write_scrollback_file:open
keybind = ctrl+space>alt+shift+o=write_scrollback_file:paste
keybind = ctrl+comma=open_config
keybind = ctrl+space>shift+r=reload_config
keybind = ctrl+shift+c=copy_to_clipboard
keybind = ctrl+shift+i=inspector:toggle
keybind = ctrl+shift+v=paste_from_clipboard
keybind = shift+insert=paste_from_selection
# Navigation
keybind = alt+f4=close_window
keybind = ctrl+shift+w=close_surface
keybind = ctrl+space>shift+t=close_surface
keybind = ctrl+shift+n=new_window
keybind = ctrl+shift+q=quit
keybind = ctrl+space>shift+f=toggle_fullscreen
keybind = ctrl+alt+j=jump_to_prompt:1
keybind = ctrl+alt+k=jump_to_prompt:-1
keybind = ctrl+shift+a=select_all
keybind = shift+right=adjust_selection:right
keybind = shift+down=adjust_selection:down
keybind = shift+up=adjust_selection:up
keybind = shift+left=adjust_selection:left
keybind = shift+end=scroll_to_bottom
keybind = shift+home=scroll_to_top
keybind = shift+page_up=scroll_page_up
keybind = shift+page_down=scroll_page_down
# Config
keybind = ctrl+equal=increase_font_size:1
keybind = ctrl+minus=decrease_font_size:1
keybind = ctrl+plus=increase_font_size:1
keybind = ctrl+zero=reset_font_size
# Splits
keybind = ctrl+space>s=new_split:right
keybind = ctrl+space>v=new_split:down
keybind = ctrl+space>h=goto_split:left
keybind = ctrl+space>j=goto_split:bottom
keybind = ctrl+space>k=goto_split:top
keybind = ctrl+space>l=goto_split:right
keybind = ctrl+space>left=goto_split:left
keybind = ctrl+space>down=goto_split:bottom
keybind = ctrl+space>up=goto_split:top
keybind = ctrl+space>right=goto_split:right
keybind = ctrl+space>m=toggle_split_zoom
keybind = super+ctrl+left_bracket=goto_split:previous
keybind = super+ctrl+right_bracket=goto_split:next
keybind = super+ctrl+shift+right=resize_split:right,10
keybind = super+ctrl+shift+down=resize_split:down,10
keybind = super+ctrl+shift+up=resize_split:up,10
keybind = super+ctrl+shift+left=resize_split:left,10
keybind = ctrl+space>ctrl+zero=equalize_splits
# Tabs
keybind = ctrl+space>one=goto_tab:1
keybind = ctrl+space>two=goto_tab:2
keybind = ctrl+space>three=goto_tab:3
keybind = ctrl+space>four=goto_tab:4
keybind = ctrl+space>five=goto_tab:5
keybind = ctrl+space>six=goto_tab:6
keybind = ctrl+space>seven=goto_tab:7
keybind = ctrl+space>eight=goto_tab:8
keybind = ctrl+space>nine=last_tab
keybind = ctrl+page_up=previous_tab
keybind = ctrl+page_down=next_tab
keybind = ctrl+shift+left=previous_tab
keybind = ctrl+shift+right=next_tab
keybind = ctrl+space>shift+tab=previous_tab
keybind = ctrl+space>tab=next_tab
keybind = ctrl+space>t=new_tab

View file

@ -0,0 +1,32 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("aleidk.options")
require("aleidk.keymaps")
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "aleidk/plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})

View file

@ -0,0 +1,5 @@
return {
cmd = { "rust-analyzer" },
filetypes = { 'rust' },
root_markers = { "cargo.toml" },
}

View file

@ -0,0 +1,19 @@
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if not client then
return
end
-- Prefer LSP folding if client supports it
if client:supports_method('textDocument/foldingRange') then
local win = vim.api.nvim_get_current_win()
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
end
if client:supports_method 'textDocument/completion' then
vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
end
end,
})

View file

@ -0,0 +1,36 @@
-- stylua: ignore start
-- QoL normalization's
vim.keymap.set("n", "Q", "<nop>", {})
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { desc = "Prevent cursor movement", silent = true })
vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'",
{ desc = "Move cursor regardless of word wrap", expr = true, silent = true })
vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'",
{ desc = "Move cursor regardless of word wrap", expr = true, silent = true })
vim.keymap.set("n", "J", "mzJ`z", { desc = "Keep cursor in column while joining lines", silent = true })
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Keep cursor centered while junping", silent = true })
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Keep cursor centered while junping", silent = true })
vim.keymap.set("n", "n", "nzzzv", { desc = "Keep cursor centered while searching", silent = true })
vim.keymap.set("n", "N", "Nzzzv", { desc = "Keep cursor centered while searching", silent = true })
-- Utils
vim.keymap.set("n", "|", ":vs<CR>", { desc = "Create vsplit", silent = true })
vim.keymap.set("n", "°", ":sp<CR>", { desc = "Create split", silent = true })
vim.keymap.set("v", "p", [["_dP]], { desc = "Paste without lossing yanked text", silent = true })
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selection down", silent = true })
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selection up", silent = true })
vim.keymap.set("n", "<Leader>uh", ":nohl<CR>", { desc = "Remove search highlight", silent = true })
-- Buffer manipulation
vim.keymap.set("n", "<leader>bc", "<Cmd>bd<CR>", { desc = "Close buffer", silent = true })
vim.keymap.set("n", "<leader>bh", "<Cmd>bp<CR>", { desc = "Prev buffer", silent = true })
vim.keymap.set("n", "<leader>bl", "<Cmd>bn<CR>", { desc = "Next buffer", silent = true })
vim.keymap.set("n", "<leader>bA", "<Cmd>bufdo bd<CR>", { desc = "Close all buffers", silent = true })
vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Move to left window", silent = true })
vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Move to bottom window", silent = true })
vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "Move to top window", silent = true })
vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "Move to right window", silent = true })
-- stylua: ignore end

View file

@ -0,0 +1,161 @@
-- [[ Setting options ]]
-- See `:help vim.o`
-- Set <space> as the leader key
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.o.diffopt = "vertical,closeoff,filler"
local opt = vim.opt
vim.schedule(function()
vim.opt.clipboard = 'unnamedplus'
end)
vim.o.winborder = 'rounded'
opt.breakindent = true -- Every wrapped line will continue visually indented
opt.autowrite = true -- Enable auto write
-- opt.completeopt = "menu,menuone,noselect"
vim.o.completeopt = 'noselect,menu,menuone,noinsert,popup'
opt.conceallevel = 2 -- Hide * markup for bold and italic
opt.confirm = true -- Confirm to save changes before exiting modified buffer
opt.cursorline = true -- Enable highlighting of the current line
opt.expandtab = true -- Use spaces instead of tabs
opt.formatoptions = "jcroqlnt" -- tcqj
opt.grepformat = "%f:%l:%c:%m"
opt.grepprg = "rg --vimgrep"
opt.ignorecase = true -- Ignore case
opt.inccommand = "nosplit" -- preview incremental substitute
opt.laststatus = 0
vim.opt.list = true -- Sets how neovim will display certain whitespace characters in the editor.
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
opt.mouse = "a" -- Enable mouse mode
opt.number = true -- Print line number
opt.pumblend = 10 -- Popup blend
opt.pumheight = 10 -- Maximum number of entries in a popup
opt.relativenumber = true -- Relative line numbers
opt.scrolloff = 15 -- Lines of context
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
opt.shiftround = true -- Round indent
opt.shiftwidth = 2 -- Size of an indent
-- opt.shortmess:append({ W = true, I = true, c = true }) -- INFO: this control the format of some messages
opt.showmode = false -- Don't show mode since we have a statusline
opt.sidescrolloff = 8 -- Columns of context
opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
opt.smartcase = true -- Don't ignore case with capitals
opt.smartindent = true -- Insert indents automatically
opt.spelllang = { "en" }
opt.splitbelow = true -- Put new windows below current
opt.splitright = true -- Put new windows right of current
opt.tabstop = 2 -- Number of spaces tabs count for
opt.termguicolors = true -- True color support
opt.timeoutlen = 300
opt.undofile = true
opt.undolevels = 10000
opt.updatetime = 200 -- Save swap file and trigger CursorHold
opt.wildmode = "longest,list:full" -- Command-line completion mode
opt.winminwidth = 5 -- Minimum window width
opt.wrap = false -- Disable line wrap
vim.opt.inccommand = 'split' -- Preview substitutions live, as you type!
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
-- Nice and simple folding:
vim.o.foldenable = true
vim.o.foldlevel = 99
vim.o.foldmethod = "expr"
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.opt.fillchars:append({ fold = " " })
local fn = vim.fn
-- Quickfix customization
function _G.qftf(info)
local items
local ret = {}
-- The name of item in list is based on the directory of quickfix window.
-- Change the directory for quickfix window make the name of item shorter.
-- It's a good opportunity to change current directory in quickfixtextfunc :)
--
-- local alterBufnr = fn.bufname('#') -- alternative buffer is the buffer before enter qf window
-- local root = getRootByAlterBufnr(alterBufnr)
-- vim.cmd(('noa lcd %s'):format(fn.fnameescape(root)))
--
if info.quickfix == 1 then
items = fn.getqflist({ id = info.id, items = 0 }).items
else
items = fn.getloclist(info.winid, { id = info.id, items = 0 }).items
end
local limit = 31
local fnameFmt1, fnameFmt2 = "%-" .. limit .. "s", "…%." .. (limit - 1) .. "s"
local validFmt = "%s │%5d:%-3d│%s %s"
for i = info.start_idx, info.end_idx do
local e = items[i]
local fname = ""
local str
if e.valid == 1 then
if e.bufnr > 0 then
fname = fn.bufname(e.bufnr)
if fname == "" then
fname = "[No Name]"
else
fname = fname:gsub("^" .. vim.env.HOME, "~")
end
-- char in fname may occur more than 1 width, ignore this issue in order to keep performance
if #fname <= limit then
fname = fnameFmt1:format(fname)
else
fname = fnameFmt2:format(fname:sub(1 - limit))
end
end
local lnum = e.lnum > 99999 and -1 or e.lnum
local col = e.col > 999 and -1 or e.col
local qtype = e.type == "" and "" or " " .. e.type:sub(1, 1):upper()
str = validFmt:format(fname, lnum, col, qtype, e.text)
else
str = e.text
end
table.insert(ret, str)
end
return ret
end
-- TODO: how to customize?
vim.o.qftf = "{info -> v:lua._G.qftf(info)}"
vim.filetype.add({
-- Detect and assign filetype based on the extension of the filename
extension = {
mdx = "mdx",
log = "log",
conf = "conf",
env = "dotenv",
},
-- Detect and apply filetypes based on the entire filename
filename = {
[".env"] = "dotenv",
["env"] = "dotenv",
["tsconfig.json"] = "jsonc",
},
-- Detect and apply filetypes based on certain patterns of the filenames
pattern = {
-- INFO: Match filenames like - ".env.example", ".env.local" and so on
["%.env%.[%w_.-]+"] = "dotenv",
[".*%.blade%.php"] = "blade",
[".*%.hurl.*"] = "hurl",
[".*/hypr/.*%.conf"] = "hyprlang",
},
})
-- ╭─────────────────────────────────────────────────────────╮
-- │ LSP │
-- ╰─────────────────────────────────────────────────────────╯
vim.lsp.enable({
"rust_analyzer"
})
vim.diagnostic.config({
virtual_lines = { current_line = true }
})

View file

@ -0,0 +1,57 @@
return { -- Change colors.none if not using a transparent background
"catppuccin/nvim",
name = "catppuccin",
priority = 1000,
config = function()
local utils = require("catppuccin.utils.colors")
local opts = {
flavour = "macchiato",
transparent_background = true,
integrations = {
aerial = true,
blink_cmp = true,
cmp = true,
gitsigns = true,
indent_blankline = { enabled = true, scope_color = "text", },
lsp_trouble = true,
mason = true,
noice = true,
notify = true,
},
custom_highlights = function(colors)
return {
-- Fix colors for cmp
Pmenu = { bg = colors.none, blend = 0 },
FloatBorder = { bg = colors.none },
CmpItemMenu = { fg = colors.text, bg = colors.none },
-- dadbod-ui
NotificationInfo = { bg = colors.none, fg = colors.text },
NotificationWarning = { bg = colors.none, fg = colors.yellow },
NotificationError = { bg = colors.none, fg = colors.red },
-- for word diff in previews
GitSignsAddInline = {
fg = colors.teal,
bg = utils.darken(colors.teal, 0.4),
style = { "bold" },
},
GitSignsDeleteInline = {
fg = colors.red,
bg = utils.darken(colors.red, 0.4),
style = { "bold" },
},
GitSignsChangeInline = {
fg = colors.mauve,
bg = utils.darken(colors.mauve, 0.4),
style = { "bold" },
},
GitSignsDeleteVirtLn = { bg = colors.none, fg = colors.red },
}
end,
}
require("catppuccin").setup(opts)
vim.cmd.colorscheme("catppuccin-macchiato")
end,
}

View file

@ -0,0 +1,6 @@
return {
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
}

View file

@ -0,0 +1,84 @@
return {
-- Highlight, edit, and navigate code
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
"JoosepAlviste/nvim-ts-context-commentstring",
"nvim-treesitter/nvim-treesitter-context",
{ "windwp/nvim-ts-autotag", opts = {} },
},
build = ":TSUpdate",
config = function()
---@diagnostic disable-next-line: missing-fields
require("nvim-treesitter.configs").setup({
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
},
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_previous = { -- current or last start of object
["[["] = { query = "@local.scope", query_group = "locals", desc = "Next scope" },
["[f"] = "@function.outer",
["[c"] = "@class.outer",
},
goto_next = { -- next object end
["]]"] = { query = "@local.scope", query_group = "locals", desc = "Next scope" },
["]f"] = "@function.outer", -- current function end
["]c"] = "@class.outer",
},
},
swap = {
enable = true,
swap_next = {
["<leader>ln"] = "@parameter.inner",
},
swap_previous = {
["<leader>lN"] = "@parameter.inner",
},
},
},
-- autotag = { enable = true },
})
require('ts_context_commentstring').setup {
enable_autocmd = false,
}
local ts_repeat_move = require "nvim-treesitter.textobjects.repeatable_move"
-- Repeat movement with ; and ,
-- ensure , goes forward and ; goes backward regardless of the last direction
vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_next)
vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_previous)
-- Optionally, make builtin f, F, t, T also repeatable with ; and ,
vim.keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f_expr, { expr = true })
vim.keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F_expr, { expr = true })
vim.keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t_expr, { expr = true })
vim.keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T_expr, { expr = true })
vim.keymap.set("n", "[u", function()
require("treesitter-context").go_to_context()
end, { silent = true, noremap = true, desc = "Go up when context is out of view" })
end,
}

View file

@ -1,5 +1,6 @@
alias \
vi='nvim' \
vi-unstable='NVIM_APPNAME=nvim-unstable nvim' \
vi-astro='NVIM_APPNAME=Distro-AstroNvim nvim' \
vi-lazy='NVIM_APPNAME=LazyVim nvim'