diff --git a/.config/nvim/after/plugin/colors.lua b/.config/nvim/after/plugin/colors.lua index 815ee3a..e3818b0 100644 --- a/.config/nvim/after/plugin/colors.lua +++ b/.config/nvim/after/plugin/colors.lua @@ -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()]]) + diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index d3f2662..8f16707 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -42,8 +42,8 @@ lsp.on_attach(function(client, bufnr) vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) vim.keymap.set("n", "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", "vca", function() vim.lsp.buf.code_action() end, opts) vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) diff --git a/.config/nvim/after/plugin/nvim-tree.lua b/.config/nvim/after/plugin/nvim-tree.lua index 6606c96..e44ef94 100644 --- a/.config/nvim/after/plugin/nvim-tree.lua +++ b/.config/nvim/after/plugin/nvim-tree.lua @@ -21,5 +21,5 @@ require("nvim-tree").setup({ }, }) -vim.api.nvim_set_keymap('n', '', ':NvimTreeToggle', {noremap = true, silent = true}) +vim.api.nvim_set_keymap('n', '', ':NvimTreeToggle', { noremap = true, silent = true }) vim.keymap.set("n", "e", "NvimTreeFocus") diff --git a/.config/nvim/after/plugin/telescope.lua b/.config/nvim/after/plugin/telescope.lua index 9fa92d6..e079284 100644 --- a/.config/nvim/after/plugin/telescope.lua +++ b/.config/nvim/after/plugin/telescope.lua @@ -1,8 +1,8 @@ local builtin = require('telescope.builtin') +local trouble = require('trouble.providers.telescope') -- File pickers vim.keymap.set('n', 'pf', "Telescope find_files hidden=true", {}) -vim.keymap.set('n', '', builtin.git_files, {}) vim.keymap.set('n', 'pg', builtin.live_grep, {}) vim.keymap.set('n', 'ps', function() builtin.grep_string({ search = vim.fn.input("Grep > ") }); @@ -10,4 +10,7 @@ end) -- Git pickers vim.keymap.set('n', 'gc', builtin.git_commits, {}) -vim.keymap.set('n', 'gs', builtin.git_status, {}) +vim.keymap.set('n', 'gs', builtin.git_stash, {}) + +-- LSP pickers +vim.keymap.set('n', 'pe', trouble.open_with_trouble, {}) diff --git a/.config/nvim/after/plugin/toggleterm.lua b/.config/nvim/after/plugin/toggleterm.lua index d06463b..a1c6843 100644 --- a/.config/nvim/after/plugin/toggleterm.lua +++ b/.config/nvim/after/plugin/toggleterm.lua @@ -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, }, diff --git a/.config/nvim/after/plugin/treesitter.lua b/.config/nvim/after/plugin/treesitter.lua index 0b5127a..20062f9 100644 --- a/.config/nvim/after/plugin/treesitter.lua +++ b/.config/nvim/after/plugin/treesitter.lua @@ -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 diff --git a/.config/nvim/after/plugin/trouble.lua b/.config/nvim/after/plugin/trouble.lua index 7987acf..ab36824 100644 --- a/.config/nvim/after/plugin/trouble.lua +++ b/.config/nvim/after/plugin/trouble.lua @@ -8,3 +8,9 @@ require("trouble").setup { -- Keybindings vim.keymap.set("n", "x", "TroubleToggle workspace_diagnostics", { 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 }) diff --git a/.config/nvim/data/colorscheme.txt b/.config/nvim/data/colorscheme.txt new file mode 100644 index 0000000..3b15296 --- /dev/null +++ b/.config/nvim/data/colorscheme.txt @@ -0,0 +1 @@ +onedark \ No newline at end of file diff --git a/.config/nvim/lua/tiagorg/init.lua b/.config/nvim/lua/tiagorg/init.lua index 5e55698..462887a 100644 --- a/.config/nvim/lua/tiagorg/init.lua +++ b/.config/nvim/lua/tiagorg/init.lua @@ -1,3 +1,5 @@ require("tiagorg.set") require("tiagorg.remap") require('Comment').setup() + +require("liveshare").setup() diff --git a/.config/nvim/lua/tiagorg/packer.lua b/.config/nvim/lua/tiagorg/packer.lua index 9332081..ffc60b4 100644 --- a/.config/nvim/lua/tiagorg/packer.lua +++ b/.config/nvim/lua/tiagorg/packer.lua @@ -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 { diff --git a/.config/nvim/lua/tiagorg/remap.lua b/.config/nvim/lua/tiagorg/remap.lua index db819cb..d27113e 100644 --- a/.config/nvim/lua/tiagorg/remap.lua +++ b/.config/nvim/lua/tiagorg/remap.lua @@ -7,7 +7,7 @@ vim.keymap.set("v", "K", ":m '<-2gv=gv") vim.keymap.set("v", "", ">gv") vim.keymap.set("v", "", "", "zz") @@ -24,7 +24,6 @@ vim.keymap.set("n", "df", "AerialPrevV$%d") vim.keymap.set("i", "", "") -vim.keymap.set("n", "Q", "") vim.keymap.set("n", "f", vim.lsp.buf.format) vim.keymap.set("n", "af", "ggVG") @@ -37,16 +36,17 @@ vim.keymap.set("n", "j", "lprevzz") vim.keymap.set("n", "r", [[:%s/\<\>//gI]]) --- vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) --- vim.keymap.set("n", "X", "!chmod -x %", { silent = true }) vim.keymap.set("n", "m", "!make", { silent = true }) -vim.keymap.set("n", "vpp", "e ~/.config/nvim/lua/tiagorg/packer.lua"); - -vim.keymap.set("n", "so", function() - vim.cmd("so") -end) +vim.keymap.set("n", "vpp", "so ~/.config/nvim/lua/tiagorg/packer.lua"); vim.keymap.set("n", "", "qa") vim.keymap.set("n", "", "tabnewNvimTreeFocus") vim.keymap.set("n", "", "w") + +vim.api.nvim_exec([[ + augroup SearchHighlight + autocmd! + autocmd CmdlineLeave /,\? :nnoremap :nohls + augroup END +]], false) diff --git a/.config/nvim/lua/tiagorg/set.lua b/.config/nvim/lua/tiagorg/set.lua index d0323da..1ccc25a 100644 --- a/.config/nvim/lua/tiagorg/set.lua +++ b/.config/nvim/lua/tiagorg/set.lua @@ -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 diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua index 7b8da07..b28a435 100644 --- a/.config/nvim/plugin/packer_compiled.lua +++ b/.config/nvim/plugin/packer_compiled.lua @@ -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 diff --git a/.config/nvim/snippets/_.snippets b/.config/nvim/snippets/_.snippets deleted file mode 100644 index f6c5ab3..0000000 --- a/.config/nvim/snippets/_.snippets +++ /dev/null @@ -1,2 +0,0 @@ -# Global snippets - diff --git a/.config/nvim/snippets/all.snippets b/.config/nvim/snippets/all.snippets index 2f27652..4a5f69c 100644 --- a/.config/nvim/snippets/all.snippets +++ b/.config/nvim/snippets/all.snippets @@ -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. diff --git a/.config/nvim/snippets/gitcommit.snippets b/.config/nvim/snippets/gitcommit.snippets index 6e44cd2..cf64d82 100644 --- a/.config/nvim/snippets/gitcommit.snippets +++ b/.config/nvim/snippets/gitcommit.snippets @@ -4,6 +4,3 @@ snippet so Signed-off-by: ${1} <${2}> snippet sotrg Signed-off-by: TiagoRG -snippet aed - Co-authored-by: diogotavc - Signed-off-by: TiagoRG diff --git a/.local/bin/checkfreespace b/.local/bin/checkfreespace new file mode 100755 index 0000000..91726b7 --- /dev/null +++ b/.local/bin/checkfreespace @@ -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" diff --git a/.local/bin/discord-update b/.local/bin/discord-update new file mode 100755 index 0000000..525cd7a --- /dev/null +++ b/.local/bin/discord-update @@ -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 diff --git a/.local/bin/git-fork-sync b/.local/bin/git-fork-sync new file mode 100755 index 0000000..e10d925 --- /dev/null +++ b/.local/bin/git-fork-sync @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + printf "Usage: git-fork-sync " + 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 diff --git a/.local/bin/truthtable b/.local/bin/truthtable new file mode 100755 index 0000000..51e5ed8 --- /dev/null +++ b/.local/bin/truthtable @@ -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 '': + 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() diff --git a/.vimrc b/.vimrc index 4f3ce7d..ac131b6 100644 --- a/.vimrc +++ b/.vimrc @@ -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 w :w -nnoremap e :E +let g:mapleader = " " + +nnoremap w :w +nnoremap e :E xnoremap J :move '>+1gv=gv xnoremap K :move '<-2gv=gv +nnoremap J mzJ`z xnoremap >gv xnoremap X @@ - nnoremap n nzzzv nnoremap N Nzzzv -nnoremap m :!make +nnoremap y "+y +vnoremap y "+y +nnoremap Y "+Y +nnoremap d "_d +vnoremap d "_d + +nnoremap Q @@ + +nnoremap r :%s/\<\>//gI + +nnoremap m :!make + +augroup SearchHighlight + autocmd! + autocmd CmdlineLeave /,\? :nnoremap :nohls +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 + diff --git a/.zsh/.zshrc b/.zsh/.zshrc index 2d09761..2043240 100644 --- a/.zsh/.zshrc +++ b/.zsh/.zshrc @@ -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'