Signed-off-by: TiagoRG <tiago.rgarcia@ua.pt>
This commit is contained in:
Tiago Garcia 2024-01-14 16:40:13 +00:00 committed by Tiago Garcia
parent 776ddec49f
commit 6ff922f0b0
Signed by: TiagoRG
GPG Key ID: FF0A53A30B1ADF82
22 changed files with 273 additions and 46 deletions

View File

@ -1,6 +1,27 @@
function ColorMyPencils(color)
--color = color or "rose-pine"
color = color or "monokai-pro-spectrum"
local function trim(str)
return str:gsub("^%s*(.-)%s*$", "%1")
end
function ColorMyPencils()
local color = nil
local file = io.open("/home/tiagorg/.config/nvim/data/colorscheme.txt", "r")
-- check if file exists
if file == nil then
vim.cmd.colorscheme("monokai-pro-spectrum")
return
end
color = file:read("*a")
file:close()
color = trim(color)
if color == nil then
color = "monokai-pro-spectrum"
elseif color == "monokai-pro" then
color = "monokai-pro-spectrum"
end
vim.cmd.colorscheme(color)
@ -9,4 +30,18 @@ function ColorMyPencils(color)
--vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
end
-- Define a function to be called when the colorscheme changes
function OnColorschemeChanged()
local newColorscheme = vim.g.colors_name
local file = io.open("/home/tiagorg/.config/nvim/data/colorscheme.txt", "w")
if file == nil then
return
end
file:write(newColorscheme)
end
ColorMyPencils()
-- Set up an autocmd to trigger the function when the colorscheme changes
vim.cmd([[autocmd ColorScheme * lua OnColorschemeChanged()]])

View File

@ -42,8 +42,8 @@ lsp.on_attach(function(client, bufnr)
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
vim.keymap.set("n", "<leader>vr", function() vim.diagnostic.close_float() end, opts)
vim.keymap.set("n", "(", function() vim.diagnostic.goto_next() end, opts)
vim.keymap.set("n", ")", function() vim.diagnostic.goto_prev() end, opts)
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)

View File

@ -21,5 +21,5 @@ require("nvim-tree").setup({
},
})
vim.api.nvim_set_keymap('n', '<C-t>', ':NvimTreeToggle<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<C-t>', ':NvimTreeToggle<CR>', { noremap = true, silent = true })
vim.keymap.set("n", "<leader>e", "<cmd>NvimTreeFocus<CR>")

View File

@ -1,8 +1,8 @@
local builtin = require('telescope.builtin')
local trouble = require('trouble.providers.telescope')
-- File pickers
vim.keymap.set('n', '<leader>pf', "<cmd>Telescope find_files hidden=true<CR>", {})
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
vim.keymap.set('n', '<leader>pg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>ps', function()
builtin.grep_string({ search = vim.fn.input("Grep > ") });
@ -10,4 +10,7 @@ end)
-- Git pickers
vim.keymap.set('n', '<leader>gc', builtin.git_commits, {})
vim.keymap.set('n', '<leader>gs', builtin.git_status, {})
vim.keymap.set('n', '<leader>gs', builtin.git_stash, {})
-- LSP pickers
vim.keymap.set('n', '<leader>pe', trouble.open_with_trouble, {})

View File

@ -16,8 +16,8 @@ require("toggleterm").setup {
float_opts = {
border = 'curved',
width = vim.o.columns * 0.8,
height = vim.o.lines * 0.8,
width = math.abs(math.floor(vim.o.columns * 0.8 + 0.5)),
height = math.abs(math.floor(vim.o.lines * 0.8 + 0.5)),
winblend = 3,
zindex = 50,
},

View File

@ -25,7 +25,7 @@ require 'nvim-treesitter.configs'.setup {
rainbow = {
enable = true,
-- list of languages you want to disable the plugin for
-- disable = { 'jsx', 'cpp' },
disable = { 'jsx', 'cpp' },
-- Which query to use for finding delimiters
query = 'rainbow-parens',
-- Highlight the entire buffer all at once

View File

@ -8,3 +8,9 @@ require("trouble").setup {
-- Keybindings
vim.keymap.set("n", "<leader>x", "<cmd>TroubleToggle workspace_diagnostics<cr>", { noremap = true, silent = true })
vim.keymap.set("n", ")", function ()
require("trouble").next({ skip_groups = true, jump = true })
end, { noremap = true, silent = true })
vim.keymap.set("n", "(", function ()
require("trouble").previous({ skip_groups = true, jump = true })
end, { noremap = true, silent = true })

View File

@ -0,0 +1 @@
onedark

View File

@ -1,3 +1,5 @@
require("tiagorg.set")
require("tiagorg.remap")
require('Comment').setup()
require("liveshare").setup()

View File

@ -14,10 +14,12 @@ return require('packer').startup(function(use)
require("monokai-pro").setup()
end
}
use({
use {
'rose-pine/neovim',
as = 'rose-pine',
})
}
use 'olimorris/onedarkpro.nvim'
use 'Mofiqul/vscode.nvim'
-- Essentials
use {

View File

@ -7,7 +7,7 @@ vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("v", "<Tab>", ">gv")
vim.keymap.set("v", "<S-Tab>", "<gv")
vim.keymap.set("n", "X", "@@", { noremap = true, silent = true })
vim.keymap.set("n", "Q", "@@", { noremap = true, silent = true })
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
@ -24,7 +24,6 @@ vim.keymap.set("n", "<leader>df", "<cmd>AerialPrev<CR>V$%d")
vim.keymap.set("i", "<C-c>", "<Esc>")
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format)
vim.keymap.set("n", "<leader>af", "ggVG")
@ -37,16 +36,17 @@ vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
vim.keymap.set("n", "<leader>r", [[:%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 })
-- vim.keymap.set("n", "<leader>X", "<cmd>!chmod -x %<CR>", { silent = true })
vim.keymap.set("n", "<leader>m", "<cmd>!make<CR>", { silent = true })
vim.keymap.set("n", "<leader>vpp", "<cmd>e ~/.config/nvim/lua/tiagorg/packer.lua<CR>");
vim.keymap.set("n", "<leader>so", function()
vim.cmd("so")
end)
vim.keymap.set("n", "<leader>vpp", "<cmd>so ~/.config/nvim/lua/tiagorg/packer.lua<CR>");
vim.keymap.set("n", "<C-q>", "<cmd>qa<CR>")
vim.keymap.set("n", "<A-t>", "<cmd>tabnew<CR><cmd>NvimTreeFocus<CR>")
vim.keymap.set("n", "<S-Tab>", "<C-w>w")
vim.api.nvim_exec([[
augroup SearchHighlight
autocmd!
autocmd CmdlineLeave /,\? :nnoremap <buffer> <Esc> :nohls<CR>
augroup END
]], false)

View File

@ -1,6 +1,6 @@
-- vim.opt.guicursor = ""
vim.opt.clipboard = "unnamedplus"
-- vim.opt.clipboard = "unnamedplus"
vim.opt.nu = true
vim.opt.relativenumber = true
@ -14,7 +14,7 @@ vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = false
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.termguicolors = true
@ -26,7 +26,7 @@ vim.opt.guitablabel = "\\[%N\\]\\ %t\\ %M"
vim.opt.updatetime = 50
vim.opt.colorcolumn = "0"
vim.opt.colorcolumn = "80"
vim.g.copilot_node_command = "/usr/bin/nodenv"
vim.g.copilot_assume_mapped = true

View File

@ -212,6 +212,11 @@ _G.packer_plugins = {
path = "/home/tiagorg/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
url = "https://github.com/nvim-tree/nvim-web-devicons"
},
["onedarkpro.nvim"] = {
loaded = true,
path = "/home/tiagorg/.local/share/nvim/site/pack/packer/start/onedarkpro.nvim",
url = "https://github.com/olimorris/onedarkpro.nvim"
},
["packer.nvim"] = {
loaded = true,
path = "/home/tiagorg/.local/share/nvim/site/pack/packer/start/packer.nvim",
@ -263,6 +268,11 @@ _G.packer_plugins = {
path = "/home/tiagorg/.local/share/nvim/site/pack/packer/start/vim-wakatime",
url = "https://github.com/wakatime/vim-wakatime"
},
["vscode.nvim"] = {
loaded = true,
path = "/home/tiagorg/.local/share/nvim/site/pack/packer/start/vscode.nvim",
url = "https://github.com/Mofiqul/vscode.nvim"
},
["wrapping.nvim"] = {
config = { "\27LJ\2\n6\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\rwrapping\frequire\0" },
loaded = true,
@ -272,18 +282,14 @@ _G.packer_plugins = {
}
time([[Defining packer_plugins]], false)
-- Config for: wrapping.nvim
time([[Config for wrapping.nvim]], true)
try_loadstring("\27LJ\2\n6\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\rwrapping\frequire\0", "config", "wrapping.nvim")
time([[Config for wrapping.nvim]], false)
-- Config for: monokai-pro.nvim
time([[Config for monokai-pro.nvim]], true)
try_loadstring("\27LJ\2\n9\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\16monokai-pro\frequire\0", "config", "monokai-pro.nvim")
time([[Config for monokai-pro.nvim]], false)
-- Config for: aerial.nvim
time([[Config for aerial.nvim]], true)
try_loadstring("\27LJ\2\n4\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\vaerial\frequire\0", "config", "aerial.nvim")
time([[Config for aerial.nvim]], false)
-- Config for: wrapping.nvim
time([[Config for wrapping.nvim]], true)
try_loadstring("\27LJ\2\n6\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\rwrapping\frequire\0", "config", "wrapping.nvim")
time([[Config for wrapping.nvim]], false)
-- Config for: nvim-surround
time([[Config for nvim-surround]], true)
try_loadstring("\27LJ\2\n?\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\18nvim-surround\frequire\0", "config", "nvim-surround")
@ -292,6 +298,10 @@ time([[Config for nvim-surround]], false)
time([[Config for tabset.nvim]], true)
try_loadstring("\27LJ\2\n4\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\vtabset\frequire\0", "config", "tabset.nvim")
time([[Config for tabset.nvim]], false)
-- Config for: monokai-pro.nvim
time([[Config for monokai-pro.nvim]], true)
try_loadstring("\27LJ\2\n9\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\16monokai-pro\frequire\0", "config", "monokai-pro.nvim")
time([[Config for monokai-pro.nvim]], false)
_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then

View File

@ -1,2 +0,0 @@
# Global snippets

View File

@ -1 +1,16 @@
extends _
# Global snippets
snippet c)
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.
snippet date
`strftime("%Y-%m-%d")`
snippet ddate
`strftime("%B %d, %Y")`
snippet diso
`strftime("%Y-%m-%dT%H:%M:%S")`
snippet time
`strftime("%H:%M")`
snippet datetime
`strftime("%Y-%m-%d %H:%M")`
snippet lorem
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -4,6 +4,3 @@ snippet so
Signed-off-by: ${1} <${2}>
snippet sotrg
Signed-off-by: TiagoRG <tiago.rgarcia@ua.pt>
snippet aed
Co-authored-by: diogotavc <diogo.tav.carvalho@ua.pt>
Signed-off-by: TiagoRG <tiago.rgarcia@ua.pt>

12
.local/bin/checkfreespace Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
if [ $# -eq 0 ]; then
mount_point="/"
else
mount_point="$1"
fi
read -ra space_info_arr <<< "$(df "$mount_point" -h | grep "/")"
free_space="${space_info_arr[3]}"
echo "$free_space"

7
.local/bin/discord-update Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
wget "https://discord.com/api/download/stable?platform=linux&format=tar.gz" -O /tmp/discord.tar.gz
tar -xvf "/tmp/discord.tar.gz" -C "/tmp/"
rm -rf "$HOME/.discord"
mv "/tmp/Discord" "$HOME/.discord"
betterdiscord-installer

23
.local/bin/git-fork-sync Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
if [ "$#" -ne 2 ]; then
printf "Usage: git-fork-sync <main_remote> <main_branch>"
exit
fi
main_remote="$1"
main_branch="$2"
if git rev-parse --is-inside-work-tree >/dev/null 2>/dev/null; then
printf "Trying to connect to remote %s...\n" "$main_remote"
if git ls-remote --exit-code "$main_remote" >/dev/null 2>/dev/null; then
git pull "$main_remote" "$main_branch"
git push --force
printf "\nSuccessfully resynced the forked repository.\n"
else
printf "\nRemote %s is unreachable for this repository.\nCheck if the name is correct and if it is, check if the remote url is correct.\n" "$main_remote"
fi
else
printf "You are currently not in a git repository."
fi

87
.local/bin/truthtable Executable file
View File

@ -0,0 +1,87 @@
#!/bin/python
import sys
import re
def main():
if len(sys.argv) == 1 or sys.argv[1] == 'usage':
print("""Usage:
truthtable '<function>':
Prints the truth table map of the function.
Valid characters:
> Variables: a-z
> Operators: +, *, ~, (, ); You can't use ~ before ()
truthtable usage:
Prints this message.""")
return
function = sys.argv[1]
validVariables = r"[a-z]"
validOperators = ['+', '*', '(', ')', '~', ' ', '0', '1']
for char in function:
if not (re.match(validVariables, char) or char in validOperators):
print("Invalid function, use 'truthtable usage' to see the valid characters.")
return
variables = re.findall(validVariables, function)
variables = list(dict.fromkeys(variables))
variables.sort()
truthTable = getTable(variables, function)
printTable(variables, truthTable)
def getTable(variables, function):
truthTable = {}
for n in range(2 ** len(variables)):
tempFunction = function
binary = bin(n)[2:]
binary = '0' * (len(variables) - len(binary)) + binary
index = 0
for var in tempFunction:
if index == len(tempFunction):
break
if var in "01" and tempFunction[index - 1] == '~':
tempFunction = tempFunction.replace('~' + var, str(1 - int(var) + " "))
if var in variables:
tempFunction = tempFunction[:index] + binary[variables.index(var)] + tempFunction[index+1:] if tempFunction[index - 1] != '~' else tempFunction[:index-1] + str(int(not bool(int(binary[variables.index(tempFunction[index])]))))+" " + tempFunction[index+1:]
index += 1
try:
truthTable[binary] = eval(tempFunction)
except:
print("Invalid function, use 'truthtable usage' to see the valid characters.")
return
if truthTable[binary] > 1:
truthTable[binary] = 1
if truthTable[binary] < 0:
truthTable[binary] = 0
return truthTable
def printTable(variables, truthTable):
for var in variables:
print("|---", end='')
print('|-----|')
for var in variables:
print("| " + var, end=' ')
print(f"{'| f() |'}")
for var in variables:
print("|---", end='')
print('|-----|')
for key, value in truthTable.items():
for char in key:
print("| " + char, end=' ')
print(f"| {value} |")
for var in variables:
print("|---", end='')
print('|-----|')
if __name__ == '__main__':
main()

37
.vimrc
View File

@ -1,22 +1,47 @@
set clipboard="unnamedplus"
set nu
set relativenumber
set tabstop=4
set shiftwidth=4
set ls=2
set hlsearch
set incsearch
set scrolloff=10
nnoremap <space>w :w<CR>
nnoremap <space>e :E<CR>
let g:mapleader = " "
nnoremap <leader>w :w<CR>
nnoremap <leader>e :E<CR>
xnoremap J :move '>+1<CR>gv=gv
xnoremap K :move '<-2<CR>gv=gv
nnoremap J mzJ`z
xnoremap <Tab> >gv
xnoremap <S-Tab> <gv
nnoremap <silent> X @@
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap <space>m :!make<CR>
nnoremap <leader>y "+y
vnoremap <leader>y "+y
nnoremap <leader>Y "+Y
nnoremap <leader>d "_d
vnoremap <leader>d "_d
nnoremap <silent> Q @@
nnoremap <leader>r :%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>
nnoremap <leader>m :!make<CR>
augroup SearchHighlight
autocmd!
autocmd CmdlineLeave /,\? :nnoremap <buffer> <Esc> :nohls<CR>
augroup END
augroup CursorShape
autocmd!
autocmd VimEnter,InsertEnter * set guicursor=n-v-c:block-Cursor/lCursor
autocmd InsertLeave * set guicursor=n-v-c:ver25-Cursor/lCursor
augroup END

View File

@ -279,7 +279,7 @@ fi
# Custom made alias
alias zshrc='vim /home/tiagorg/.zsh/.zshrc'
alias zshrc='vim /home/tiagorg/.zsh/.zshrc && ref'
# improved system commands
alias update='yay -Syu && flatpak update -y'
@ -292,6 +292,8 @@ alias sus='su'
alias s='sudo'
alias grepf='grep -sirnIE'
alias tl='telnet localhost'
alias py='python'
alias core='echo "core.%e.%p" | sudo tee /proc/sys/kernel/core_pattern'
# uaveiro-leci repository
alias ua='cd /home/tiagorg/repos/uaveiro-leci'
@ -302,6 +304,8 @@ alias aed='/home/tiagorg/repos/uaveiro-leci/2ano/1semestre/aed/setup.sh'
alias vpn='sudo snx -s go.ua.pt -u tiago.rgarcia@ua.pt'
alias vpnd='sudo snx -d'
alias liveshare-nvim='/home/tiagorg/.local/share/nvim/site/pack/packer/start/liveshare.nvim'
source /home/tiagorg/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
source /home/tiagorg/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999999'