Merge pull request #178 from Akianonymus/main
install.sh: Use chsh instead of grep /etc/shells | init: Move bufferline config to pluginList | Misc improvements
This commit is contained in:
commit
e01aafeea5
5 changed files with 39 additions and 38 deletions
1
init.lua
1
init.lua
|
@ -2,7 +2,6 @@ require "options"
|
|||
|
||||
local chad_modules = {
|
||||
"pluginList",
|
||||
"plugins.bufferline",
|
||||
"mappings",
|
||||
"utils"
|
||||
}
|
||||
|
|
25
install.sh
25
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() {
|
||||
|
|
|
@ -27,15 +27,15 @@ vim.api.nvim_set_keymap("t", "jk", "<esc>", {})
|
|||
map("v", "p", '"_dP', opt)
|
||||
|
||||
-- OPEN TERMINALS --
|
||||
map("n", "<C-l>", [[<Cmd> vnew +terminal | setlocal nobuflisted <CR>]], opt) -- term over right
|
||||
map("n", "<C-x>", [[<Cmd> 10new +terminal | setlocal nobuflisted <CR>]], opt) -- term bottom
|
||||
map("n", "<C-t>t", [[<Cmd> terminal <CR>]], opt) -- term buffer
|
||||
map("n", "<C-l>", ":vnew +terminal | setlocal nobuflisted <CR>", opt) -- term over right
|
||||
map("n", "<C-x>", ":10new +terminal | setlocal nobuflisted <CR>", opt) -- term bottom
|
||||
map("n", "<C-t>t", ":<Cmd> terminal <CR>", opt) -- term buffer
|
||||
|
||||
-- copy whole file content
|
||||
map("n", "<C-a>", [[ <Cmd> %y+<CR>]], opt)
|
||||
map("n", "<C-a>", ":%y+<CR>", opt)
|
||||
|
||||
-- toggle numbers
|
||||
map("n", "<leader>n", [[ <Cmd> set nu!<CR>]], opt)
|
||||
map("n", "<leader>n", ":set nu!<CR>", opt)
|
||||
|
||||
-- Truezen.nvim
|
||||
map("n", "<leader>zz", ":TZAtaraxis<CR>", opt)
|
||||
|
@ -113,24 +113,24 @@ map("i", "<CR>", "v:lua.completions()", {expr = true})
|
|||
map("n", "<C-n>", ":NvimTreeToggle<CR>", opt)
|
||||
|
||||
-- format code
|
||||
map("n", "<Leader>fm", [[<Cmd> Neoformat<CR>]], opt)
|
||||
map("n", "<Leader>fm", ":Neoformat<CR>", opt)
|
||||
|
||||
-- dashboard stuff
|
||||
map("n", "<Leader>fw", [[<Cmd> Telescope live_grep<CR>]], opt)
|
||||
map("n", "<Leader>db", [[<Cmd> Dashboard<CR>]], opt)
|
||||
map("n", "<Leader>fn", [[<Cmd> DashboardNewFile<CR>]], opt)
|
||||
map("n", "<Leader>bm", [[<Cmd> DashboardJumpMarks<CR>]], opt)
|
||||
map("n", "<C-s>l", [[<Cmd> SessionLoad<CR>]], opt)
|
||||
map("n", "<C-s>s", [[<Cmd> SessionSave<CR>]], opt)
|
||||
map("n", "<Leader>db", ":Dashboard<CR>", opt)
|
||||
map("n", "<Leader>fn", ":DashboardNewFile<CR>", opt)
|
||||
map("n", "<Leader>bm", ":DashboardJumpMarks<CR>", opt)
|
||||
map("n", "<C-s>l", ":SessionLoad<CR>", opt)
|
||||
map("n", "<C-s>s", ":SessionSave<CR>", opt)
|
||||
|
||||
-- Telescope
|
||||
map("n", "<Leader>gt", [[<Cmd> Telescope git_status <CR>]], opt)
|
||||
map("n", "<Leader>cm", [[<Cmd> Telescope git_commits <CR>]], opt)
|
||||
map("n", "<Leader>ff", [[<Cmd> Telescope find_files <CR>]], opt)
|
||||
map("n", "<Leader>fp", [[<Cmd>lua require('telescope').extensions.media_files.media_files()<CR>]], opt)
|
||||
map("n", "<Leader>fb", [[<Cmd>Telescope buffers<CR>]], opt)
|
||||
map("n", "<Leader>fh", [[<Cmd>Telescope help_tags<CR>]], opt)
|
||||
map("n", "<Leader>fo", [[<Cmd>Telescope oldfiles<CR>]], opt)
|
||||
map("n", "<Leader>fw", ":Telescope live_grep<CR>", opt)
|
||||
map("n", "<Leader>gt", ":Telescope git_status <CR>", opt)
|
||||
map("n", "<Leader>cm", ":Telescope git_commits <CR>", opt)
|
||||
map("n", "<Leader>ff", ":Telescope find_files <CR>", opt)
|
||||
map("n", "<Leader>fp", ":lua require('telescope').extensions.media_files.media_files()<CR>", opt)
|
||||
map("n", "<Leader>fb", ":Telescope buffers<CR>", opt)
|
||||
map("n", "<Leader>fh", ":Telescope help_tags<CR>", opt)
|
||||
map("n", "<Leader>fo", ":Telescope oldfiles<CR>", opt)
|
||||
|
||||
-- bufferline tab stuff
|
||||
map("n", "<S-t>", ":enew<CR>", opt) -- new buffer
|
||||
|
@ -138,8 +138,8 @@ map("n", "<C-t>b", ":tabnew<CR>", opt) -- new tab
|
|||
map("n", "<S-x>", ":bd!<CR>", opt) -- close tab
|
||||
|
||||
-- move between tabs
|
||||
map("n", "<TAB>", [[<Cmd>BufferLineCycleNext<CR>]], opt)
|
||||
map("n", "<S-TAB>", [[<Cmd>BufferLineCyclePrev<CR>]], opt)
|
||||
map("n", "<TAB>", ":BufferLineCycleNext<CR>", opt)
|
||||
map("n", "<S-TAB>", ":BufferLineCyclePrev<CR>", opt)
|
||||
|
||||
-- use ESC to turn off search highlighting
|
||||
map("n", "<Esc>", ":noh<CR>", opt)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue