From 3fc587b54d1e84a48f7fbdbfd51c82e4a62b7052 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Wed, 21 Jul 2021 14:33:50 +0530 Subject: [PATCH 1/3] install.sh: Use chsh instead of grep /etc/shells --- install.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index 9683ca4..ee5e2fe 100755 --- a/install.sh +++ b/install.sh @@ -21,7 +21,7 @@ _check_install_dependencies() { printf "%s\n" "Error: Install ${1} before proceeding." exit 1 } - _GIT="$(command -v git)" || _error_dependencies git + command -v git 1>/dev/null || _error_dependencies git _SED="$(command -v sed)" || _error_dependencies sed return 0 } @@ -71,26 +71,29 @@ _setup_terminal_shell() { _mappings_file="${_CONFIG_PATH}/lua/mappings.lua" # only ask for shellname if running in terminal if [ -t 1 ]; then - printf "\n%s\n" "Which shell do you want to use? (Eg. 2)" - printf "\t%s\n" "[ Enter nothing for current shell ( $_CURRENT_SHELL ) ]" - grep '^/bin/' '/etc/shells' | nl - read -r shellNUM + if chsh -l 2>/dev/null 1>&2; then + printf "\nAvailable Shells:\n" + chsh -l | nl + printf "\n%s\n" "Which shell do you want to use? (Eg. 2)" + printf "\t%s\n" "[ Enter nothing for current shell ( $_CURRENT_SHELL ) ]" + read -r shellnum + [ "${shellnum}" -gt 0 ] 2>/dev/null && _SHELLPATH="$(chsh -l | sed -n "$shellnum p")" + fi fi # don't try to do any changes user wants their default shell in nvim - if [ ! -z "$shellNUM" ]; then - shellpath=$(grep '^/bin/' '/etc/shells' | sed -n "$shellNUM p") + if [ -n "$_SHELLPATH" ]; then # Reference: https://stackoverflow.com/a/4247319 # \( & \) will use regex brackets (for later reference with \1) # ( & ) will match text brackets - if "${_SED}" --posix -i'.bak' -e "s=^\(map(.* \+*terminal\) \(.*)\)=\1$shellpath \2=g" "${_mappings_file}"; then - printf "%s\n" "=> Neovim shell changed to $shellpath successfully!" + if "${_SED}" --posix -i'.bak' -e "s=^\(map(.* \+*terminal\) \(.*)\)=\1$_SHELLPATH \2=g" "${_mappings_file}"; then + printf "%s\n" "=> Neovim shell changed to $_SHELLPATH successfully!" else - printf "%s\n" "Cannot edit with sed, edit ${_mappings_file} manually to replace bash with $shellpath." + printf "%s\n" "Cannot edit with sed, edit ${_mappings_file} manually to replace bash with $_SHELLPATH." fi rm -f "${_mappings_file}".bak # delete backup file created by sed fi - printf "%s\n\n" "=> Neovim shell will be ${shellpath:-${_CURRENT_SHELL}}" + printf "%s\n" "=> Neovim shell will be ${_SHELLPATH:-${_CURRENT_SHELL}}" return 0 } _setup_arguments() { From fcfb8145943fa374cbd7f3ed2ab2670273badd34 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Fri, 23 Jul 2021 12:14:39 +0530 Subject: [PATCH 2/3] init: Move bufferline config to pluginList.lua plugins.bufferline should be as config of nvim-bufferline and pluginList for packer --- init.lua | 1 - lua/pluginList.lua | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 13b4fe9..b3b7e50 100644 --- a/init.lua +++ b/init.lua @@ -2,7 +2,6 @@ require "options" local chad_modules = { "pluginList", - "plugins.bufferline", "mappings", "utils" } diff --git a/lua/pluginList.lua b/lua/pluginList.lua index 56f197f..0829a56 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -18,7 +18,10 @@ return packer.startup( use { "akinsho/nvim-bufferline.lua", - after = "nvim-base16.lua" + after = "nvim-base16.lua", + config = function() + require "plugins.bufferline" + end } use { From bb04ba07cb36f8ee23212e0e8e04361056313431 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Fri, 23 Jul 2021 13:22:53 +0530 Subject: [PATCH 3/3] mappings.lua: Code style fixes | Cleanup options.lua --- lua/mappings.lua | 42 +++++++++++++++++++++--------------------- lua/options.lua | 4 ---- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/lua/mappings.lua b/lua/mappings.lua index f5cb5ea..0ff8a87 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -27,15 +27,15 @@ vim.api.nvim_set_keymap("t", "jk", "", {}) map("v", "p", '"_dP', opt) -- OPEN TERMINALS -- -map("n", "", [[ vnew +terminal | setlocal nobuflisted ]], opt) -- term over right -map("n", "", [[ 10new +terminal | setlocal nobuflisted ]], opt) -- term bottom -map("n", "t", [[ terminal ]], opt) -- term buffer +map("n", "", ":vnew +terminal | setlocal nobuflisted ", opt) -- term over right +map("n", "", ":10new +terminal | setlocal nobuflisted ", opt) -- term bottom +map("n", "t", ": terminal ", opt) -- term buffer -- copy whole file content -map("n", "", [[ %y+]], opt) +map("n", "", ":%y+", opt) -- toggle numbers -map("n", "n", [[ set nu!]], opt) +map("n", "n", ":set nu!", opt) -- Truezen.nvim map("n", "zz", ":TZAtaraxis", opt) @@ -113,24 +113,24 @@ map("i", "", "v:lua.completions()", {expr = true}) map("n", "", ":NvimTreeToggle", opt) -- format code -map("n", "fm", [[ Neoformat]], opt) +map("n", "fm", ":Neoformat", opt) -- dashboard stuff -map("n", "fw", [[ Telescope live_grep]], opt) -map("n", "db", [[ Dashboard]], opt) -map("n", "fn", [[ DashboardNewFile]], opt) -map("n", "bm", [[ DashboardJumpMarks]], opt) -map("n", "l", [[ SessionLoad]], opt) -map("n", "s", [[ SessionSave]], opt) +map("n", "db", ":Dashboard", opt) +map("n", "fn", ":DashboardNewFile", opt) +map("n", "bm", ":DashboardJumpMarks", opt) +map("n", "l", ":SessionLoad", opt) +map("n", "s", ":SessionSave", opt) -- Telescope -map("n", "gt", [[ Telescope git_status ]], opt) -map("n", "cm", [[ Telescope git_commits ]], opt) -map("n", "ff", [[ Telescope find_files ]], opt) -map("n", "fp", [[lua require('telescope').extensions.media_files.media_files()]], opt) -map("n", "fb", [[Telescope buffers]], opt) -map("n", "fh", [[Telescope help_tags]], opt) -map("n", "fo", [[Telescope oldfiles]], opt) +map("n", "fw", ":Telescope live_grep", opt) +map("n", "gt", ":Telescope git_status ", opt) +map("n", "cm", ":Telescope git_commits ", opt) +map("n", "ff", ":Telescope find_files ", opt) +map("n", "fp", ":lua require('telescope').extensions.media_files.media_files()", opt) +map("n", "fb", ":Telescope buffers", opt) +map("n", "fh", ":Telescope help_tags", opt) +map("n", "fo", ":Telescope oldfiles", opt) -- bufferline tab stuff map("n", "", ":enew", opt) -- new buffer @@ -138,8 +138,8 @@ map("n", "b", ":tabnew", opt) -- new tab map("n", "", ":bd!", opt) -- close tab -- move between tabs -map("n", "", [[BufferLineCycleNext]], opt) -map("n", "", [[BufferLineCyclePrev]], opt) +map("n", "", ":BufferLineCycleNext", opt) +map("n", "", ":BufferLineCyclePrev", opt) -- use ESC to turn off search highlighting map("n", "", ":noh", opt) diff --git a/lua/options.lua b/lua/options.lua index 704a4e8..cb62d38 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -71,9 +71,5 @@ for _, plugin in pairs(disabled_built_ins) do vim.g["loaded_" .. plugin] = 1 end -local M = {} - -- file extension specific tabbing -- vim.cmd([[autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4]]) - -return M