From 15839990ddd952aa67bd4889368a5a9be0d33339 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Mon, 19 Aug 2024 18:48:44 -0400 Subject: tweak config and nvim --- .config/nvim/init.lua | 84 ++++++++++++++++++++++++++++++++++++--------------- .zshrc | 42 ++++---------------------- 2 files changed, 66 insertions(+), 60 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index c9f3e12..16d6cfd 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -135,6 +135,16 @@ require("packer").startup(function(use) end, }) + use({ + "ellisonleao/glow.nvim", + config = function() + require("glow").setup({ + -- Configure options here + width = 120, -- Set the width of the preview + }) + end, + }) + -- Automatically set up configuration after cloning packer.nvim -- This should be kept at the end after all plugins if packer_bootstrap then @@ -355,19 +365,27 @@ require("toggleterm").setup({ --- Key mappings -- Telescope 'Find Files' -vim.api.nvim_set_keymap("n", "ff", ":Telescope find_files", { noremap = true, silent = true }) +vim.api.nvim_set_keymap( + "n", + "ff", + ":Telescope find_files find_command=rg,--ignore,--hidden,--files,--glob=!**/.git", + { noremap = true, silent = true } +) -- Telescope 'Find Grep' for text search vim.api.nvim_set_keymap("n", "fg", ":Telescope live_grep", { noremap = true, silent = true }) -- Telescope 'Find symbols' -vim.api.nvim_set_keymap("n", "fs", ":Telescope treesitter", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "fs", ":Telescope lsp_document_symbols", { noremap = true, silent = true }) +-- Telescope 'Find Workspace Symbols' -- Finds all symbols across the workspace rather than a single file +vim.api.nvim_set_keymap( + "n", + "fw", + ":Telescope lsp_dynamic_workspace_symbols", + { noremap = true, silent = true } +) -- Telescope 'Find buffers' vim.api.nvim_set_keymap("n", "fb", ":Telescope buffers", { noremap = true, silent = true }) --- LSP 'Find symbols' -- More context aware symbol information if LSP is setup for the language -vim.api.nvim_set_keymap("n", "ls", ":Telescope lsp_document_symbols", { noremap = true, silent = true }) --- LSP 'Find Workspace Symbols' -- Finds all symbols across the workspace rather than a single file -vim.api.nvim_set_keymap("n", "lw", ":Telescope lsp_workspace_symbols", { noremap = true, silent = true }) --- LSP 'Format' -- Formats the current file asyncronously +-- Telescope 'Format' -- Formats the current file asyncronously vim.api.nvim_set_keymap( "n", "lf", @@ -380,11 +398,11 @@ vim.api.nvim_set_keymap("n", "gs", ":G", { noremap = true, silent = -- 'Git diff' vim.api.nvim_set_keymap("n", "gd", ":Gdiff", { noremap = true, silent = true }) -- 'Git diff --staged' -vim.api.nvim_set_keymap('n', 'gds', ':Gdiffsplit --staged', { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "gds", ":Gdiff --staged", { noremap = true, silent = true }) -- Toggle/Update docs view -vim.api.nvim_set_keymap('n', 'dt', ':DocsViewToggle', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'du', ':DocsViewUpdate', { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "dt", ":DocsViewToggle", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "du", ":DocsViewUpdate", { noremap = true, silent = true }) -- Close the current window vim.api.nvim_set_keymap("n", "q", ":q", { noremap = true, silent = true }) @@ -398,20 +416,38 @@ vim.api.nvim_set_keymap("s", "", "lua require'luasnip'.jump(-1)", -- Mappings for opening terminals vim.api.nvim_set_keymap("n", "tt", ":ToggleTerm", { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'th', ':ToggleTerm size=15 direction=horizontal', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'tv', ':ToggleTerm size=60 direction=vertical', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'tf', ':ToggleTerm direction=float', { noremap = true, silent = true }) - +vim.api.nvim_set_keymap( + "n", + "th", + ":ToggleTerm size=15 direction=horizontal", + { noremap = true, silent = true } +) +vim.api.nvim_set_keymap( + "n", + "tv", + ":ToggleTerm size=60 direction=vertical", + { noremap = true, silent = true } +) +vim.api.nvim_set_keymap("n", "tf", ":ToggleTerm direction=float", { noremap = true, silent = true }) +-- Increase terminal height +vim.api.nvim_set_keymap("n", "+", ":resize +5", { noremap = true, silent = true }) +-- Decrease terminal height +vim.api.nvim_set_keymap("n", "-", ":resize -5", { noremap = true, silent = true }) +-- Increase terminal width (for vertical terminals) +vim.api.nvim_set_keymap("n", ">", ":vertical resize +5", { noremap = true, silent = true }) +-- Decrease terminal width (for vertical terminals) +vim.api.nvim_set_keymap("n", "<", ":vertical resize -5", { noremap = true, silent = true }) -- Map in terminal mode to exit to normal mode -vim.api.nvim_set_keymap('t', '', '', { noremap = true, silent = true }) +vim.api.nvim_set_keymap("t", "", "", { noremap = true, silent = true }) -- Use Ctrl-[hjkl] to navigate between splits -vim.api.nvim_set_keymap('n', '', ':wincmd k', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', '', ':wincmd j', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', '', ':wincmd h', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', '', ':wincmd l', { noremap = true, silent = true }) - --- Command to run C programs -vim.api.nvim_create_user_command("RunC", function(opts) - vim.cmd("!./" .. vim.fn.expand("%<") .. " " .. opts.args) -end, { nargs = 1 }) +vim.api.nvim_set_keymap("n", "", ":wincmd k", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "", ":wincmd j", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "", ":wincmd h", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "", ":wincmd l", { noremap = true, silent = true }) + +vim.api.nvim_set_keymap("n", "e", ":NvimTreeToggle", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "", ":noh", { noremap = true, silent = true }) + +-- Key mapping to preview markdown +vim.api.nvim_set_keymap("n", "mp", ":Glow", { noremap = true, silent = true }) diff --git a/.zshrc b/.zshrc index d5f1e04..1ea1e6b 100755 --- a/.zshrc +++ b/.zshrc @@ -34,7 +34,6 @@ export PATH="$GOBIN:$PATH" source "$HOME/.cargo/env" export BAT_THEME="gruvbox-dark" -export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git" export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" @@ -45,6 +44,12 @@ eval "$(pyenv virtualenv-init -)" export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +export PNPM_HOME="/Users/eugene/Library/pnpm" +case ":$PATH:" in + *":$PNPM_HOME:"*) ;; + *) export PATH="$PNPM_HOME:$PATH" ;; +esac + export LDFLAGS="-L/opt/homebrew/lib" export CPPFLAGS="-I/opt/homebrew/include" export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib" @@ -73,38 +78,3 @@ alias vicfg="nvim ~/.config/nvim/init.lua" alias python="python3" -# "Compile C Program" -# -# $1: Program Name -# $2: Output File (default: a.out) -# $3: C Standard (default: c11) -# -# Example: ccp main.c main c99 -function ccp() { - local prog_name=${1:?"Please provide the path to the program to compile"} - local output_file=${2:-${prog_name:r}} - local std=${3:-c11} - - gcc -Wall -W -pedantic -ansi -std=$std -o $output_file $prog_name -} - -memcheck() { - G_DEBUG=always-malloc valgrind --tool=memcheck --leak-check=full --show-reachable=yes -s $1 -} - -gocover() { - t="/tmp/go-cover.$$.tmp" - go test -coverprofile=$t $@ && go tool cover -html=$t && unlink $t -} - -# pnpm -export PNPM_HOME="/Users/eugene/Library/pnpm" -case ":$PATH:" in - *":$PNPM_HOME:"*) ;; - *) export PATH="$PNPM_HOME:$PATH" ;; -esac -# pnpm end - -export CPPFLAGS="-I/usr/local/opt/readline/include" -export LDFLAGS="-L/usr/local/opt/readline/lib" -export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig" -- cgit v1.2.3