This commit is contained in:
Tiago Sousa 2024-03-04 13:30:30 +00:00
commit 0f6dee5c9a
Signed by: tiago
SSH key fingerprint: SHA256:odOD9vln9U7qNe1R8o3UCbE3jkQCkr5/q5mgd5hwua0
12 changed files with 158 additions and 91 deletions

View file

@ -30,23 +30,10 @@ autocmd('TextYankPost', {
autocmd({ "BufWritePre" }, {
group = TsousaGroup,
pattern = "*",
command = [[%s/\s\+$//e]],
})
autocmd("LspAttach", {
group = TsousaGroup,
callback = function(e)
local bufopts = {buffer = e.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<leader>fo', function() vim.lsp.buf.format { async = true } end, bufopts)
vim.keymap.set('i', '<C-h>', vim.lsp.buf.signature_help, bufopts)
callback = function ()
local cursor_pos = vim.fn.getpos('.')
vim.cmd([[%s/\s\+$//e]])
vim.fn.setpos('.', cursor_pos)
end
})

View file

@ -3,6 +3,10 @@ local background = "dark"
function SetColor()
vim.cmd.colorscheme(color)
vim.opt.background = background
-- transparency
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
end
return {
@ -14,9 +18,9 @@ return {
-- flavour = "macchiato", -- latte, frappe, macchiato, mocha
background = {
dark = "macchiato",
light = "mocha",
light = "latte",
},
transparent_background = true,
transparent_background = false,
term_colors = false,
integrations = {
cmp = true,
@ -35,7 +39,7 @@ return {
"sainnhe/gruvbox-material",
priority = 1000,
config = function()
local contrast = "hard"
local contrast = "medium"
if background == "light" then
contrast = "soft"
end

View file

@ -0,0 +1,32 @@
return {
"stevearc/conform.nvim",
config = function()
require("conform").setup({
lua = { "stylua" },
python = { "isort", "blue" },
javascript = { "prettierd" },
typescript = { "prettierd" },
html = { "prettierd" },
json = { "prettierd" },
yaml = { "prettierd" },
markdown = { "prettierd" },
})
-- vim.api.nvim_create_autocmd("BufWritePre", {
-- pattern = "*",
-- callback = function(args)
-- require("conform").format { bufnr = args.buf, lsp_fallback = true }
-- end,
-- })
-- local null_ls = require("null-ls")
-- null_ls.setup({
-- sources = {
-- null_ls.builtins.formatting.rustfmt,
-- null_ls.builtins.formatting.blue,
-- null_ls.builtins.formatting.shfmt,
-- null_ls.builtins.formatting.prettierd.with({
-- filetypes = { "html", "json", "yaml", "markdown" },
-- }),
-- }
-- })
end
}

View file

@ -29,11 +29,6 @@ return {
require("luasnip.loaders.from_vscode").lazy_load()
local check_backspace = function()
local col = vim.fn.col "." - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
end
cmp.setup {
snippet = {
expand = function(args)
@ -54,20 +49,14 @@ return {
),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-k>"] = cmp.mapping(function(fallback)
["<C-l>"] = cmp.mapping(function()
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end),
["<C-j>"] = cmp.mapping(function(fallback)
["<C-h>"] = cmp.mapping(function()
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end
),
@ -199,6 +188,7 @@ return {
vim.keymap.set('n', '<leader>vd', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<leader>ve', vim.diagnostic.setloclist)
-- external (non mason) lsps
lspconfig.rust_analyzer.setup({
@ -210,6 +200,26 @@ return {
}
})
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("TsousaLspConfig", {}),
callback = function(e)
local bufopts = { buffer = e.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', '<leader>wss', vim.lsp.buf.workspace_symbol, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
-- vim.keymap.set('n', '<leader>fo', function() vim.lsp.buf.format { async = true } end, bufopts)
vim.keymap.set('n', '<leader>fo',
function() require("conform").format({ lsp_fallback = true }) end, bufopts)
vim.keymap.set('i', '<C-s>', vim.lsp.buf.signature_help, bufopts)
end
})
mason_lspconfig.setup({
ensure_installed = {
lua_ls,
@ -224,11 +234,24 @@ return {
})
end,
-- add here other custom overrides
["hls"] = function()
lspconfig.hls.setup({
settings = {
haskell = {
plugin = {
stan = { globalOn = false },
hlint = { config = { flags = { "--ignore=Eta reduce" } } }
}
}
}
})
end,
["lua_ls"] = function()
lspconfig.lua_ls.setup({
settings = {
Lua = {
diagnostics = { globals = { "vim" } }
diagnostics = { globals = { "vim" } },
telemetry = { enable = false }
}
}
})

View file

@ -1,17 +0,0 @@
return {
"nvimtools/none-ls.nvim",
config = function()
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.rustfmt,
null_ls.builtins.formatting.blue,
null_ls.builtins.formatting.shfmt,
null_ls.builtins.formatting.prettierd.with({
filetypes = { "html", "json", "yaml", "markdown" },
}),
}
})
end
}

View file

@ -20,10 +20,6 @@ return {
NOTE = { icon = "", color = "hint", alt = { "INFO", "info", "note" } },
TEST = { icon = "", color = "test", alt = { "TESTING", "PASSED", "FAILED", "test" } },
},
gui_style = {
fg = "NONE", -- The gui style to use for the fg highlight group.
bg = "BOLD", -- The gui style to use for the bg highlight group.
},
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
-- highlighting of the line containing the todo comment
-- * before: highlights before the keyword (typically comment characters)
@ -41,30 +37,6 @@ return {
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
-- list of named colors where we try to extract the guifg from the
-- list of highlight groups or use the hex color if hl not found as a fallback
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" }
},
search = {
command = "rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
},
})
end
}

View file

@ -1,4 +1,5 @@
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
@ -10,10 +11,8 @@ vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- greatest remap ever
vim.keymap.set("x", "<leader>p", "\"_dP")
-- next greatest remap ever : asbjornHaland
vim.keymap.set("n", "<leader>y", "\"+y")
vim.keymap.set("v", "<leader>y", "\"+y")
vim.keymap.set("n", "<leader>Y", "\"+Y")
@ -21,8 +20,13 @@ vim.keymap.set("n", "<leader>Y", "\"+Y")
vim.keymap.set("n", "<leader>d", "\"_d")
vim.keymap.set("v", "<leader>d", "\"_d")
-- This is going to get me cancelled
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "<leader>s", ":%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>")
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
vim.keymap.set("n", "<leader>s", ":%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>")
--vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })

View file

@ -1,8 +1,8 @@
* {
background: #1E1D2FFF;
background: #24273AFF;
background-alt: #282839FF;
foreground: #D9E0EEFF;
selected: #7AA2F7FF;
active: #ABE9B3FF;
urgent: #F28FADFF;
foreground: #CAD3F5FF;
selected: #8AADF4FF;
active: #A6DA95FF;
urgent: #ED8796FF;
}

View file

@ -0,0 +1,9 @@
* {
background: #282828;
background-alt: #1D2021;
foreground: #D4BE98;
selected: #7DAEA3;
active: #A9B665;
urgent: #EA6962;
}

View file

@ -0,0 +1,8 @@
* {
background: #F2E5BC;
background-alt: #FBF1C7;
foreground: #654735;
selected: #45707A;
active: #6C782E;
urgent: #C14A4A;
}

View file

@ -0,0 +1,41 @@
#!/bin/bash
# Define options
options="Shutdown\nRestart\nSuspend\nLock"
# Prompt user to select an option using Rofi
selected_option=$(echo -e "$options" | rofi -dmenu -p "Power Menu")
# Function to display confirmation dialog
confirm_action() {
rofi -dmenu -p "$1" <<<"Yes\nNo"
}
# Perform action based on selected option
case $selected_option in
"Shutdown")
confirmation=$(confirm_action "Shutdown?")
if [ "$confirmation" == "Yes" ]; then
systemctl poweroff
else
exit 0
fi
;;
"Restart")
confirmation=$(confirm_action "Restart?")
if [ "$confirmation" == "Yes" ]; then
systemctl reboot
else
exit 0
fi
;;
"Suspend")
systemctl suspend
;;
"Lock")
i3-msg exit
;;
*)
exit 0
;;
esac

View file

@ -9,11 +9,14 @@ theme_options=(
)
# rofi script to get what theme to use
chosen=$(printf '%s\n' "${theme_options[@]}" | rofi -dmenu -p "Choose a theme")
chosen=$(printf '%s\n' "${theme_options[@]}" | rofi -dmenu -p "Theme")
theme=$(echo "${chosen}" | cut -d- -f1)
background=$(echo "${chosen}" | cut -d- -f2)
theme=$(echo "${chosen}" | rev | cut -d- -f2- | rev)
background=$(echo "${chosen}" | awk -F'-' '{print $NF}')
echo "Theme: ${theme}"
echo "Background: ${background}"
# change rofi theme
sed -i "s/\(@import \".config\/rofi\/colors\/\).*/\1${theme}-${background}.rasi\"/" ~/.config/rofi/config.rasi
@ -24,5 +27,6 @@ sed -i "s/\(local background = \).*/\1\"${background}\"/" ~/.config/nvim/lua/tso
# change xresources
xresources_themes=".Xresources.d"
sed -i "s/#include \".*\"/#include \"~\/${xresources_themes}\/${theme}-${background}\"/" ~/.Xresources
xrdb ~/.Xresources