From a8735ea716fff40e603360a3248a8e8fb4585b1d Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Fri, 25 Aug 2023 20:57:39 -0400 Subject: [PATCH] updates to dotfile --- .config/bash/.bash_aliases | 1 + .config/bash/.bash_profile | 155 +++++++++++++++ .config/nvim/lazy-lock.json | 54 +++--- .config/nvim/lua/plugins/autotag.lua | 25 +-- .config/nvim/lua/plugins/markdown-preview.lua | 9 + .config/nvim/lua/plugins/neo-tree.lua | 133 ++++++------- .../lua/plugins/telescope-file-browser.lua | 12 +- .config/nvim/lua/plugins/telescope.lua | 176 +++++++++--------- .config/nvim/lua/plugins/treesitter.lua | 4 +- 9 files changed, 369 insertions(+), 200 deletions(-) create mode 100644 .config/bash/.bash_aliases create mode 100644 .config/bash/.bash_profile create mode 100644 .config/nvim/lua/plugins/markdown-preview.lua diff --git a/.config/bash/.bash_aliases b/.config/bash/.bash_aliases new file mode 100644 index 0000000..af6daaf --- /dev/null +++ b/.config/bash/.bash_aliases @@ -0,0 +1 @@ +alias gs="git status" diff --git a/.config/bash/.bash_profile b/.config/bash/.bash_profile new file mode 100644 index 0000000..208d0cc --- /dev/null +++ b/.config/bash/.bash_profile @@ -0,0 +1,155 @@ +# list directory and cd into it +sd() { + local path=${1:-.} + local result=$(ls -d ${path}/*/ 2> /dev/null | fzf) + if [[ -n "${result}" ]]; then + cd "${result}" + else + echo "No directories found or no selection made." + fi +} + +# list files and opens it in neovim +sf() { + local path=${2:-.} + if [[ $1 == "-h" ]]; then + local result=$(find ${path} -type f -name '.*' 2> /dev/null | fzf) + else + local result=$(find ${path} -type f 2> /dev/null | fzf) + fi + if [[ -n "${result}" ]]; then + nvim "${result}" + else + echo "No files found or no selecteion made." + fi +} + +# fuzzy cd into specific folders +fcd() { + local selected_dir=$({ + echo "$HOME/.config" + find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d + ls -d -1 "$HOME/"/*/ | grep -v \.git + ls -d -1 */ | perl -pe "s#^#$PWD/#" | grep -v \.git + } | fzf) + + if [ -n "$selected_dir" ]; then + cd "$selected_dir" + if [[ -f .nvmrc ]]; then + NVMRC_VERSION=$(cat .nvmrc) + CURRENT_VERSION=$(nvm current) + if [ "$NVMRC_VERSIOn" != "$CURRENT_VERSION" ]; then + nvm use + fi + fi + else + echo "No selection made." + fi +} + +# clone repository +gc() { + local url=$1 + local ghq_dir="$HOME/ghq" + + # extract project name + if [[ $url =~ git@github\.com:([^/]+)/([^/]+)\.git ]]; then + local project_name="${BASH_REMATCH[1]}" + local repository_name="${BASH_REMATCH[2]}" + elif [[ $url =~ https://github\.com/([^/]+)/([^/]+)\.git ]]; then + local project_name="${BASH_REMATCH[1]}" + local repository_name="${BASH_REMATCH[2]}" + else + echo "Invalid URL format" + return 1 + fi + + # check if directory for project exists or not + local project_dir="${ghq_dir}/${project_name}/${repository_name}" + if [[ ! -d $project_dir ]]; then + mkdir -p $project_dir + fi + + git clone $url $project_dir +} + +# get branch if available +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' +} + +# Set prompt +color_prompt=yes + +if [ "$color_prompt" = yes ]; then + PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]\$(parse_git_branch)\[\033[00m\] \$ " +else + PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$(parse_git_branch)\$ " +fi +unset color_prompt + +# install curl to complete auto installs +type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) + +# auto install nvm +command -v nvm > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "NVM is not installed. Installing now..." + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash + echo "NVM is now installed. Installing node..." + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + nvm install lts && nvm use lts + echo "Node is now installed." +fi + +# auto install pnpm +command -v pnpm > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "PNPM is not installed. Installing now..." + export SHELL=/bin/bash + curl -fsSL https://get.pnpm.io/install.sh | sh - + # pnpm + export PNPM_HOME="/root/.local/share/pnpm" + case ":$PATH:" in + *":$PNPM_HOME:"*) ;; + *) export PATH="$PNPM_HOME:$PATH" ;; + esac + # pnpm end + echo "PNPM is now installed." +fi + +# auto install gh cli +command -v gh > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "GitHub CLI is not installed. Installing now..." + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && sudo apt update \ + && sudo apt install gh -y + + echo "GitHub CLI is now installed." +fi + +# auto install neovim +command -v nvim > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "NeoVim is not installed. Installing now..." + mkdir -p ~/opt + curl -L https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz -o ~/opt/nvim-linux64.tar.gz + tar xzf ~/opt/nvim-linux64.tar.gz -C ~/opt + + # create symlink + ln -s ~/opt/nvim-linux64/bin/nvim /usr/local/bin/nvim + # create symlink as vim if vim is not installed + type -p vim >/dev/null || ln -s ~/opt/nvim-linux64/bin/nvim /usr/local/bin/vim + + # remove tar file + rm ~/opt/nvim-linux64.tar.gz + + echo "NeoVim is now installed." +fi + +export PATH=$PATH:/usr/local/go/bin:/home/jc/go/bin diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 5508d43..08a996c 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,39 +1,39 @@ { - "Comment.nvim": { "branch": "master", "commit": "176e85eeb63f1a5970d6b88f1725039d85ca0055" }, - "LuaSnip": { "branch": "master", "commit": "a658ae2906344a1d2b9c507738e585cf68e685c7" }, + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "c4d6298347f7707e9757351b2ee03d0c00da5c20" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, - "fzf": { "branch": "master", "commit": "547e101f1d6bf326d286bac0fb3272738a92a67f" }, - "fzf-lua": { "branch": "main", "commit": "19732fdf9b8b038b6a5813b077b382ab2b48e094" }, - "git.nvim": { "branch": "main", "commit": "7a342e61f28e321ef08e00fca4be74ff3ef88335" }, - "gitsigns.nvim": { "branch": "main", "commit": "dc2962f7fce953a2a98e7c6d3d7fc4c1d1f66758" }, + "fzf": { "branch": "master", "commit": "178581b56001f7553fe83b15dab820179521a915" }, + "fzf-lua": { "branch": "main", "commit": "b7bda51ba7d0c07aaa30e8428a6531e939f6c3a3" }, + "git.nvim": { "branch": "main", "commit": "eb09b8d01d7bb38ca1d65ed0d82d71bddcd8a8bd" }, + "gitsigns.nvim": { "branch": "main", "commit": "79127db3b127f5d125f35e0d44ba60715edf2842" }, "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, - "lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" }, - "lsp-zero.nvim": { "branch": "v2.x", "commit": "7b9627c2cb50906993e194290b2e539c95dfdf47" }, - "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "82685fdd0f67a694b244cb058b83761f54664d68" }, - "mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, - "neo-tree.nvim": { "branch": "v2.x", "commit": "7f6fa04dbd8e8c79d1af33bc90e856b65d8641da" }, - "nui.nvim": { "branch": "main", "commit": "d146966a423e60699b084eeb28489fe3b6427599" }, - "null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" }, - "nvim-autopairs": { "branch": "master", "commit": "e8f7dd7a72de3e7b6626c050a802000e69d53ff0" }, - "nvim-cmp": { "branch": "main", "commit": "2743dd989e9b932e1b4813a4927d7b84272a14e2" }, - "nvim-dap": { "branch": "master", "commit": "3bde6f786057fa29d8356559b2ae3a52d9317fba" }, + "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, + "lsp-zero.nvim": { "branch": "v2.x", "commit": "f084f4a6a716f55bf9c4026e73027bb24a0325a3" }, + "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, + "markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "2997f467881ac4faa6f8c5e7065e3a672297c8ad" }, + "mason.nvim": { "branch": "main", "commit": "4a8deb615a477029a549cea5cef69d90e4d1f850" }, + "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, + "nvim-autopairs": { "branch": "master", "commit": "ae5b41ce880a6d850055e262d6dfebd362bb276e" }, + "nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" }, + "nvim-dap": { "branch": "master", "commit": "4377a05b9476587b7b485d6a9d9745768c4e4b37" }, "nvim-dap-ui": { "branch": "master", "commit": "85b16ac2309d85c88577cd8ee1733ce52be8227e" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, - "nvim-lspconfig": { "branch": "master", "commit": "deade69789089c3da15237697156334fb3e943f0" }, - "nvim-treesitter": { "branch": "master", "commit": "d9104a1d10023ed9e7eacf68639ad887425246eb" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "52f1f3280d9092bfaee5c45be5962fabee3d9654" }, + "nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" }, + "nvim-treesitter": { "branch": "master", "commit": "4d41d9bfb09dd0836ce6910404e3cd570500c9ca" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "e3e2b6de4ccf781fb653a3a1d397aeb4a0095609" }, "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "7f625207f225eea97ef7a6abe7611e556c396d2f" }, - "nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" }, - "plenary.nvim": { "branch": "master", "commit": "bda256fab0eb66a15e8190937e417e6a14ee5d72" }, - "rose-pine": { "branch": "main", "commit": "932adb0d9351186db047302de021bb2976756a07" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "9bff161dfece6ecf3459e6e46ca42e49f9ed939f" }, + "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, + "plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" }, + "rose-pine": { "branch": "main", "commit": "e29002cbee4854a9c8c4b148d8a52fae3176070f" }, "telescope-dap.nvim": { "branch": "master", "commit": "313d2ea12ae59a1ca51b62bf01fc941a983d9c9c" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "ad7b637c72549713b9aaed7c4f9c79c62bcbdff0" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, - "todo-comments.nvim": { "branch": "main", "commit": "09b0b17d824d2d56f02ff15967e8a2499a89c731" }, + "todo-comments.nvim": { "branch": "main", "commit": "3094ead8edfa9040de2421deddec55d3762f64d1" }, "undotree": { "branch": "master", "commit": "0e11ba7325efbbb3f3bebe06213afa3e7ec75131" }, - "vim-floaterm": { "branch": "master", "commit": "bd0aee3c861d613f56b85bd9eaffdcab459071fd" }, + "vim-floaterm": { "branch": "master", "commit": "bcaeabf89a92a924031d471395054d84bd88ce2f" }, "vscode-js-debug": { "branch": "main", "commit": "16b9a70171b94cfe4aafc49e991f93b87b8ffb77" }, - "which-key.nvim": { "branch": "main", "commit": "96e99913df649d45333a9ad625ad4c72d5e65fe1" } + "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" } } \ No newline at end of file diff --git a/.config/nvim/lua/plugins/autotag.lua b/.config/nvim/lua/plugins/autotag.lua index e5d682f..97af870 100644 --- a/.config/nvim/lua/plugins/autotag.lua +++ b/.config/nvim/lua/plugins/autotag.lua @@ -1,13 +1,16 @@ return { - "windwp/nvim-ts-autotag", - dependencies = { "nvim-treesitter/nvim-treesitter", build = ':TSUpdate' }, - ft = { - "javascriptreact", - "typescriptreact", - "html" - }, - config = function() - local autotag = require('nvim-ts-autotag') - autotag.setup() - end + "windwp/nvim-ts-autotag", + dependencies = { "nvim-treesitter/nvim-treesitter", build = ':TSUpdate' }, + ft = { + "javascriptreact", + "typescriptreact", + "html" + }, + config = function() + local autotag = require('nvim-ts-autotag') + autotag.setup({ + enable = true, + enable_close_on_slash = false, + }) + end } diff --git a/.config/nvim/lua/plugins/markdown-preview.lua b/.config/nvim/lua/plugins/markdown-preview.lua new file mode 100644 index 0000000..6a584bf --- /dev/null +++ b/.config/nvim/lua/plugins/markdown-preview.lua @@ -0,0 +1,9 @@ +return { + "iamcco/markdown-preview.nvim", + build = function() + vim.fn["mkdp#util#install"]() + end, + keys = { + { "mp", "MarkdownPreview", desc = "Toggle [M]arkdown [P]review" } + } +} diff --git a/.config/nvim/lua/plugins/neo-tree.lua b/.config/nvim/lua/plugins/neo-tree.lua index 7f9aa5f..5a640e7 100644 --- a/.config/nvim/lua/plugins/neo-tree.lua +++ b/.config/nvim/lua/plugins/neo-tree.lua @@ -1,70 +1,71 @@ return { - "nvim-neo-tree/neo-tree.nvim", - branch = "v2.x", - cmd = { "Neotree" }, - keys = { - { "fs", "NeoTreeFloatToggle", desc = "Toggle [F]ile [S]ystem Floating Menu" }, - { "", "NeoTreeFocusToggle", desc = "Open Side File System" } - }, - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - config = { - use_default_mappings = true, - mappings = { - [""] = { - "toggle_node", - nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use - }, - ["<2-LeftMouse>"] = "open", - [""] = "open", - [""] = "cancel", -- close preview or floating neo-tree window - ["P"] = { "toggle_preview", config = { use_float = true } }, - ["l"] = "focus_preview", - ["O"] = "open_split", - ["o"] = "open_vsplit", - ["S"] = "none", - ["s"] = "none", - -- ["S"] = "split_with_window_picker", - -- ["s"] = "vsplit_with_window_picker", - ["t"] = "open_tabnew", - -- [""] = "open_drop", - -- ["t"] = "open_tab_drop", - ["w"] = "open_with_window_picker", - --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing - ["C"] = "close_node", - -- ['C'] = 'close_all_subnodes', - ["z"] = "close_all_nodes", - --["Z"] = "expand_all_nodes", - ["a"] = { - "add", - -- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details - -- some commands may take optional config options, see `:h neo-tree-mappings` for details - config = { - show_path = "none" -- "none", "relative", "absolute" - } - }, - ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion. - ["d"] = "delete", - ["r"] = "rename", - ["y"] = "copy_to_clipboard", - ["x"] = "cut_to_clipboard", - ["p"] = "paste_from_clipboard", - ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add": - -- ["c"] = { - -- "copy", - -- config = { - -- show_path = "none" -- "none", "relative", "absolute" - -- } - --} - ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add". - ["q"] = "close_window", - ["R"] = "refresh", - ["?"] = "show_help", - ["<"] = "prev_source", - [">"] = "next_source", + "nvim-neo-tree/neo-tree.nvim", + enabled = false, + branch = "v2.x", + cmd = { "Neotree" }, + keys = { + { "fs", "NeoTreeFloatToggle", desc = "Toggle [F]ile [S]ystem Floating Menu" }, + { "", "NeoTreeFocusToggle", desc = "Open Side File System" } + }, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = { + use_default_mappings = true, + mappings = { + [""] = { + "toggle_node", + nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use + }, + ["<2-LeftMouse>"] = "open", + [""] = "open", + [""] = "cancel", -- close preview or floating neo-tree window + ["P"] = { "toggle_preview", config = { use_float = true } }, + ["l"] = "focus_preview", + ["O"] = "open_split", + ["o"] = "open_vsplit", + ["S"] = "none", + ["s"] = "none", + -- ["S"] = "split_with_window_picker", + -- ["s"] = "vsplit_with_window_picker", + ["t"] = "open_tabnew", + -- [""] = "open_drop", + -- ["t"] = "open_tab_drop", + ["w"] = "open_with_window_picker", + --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing + ["C"] = "close_node", + -- ['C'] = 'close_all_subnodes', + ["z"] = "close_all_nodes", + --["Z"] = "expand_all_nodes", + ["a"] = { + "add", + -- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details + -- some commands may take optional config options, see `:h neo-tree-mappings` for details + config = { + show_path = "none" -- "none", "relative", "absolute" } + }, + ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion. + ["d"] = "delete", + ["r"] = "rename", + ["y"] = "copy_to_clipboard", + ["x"] = "cut_to_clipboard", + ["p"] = "paste_from_clipboard", + ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add": + -- ["c"] = { + -- "copy", + -- config = { + -- show_path = "none" -- "none", "relative", "absolute" + -- } + --} + ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add". + ["q"] = "close_window", + ["R"] = "refresh", + ["?"] = "show_help", + ["<"] = "prev_source", + [">"] = "next_source", } + } } diff --git a/.config/nvim/lua/plugins/telescope-file-browser.lua b/.config/nvim/lua/plugins/telescope-file-browser.lua index 4419301..b75a424 100644 --- a/.config/nvim/lua/plugins/telescope-file-browser.lua +++ b/.config/nvim/lua/plugins/telescope-file-browser.lua @@ -1,8 +1,8 @@ return { - "nvim-telescope/telescope-file-browser.nvim", - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/plenary.nvim", - }, - enabled = false, + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim", + }, + enabled = true, } diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 87beb48..10c670a 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,92 +1,92 @@ return { - "nvim-telescope/telescope.nvim", - version = "0.1.2", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - local telescope = require("telescope") - local actions = require("telescope.actions") - local builtin = require("telescope.builtin") - -- local fb_actions = require "telescope".extensions.file_browser.actions - -- - -- local function telescope_buffer_dir() - -- return vim.fn.expand("%:p:h") - -- end + "nvim-telescope/telescope.nvim", + version = "0.1.2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + local builtin = require("telescope.builtin") + local fb_actions = require "telescope".extensions.file_browser.actions - telescope.setup({ - defaults = { - mappings = { - n = { - ['q'] = actions.close - } - } - }, - -- extensions = { - -- file_browser = { - -- theme = "dropdown", - -- hijack_netrw = true, - -- hidden = true, - -- mappings = { - -- ['i'] = { - -- [''] = function() vim.cmd("normal vbd") end, - -- [''] = function(bufnr) actions.move_selection_next(bufnr) end, - -- [''] = function(bufnr) actions.move_selection_previous(bufnr) end, - -- [''] = function(bufnr) actions.select_vertical(bufnr) end, - -- }, - -- ['n'] = { - -- ['N'] = fb_actions.create, - -- ['h'] = fb_actions.goto_parent_dir, - -- ['/'] = function() vim.cmd("startinsert") end, - -- ['D'] = fb_actions.remove, - -- [''] = function(bufnr) actions.select_vertical(bufnr) end, - -- [''] = function(bufnr) actions.toggle_all(bufnr) end, - -- } - -- } - -- }, - -- } - }) - - -- pcall(telescope.load_extension, "file_browser") - pcall(telescope.load_extension, "fzf") - pcall(telescope.load_extension, "dap") - - -- Builtin pickers - vim.keymap.set("n", "sf", function() - builtin.find_files({ no_ignore = false, hidden = true }) - end, { desc = "[S]earch [F]iles" }) - vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" }) - vim.keymap.set("n", "sb", builtin.buffers, { desc = "[S]earch [B]uffers" }) - vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch [W]ord" }) - vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) - vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) - vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true }) - - -- Git pickers - vim.keymap.set("n", "gf", builtin.git_files, { desc = "Search [G]it [F]iles" }) - vim.keymap.set("n", "gs", builtin.git_status, { desc = "List [G]it [S]tatus" }) - vim.keymap.set("n", "gh", builtin.git_stash, { desc = "List [G]it [S]tash" }) - vim.keymap.set("n", "gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" }) - vim.keymap.set("n", "gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" }) - - -- File Browser Ext - -- vim.keymap.set("n", "od", - -- function() - -- telescope.extensions.file_browser.file_browser({ - -- path = "%:p:h", - -- cwd = telescope_buffer_dir(), - -- respect_gitignore = true, - -- hidden = true, - -- grouped = true, - -- previewer = false, - -- initial_mode = "normal", - -- layout_config = { height = 40 } - -- }) - -- end, { desc = "[O]pen [D]irectory" }) - - vim.keymap.set('n', '/', function() - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown({ - winblend = 10, - previewer = false, - })) - end, { desc = '[/] Fuzzily serach in current buffer' }) + local function telescope_buffer_dir() + return vim.fn.expand("%:p:h") end + + telescope.setup({ + defaults = { + mappings = { + n = { + ['q'] = actions.close + } + } + }, + extensions = { + file_browser = { + theme = "dropdown", + hijack_netrw = false, + hidden = true, + mappings = { + ['i'] = { + [''] = function() vim.cmd("normal vbd") end, + [''] = function(bufnr) actions.move_selection_next(bufnr) end, + [''] = function(bufnr) actions.move_selection_previous(bufnr) end, + [''] = function(bufnr) actions.select_vertical(bufnr) end, + }, + ['n'] = { + ['a'] = fb_actions.create, + ['h'] = fb_actions.goto_parent_dir, + ['/'] = function() vim.cmd("startinsert") end, + ['d'] = fb_actions.remove, + [''] = function(bufnr) actions.select_vertical(bufnr) end, + [''] = function(bufnr) actions.toggle_all(bufnr) end, + } + } + }, + } + }) + + pcall(telescope.load_extension, "file_browser") + pcall(telescope.load_extension, "fzf") + pcall(telescope.load_extension, "dap") + + -- Builtin pickers + vim.keymap.set("n", "sf", function() + builtin.find_files({ no_ignore = false, hidden = true }) + end, { desc = "[S]earch [F]iles" }) + vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" }) + vim.keymap.set("n", "sb", builtin.buffers, { desc = "[S]earch [B]uffers" }) + vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch [W]ord" }) + vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) + vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) + vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true }) + + -- Git pickers + vim.keymap.set("n", "gf", builtin.git_files, { desc = "Search [G]it [F]iles" }) + vim.keymap.set("n", "gs", builtin.git_status, { desc = "List [G]it [S]tatus" }) + vim.keymap.set("n", "gh", builtin.git_stash, { desc = "List [G]it [S]tash" }) + vim.keymap.set("n", "gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" }) + vim.keymap.set("n", "gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" }) + + -- File Browser Ext + vim.keymap.set("n", "fs", + function() + telescope.extensions.file_browser.file_browser({ + path = "%:p:h", + cwd = telescope_buffer_dir(), + respect_gitignore = true, + hidden = true, + grouped = true, + previewer = false, + initial_mode = "normal", + layout_config = { height = 40 } + }) + end, { desc = "Open [F]ile [S]ystem Menu" }) + + vim.keymap.set('n', '/', function() + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown({ + winblend = 10, + previewer = false, + })) + end, { desc = '[/] Fuzzily serach in current buffer' }) + end } diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index fff4f45..c2f7599 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -40,7 +40,7 @@ return { textobjects = { select = { enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim keymaps = { -- You can use the capture groups defined in textobjects.scm ['aa'] = '@parameter.outer', @@ -53,7 +53,7 @@ return { }, move = { enable = true, - set_jumps = true, -- whether to set jumps in the jumplist + set_jumps = true, -- whether to set jumps in the jumplist goto_next_start = { [']m'] = '@function.outer', [']]'] = '@class.outer',