Skip to content

Commit

Permalink
Batch of updates (#82)
Browse files Browse the repository at this point in the history
* nvim, env and xmonad updates

* Update conform and telescope, and add avante basic config
  • Loading branch information
EnriqueVidal authored Dec 4, 2024
1 parent 199d7df commit 42c19aa
Show file tree
Hide file tree
Showing 36 changed files with 453 additions and 251 deletions.
12 changes: 7 additions & 5 deletions .config/git/config
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
st = status
br = branch
ci = commit
m = checkout master
m = checkout main
sign = commit --amend -S -sC HEAD
amend = commit --amend -C HEAD
l = log --graph --date=short --pretty='format:%C(green)%ad %C(yellow)%h%Creset %C(cyan)%aN%Creset %s%C(magenta bold)%d%Creset'
ll = log --decorate=short --name-status -M
p = format-patch master
p = format-patch main
trash-clean = !git ls-files --others --exclude-standard -z | xargs -0 trash-put
branch-delete = !sh -c 'git cherry master $1 | grep -v "^-" > /dev/null && $( git br -d "$1" || exit 0 ) || git br -D "$1"' -
branch-delete = !sh -c 'git cherry main $1 | grep -v "^-" > /dev/null && $( git br -d "$1" || exit 0 ) || git br -D "$1"' -
brd = !git branch-delete
cleanup = !git clean -n | sed -n -e 's/Would remove \\(.*\\)/\\1/p' | tr '\n' '\\0' | xargs -0 trash-put
bb = bisect bad
bg = bisect good
bs = bisect skip
clean-remote = !git branch -r --merged master | grep -v master | sed -e 's/\\// :/g' | xargs -n2 git push
clean-remote = !git branch -r --merged main | grep -v main | sed -e 's/\\// :/g' | xargs -n2 git push
[push]
default = tracking
[mergetool]
Expand All @@ -31,4 +31,6 @@
[merge]
tool = fugitive
[diff]
tool = vimdiff
tool = nvimdiff
[difftool]
prompt = false
2 changes: 1 addition & 1 deletion .config/kitty/kitty.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ font_size 12.0
bold_font auto

# dynamic_background_opacity yes
background_opacity 0.9
background_opacity 0.95

window_padding_width 5.0
disable_ligatures never
Expand Down
64 changes: 35 additions & 29 deletions .config/nvim/lazy-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .config/nvim/lua/config/lazy.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
if not vim.uv.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
Expand All @@ -16,7 +16,7 @@ require("lazy").setup({
{ import = "plugins" },
},
checker = { enabled = true },
default = {
defaults = {
lazy = false,
version = false,
},
Expand Down
55 changes: 29 additions & 26 deletions .config/nvim/lua/core/helpers.lua
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
--- @alias Command string | function
---@alias RHS
---| string
---| function

---@class Helpers
---@field nmap fun(keys: string, command: Command, desc?: string): nil
---@field imap fun(keys: string, command: Command, desc?: string): nil
---@field tmap fun(keys: string, command: Command, desc?: string): nil
---@field augroups fun(defintions: table<string, table<string, string>>): nil
---@field merge fun(a?: table, b?: table): table
local M = {}

---@module "vim"
---@alias MapOpts string | vim.keymap.set.Opts options or description

--- Simple keymap helper
---@param mode string
---@param mode string | string[]
---@param keys "n" | "i" | "t"
---@param command Command
---@param desc? string
local function keymap(mode, keys, command, desc)
local options = { noremap = true, silent = true, desc = desc }
---@param command RHS
---@param opts? MapOpts
local function keymap(mode, keys, command, opts)
local options = (type(opts) == "table" and opts)
or { noremap = true, silent = true, desc = opts }

vim.keymap.set(mode, keys, command, options)
end

--- Simple `n` keymap shorthand basically a shorter version of:
--- `vim.keymap.set('n', keys, command, { noremap = true, silent = true, desc = desc })`
---@param keys string
---@param command Command
---@param desc? string
function M.nmap(keys, command, desc)
keymap("n", keys, command, desc)
---@param command RHS
---@param opts? MapOpts
function M.nmap(keys, command, opts)
keymap("n", keys, command, opts)
end

--- Simple `i` keymap shorthand basically a shorter version of:
--- `vim.keymap.set('i', keys, command, { noremap = true, silent = true, desc = desc })`
---@param keys string
---@param command Command
---@param desc? string
function M.imap(keys, command, desc)
keymap("i", keys, command, desc)
---@param command RHS
---@param opts? MapOpts
function M.imap(keys, command, opts)
keymap("i", keys, command, opts)
end

--- Simple `t` keymap shorthand basically a shorter version of:
--- `vim.keymap.set('t', keys, command, { noremap = true, silent = true, desc = desc })`
---@param keys string
---@param command Command
---@param desc? string
function M.tmap(keys, command, desc)
keymap("t", keys, command, desc)
---@param command RHS
---@param opts? MapOpts
function M.tmap(keys, command, opts)
keymap("t", keys, command, opts)
end

--- Simple way to create augroups
Expand All @@ -53,8 +54,10 @@ function M.augroups(defintions)
vim.api.nvim_command("autocmd!")

for _, def in ipairs(definition) do
local command =
table.concat(vim.tbl_flatten({ "autocmd", def }), " ")
local command = table.concat(
vim.iter({ "autocmd", def }):flatten():totable(),
" "
)
vim.api.nvim_command(command)
end

Expand Down
109 changes: 78 additions & 31 deletions .config/nvim/lua/core/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ if not ok then
return
end

--- @module "vim"
--- @type vim.diagnostic.Opts.Signs
local signs = {
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
Expand All @@ -18,9 +20,12 @@ for _, sign in ipairs(signs) do
)
end

--- @module "vim"
--- @type vim.diagnostic.Opts
local config = {
-- disable virtual text
virtual_text = false,
virtual_text = {
source = "if_many",
},
-- show signs
signs = {
active = signs,
Expand All @@ -31,7 +36,7 @@ local config = {
float = {
focusable = false,
style = "minimal",
source = "always",
source = true,
header = "",
prefix = "",
},
Expand All @@ -41,6 +46,9 @@ vim.diagnostic.config(config)

vim.diagnostic.get(0, { severity = { min = vim.diagnostic.severity.WARN } })

-- Turn inlay hints on by default
vim.lsp.inlay_hint.enable(true)

-- Global Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
helpers.nmap(
Expand Down Expand Up @@ -68,36 +76,75 @@ vim.api.nvim_create_autocmd("LspAttach", {

-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }

vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set(
"n",
"<space>wr",
vim.lsp.buf.remove_workspace_folder,
opts

helpers.nmap(
"gD",
vim.lsp.buf.declaration,
{ buffer = ev.buf, desc = "Jump to code declaration" }
)

helpers.nmap(
"gd",
vim.lsp.buf.definition,
{ buffer = ev.buf, desc = "Jump to code definition" }
)

vim.keymap.set("n", "<space>wl", function()
helpers.nmap("K", vim.lsp.buf.hover, {
buffer = ev.buf,
desc = "Display hover information in floating window",
})

helpers.nmap("gi", vim.lsp.buf.implementation, {
buffer = ev.buf,
desc = "List implementations in quickfix window",
})

helpers.nmap("<C-k>", vim.lsp.buf.signature_help, {
buffer = ev.buf,
desc = "Display signature information in floating window",
})

helpers.nmap("<space>wa", vim.lsp.buf.add_workspace_folder, {
buffer = ev.buf,
desc = "Add the folder at path to the workspace folders",
})

helpers.nmap("<space>wr", vim.lsp.buf.remove_workspace_folder, {
buffer = ev.buf,
desc = "Remove the folder at path from the workspace folders",
})

helpers.nmap("<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)

vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "<space>f", function()
vim.lsp.buf.format({
async = true,
filter = function(client)
return client.name == "null-ls"
end,
})
end, opts)
end, { buffer = ev.buf, desc = "List workspace folders" })

helpers.nmap(
"<space>D",
vim.lsp.buf.type_definition,
{ buffer = ev.buf, desc = "Jumps to the definition of the type" }
)

helpers.nmap(
"<space>rn",
vim.lsp.buf.rename,
{ buffer = ev.buf, desc = "Renames all refereces to the symbol" }
)

helpers.nmap("<space>ca", vim.lsp.buf.code_action, {
buffer = ev.buf,
desc = "Selects code action available at current cursor position",
})

helpers.nmap("gr", vim.lsp.buf.references, {
buffer = ev.buf,
desc = "List all the references in the quickfix window",
})

helpers.nmap("<leader>i", function()
vim.lsp.inlay_hint.enable(
not vim.lsp.inlay_hint.is_enabled({ 0 }),
{ 0 }
)
end, "Toggle inlay hints")
end,
})
6 changes: 6 additions & 0 deletions .config/nvim/lua/core/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ set.termguicolors = true
set.number = true
set.relativenumber = true

-- Disable swapfiles
set.swapfile = false

set.cursorline = true
set.hidden = true

-- yank to clipboard
set.clipboard = "unnamed,unnamedplus"
Loading

0 comments on commit 42c19aa

Please sign in to comment.