Merge branch 'main' into patch-1

This commit is contained in:
vlad doster 2021-07-27 16:30:24 -05:00 committed by GitHub
commit e197049a59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 134 additions and 86 deletions

View File

@ -1,26 +1,9 @@
require "options"
local chad_modules = { local chad_modules = {
"pluginList", "options",
"plugins.bufferline",
"mappings", "mappings",
"utils" "utils"
} }
local async
async =
vim.loop.new_async(
vim.schedule_wrap(
function()
for i = 1, #chad_modules, 1 do for i = 1, #chad_modules, 1 do
local ok, res = xpcall(require, debug.traceback, chad_modules[i]) pcall(require, chad_modules[i])
if not (ok) then
print("Error loading module : " .. chad_modules[i])
print(res) -- print stack traceback of the error
end end
end
async:close()
end
)
)
async:send()

View File

@ -21,7 +21,7 @@ _check_install_dependencies() {
printf "%s\n" "Error: Install ${1} before proceeding." printf "%s\n" "Error: Install ${1} before proceeding."
exit 1 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 _SED="$(command -v sed)" || _error_dependencies sed
return 0 return 0
} }
@ -71,26 +71,29 @@ _setup_terminal_shell() {
_mappings_file="${_CONFIG_PATH}/lua/mappings.lua" _mappings_file="${_CONFIG_PATH}/lua/mappings.lua"
# only ask for shellname if running in terminal # only ask for shellname if running in terminal
if [ -t 1 ]; then if [ -t 1 ]; then
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 "\n%s\n" "Which shell do you want to use? (Eg. 2)"
printf "\t%s\n" "[ Enter nothing for current shell ( $_CURRENT_SHELL ) ]" printf "\t%s\n" "[ Enter nothing for current shell ( $_CURRENT_SHELL ) ]"
grep '^/bin/' '/etc/shells' | nl read -r shellnum
read -r shellNUM [ "${shellnum}" -gt 0 ] 2>/dev/null && _SHELLPATH="$(chsh -l | sed -n "$shellnum p")"
fi
fi fi
# don't try to do any changes user wants their default shell in nvim # don't try to do any changes user wants their default shell in nvim
if [ -n "$shellNUM" ]; then if [ -n "$_SHELLPATH" ]; then
shellpath=$(grep '^/bin/' '/etc/shells' | sed -n "$shellNUM p")
# Reference: https://stackoverflow.com/a/4247319 # Reference: https://stackoverflow.com/a/4247319
# \( & \) will use regex brackets (for later reference with \1) # \( & \) will use regex brackets (for later reference with \1)
# ( & ) will match text brackets # ( & ) will match text brackets
if "${_SED}" --posix -i'.bak' -e "s=^\(map(.* \+*terminal\) \(.*)\)=\1$shellpath \2=g" "${_mappings_file}"; then 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!" printf "%s\n" "=> Neovim shell changed to $_SHELLPATH successfully!"
else 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 fi
rm -f "${_mappings_file}".bak # delete backup file created by sed rm -f "${_mappings_file}".bak # delete backup file created by sed
fi fi
printf "%s\n\n" "=> Neovim shell will be ${shellpath:-${_CURRENT_SHELL}}" printf "%s\n" "=> Neovim shell will be ${_SHELLPATH:-${_CURRENT_SHELL}}"
return 0 return 0
} }
_setup_arguments() { _setup_arguments() {

View File

@ -115,6 +115,5 @@ bg("NormalFloat", black2)
bg("FloatBorder", black2) bg("FloatBorder", black2)
fg("FloatBorder", black2) fg("FloatBorder", black2)
-- set bg color for nvim ( so nvim wont use terminal bg) -- set bg color for nvim
-- bg("Normal", black)
bg("Normal", black)

View File

@ -18,24 +18,27 @@ map("v", "x", [=[ "_x ]=], opt)
this line too ]] this line too ]]
-- --
-- escape with 'jk' mapping
vim.api.nvim_set_keymap("i", "jk", "<esc>", {})
vim.api.nvim_set_keymap("v", "jk", "<esc>", {})
vim.api.nvim_set_keymap("t", "jk", "<esc>", {})
-- Don't copy the replaced text after pasting in visual mode -- Don't copy the replaced text after pasting in visual mode
map("v", "p", '"_dP', opt) map("v", "p", '"_dP', opt)
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
-- empty mode is same as using :map
map("", "j", 'v:count ? "j" : "gj"', {expr = true})
map("", "k", 'v:count ? "k" : "gk"', {expr = true})
map("", "<Down>", 'v:count ? "j" : "gj"', {expr = true})
map("", "<Up>", 'v:count ? "k" : "gk"', {expr = true})
-- OPEN TERMINALS -- -- OPEN TERMINALS --
map("n", "<C-l>", [[<Cmd> vnew +terminal | setlocal nobuflisted <CR>]], opt) -- term over right map("n", "<C-l>", ":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-x>", ":10new +terminal | setlocal nobuflisted <CR>", opt) -- term bottom
map("n", "<C-t>t", [[<Cmd> terminal <CR>]], opt) -- term buffer map("n", "<C-t>t", ":<Cmd> terminal <CR>", opt) -- term buffer
-- copy whole file content -- copy whole file content
map("n", "<C-a>", [[ <Cmd> %y+<CR>]], opt) map("n", "<C-a>", ":%y+<CR>", opt)
-- toggle numbers -- toggle numbers
map("n", "<leader>n", [[ <Cmd> set nu!<CR>]], opt) map("n", "<leader>n", ":set nu!<CR>", opt)
-- Truezen.nvim -- Truezen.nvim
map("n", "<leader>zz", ":TZAtaraxis<CR>", opt) map("n", "<leader>zz", ":TZAtaraxis<CR>", opt)
@ -113,24 +116,24 @@ map("i", "<CR>", "v:lua.completions()", {expr = true})
map("n", "<C-n>", ":NvimTreeToggle<CR>", opt) map("n", "<C-n>", ":NvimTreeToggle<CR>", opt)
-- format code -- format code
map("n", "<Leader>fm", [[<Cmd> Neoformat<CR>]], opt) map("n", "<Leader>fm", ":Neoformat<CR>", opt)
-- dashboard stuff -- dashboard stuff
map("n", "<Leader>fw", [[<Cmd> Telescope live_grep<CR>]], opt) map("n", "<Leader>db", ":Dashboard<CR>", opt)
map("n", "<Leader>db", [[<Cmd> Dashboard<CR>]], opt) map("n", "<Leader>fn", ":DashboardNewFile<CR>", opt)
map("n", "<Leader>fn", [[<Cmd> DashboardNewFile<CR>]], opt) map("n", "<Leader>bm", ":DashboardJumpMarks<CR>", opt)
map("n", "<Leader>bm", [[<Cmd> DashboardJumpMarks<CR>]], opt) map("n", "<C-s>l", ":SessionLoad<CR>", opt)
map("n", "<C-s>l", [[<Cmd> SessionLoad<CR>]], opt) map("n", "<C-s>s", ":SessionSave<CR>", opt)
map("n", "<C-s>s", [[<Cmd> SessionSave<CR>]], opt)
-- Telescope -- Telescope
map("n", "<Leader>gt", [[<Cmd> Telescope git_status <CR>]], opt) map("n", "<Leader>fw", ":Telescope live_grep<CR>", opt)
map("n", "<Leader>cm", [[<Cmd> Telescope git_commits <CR>]], opt) map("n", "<Leader>gt", ":Telescope git_status <CR>", opt)
map("n", "<Leader>ff", [[<Cmd> Telescope find_files <CR>]], opt) map("n", "<Leader>cm", ":Telescope git_commits <CR>", opt)
map("n", "<Leader>fp", [[<Cmd>lua require('telescope').extensions.media_files.media_files()<CR>]], opt) map("n", "<Leader>ff", ":Telescope find_files <CR>", opt)
map("n", "<Leader>fb", [[<Cmd>Telescope buffers<CR>]], opt) map("n", "<Leader>fp", ":Telescope media_files <CR>", opt)
map("n", "<Leader>fh", [[<Cmd>Telescope help_tags<CR>]], opt) map("n", "<Leader>fb", ":Telescope buffers<CR>", opt)
map("n", "<Leader>fo", [[<Cmd>Telescope oldfiles<CR>]], opt) map("n", "<Leader>fh", ":Telescope help_tags<CR>", opt)
map("n", "<Leader>fo", ":Telescope oldfiles<CR>", opt)
-- bufferline tab stuff -- bufferline tab stuff
map("n", "<S-t>", ":enew<CR>", opt) -- new buffer map("n", "<S-t>", ":enew<CR>", opt) -- new buffer
@ -138,11 +141,24 @@ map("n", "<C-t>b", ":tabnew<CR>", opt) -- new tab
map("n", "<S-x>", ":bd!<CR>", opt) -- close tab map("n", "<S-x>", ":bd!<CR>", opt) -- close tab
-- move between tabs -- move between tabs
map("n", "<TAB>", [[<Cmd>BufferLineCycleNext<CR>]], opt) map("n", "<TAB>", ":BufferLineCycleNext<CR>", opt)
map("n", "<S-TAB>", [[<Cmd>BufferLineCyclePrev<CR>]], opt) map("n", "<S-TAB>", ":BufferLineCyclePrev<CR>", opt)
-- use ESC to turn off search highlighting -- use ESC to turn off search highlighting
map("n", "<Esc>", ":noh<CR>", opt) map("n", "<Esc>", ":noh<CR>", opt)
-- get out of terminal with jk -- get out of terminal with jk
map("t", "jk", "<C-\\><C-n>", opt) map("t", "jk", "<C-\\><C-n>", opt)
-- Packer commands till because we are not loading it at startup
vim.cmd("silent! command PackerCompile lua require 'pluginList' require('packer').compile()")
vim.cmd("silent! command PackerInstall lua require 'pluginList' require('packer').install()")
vim.cmd("silent! command PackerStatus lua require 'pluginList' require('packer').status()")
vim.cmd("silent! command PackerSync lua require 'pluginList' require('packer').sync()")
vim.cmd("silent! command PackerUpdate lua require 'pluginList' require('packer').update()")
-- Vim Fugitive
map("n", "<Leader>gs", ":Git<CR>", opt)
map("n", "<Leader>gh", ":diffget //2<CR>", opt)
map("n", "<Leader>gl", ":diffget //3<CR>", opt)
map("n", "<Leader>gb", ":Git blame<CR>", opt)

View File

@ -1,13 +1,6 @@
local opt = vim.opt local opt = vim.opt
local g = vim.g local g = vim.g
-- Turn these off at startup, will be enabled later just before loading the theme
vim.cmd([[
syntax off
filetype off
filetype plugin indent off
]])
opt.ruler = false opt.ruler = false
opt.hidden = true opt.hidden = true
opt.ignorecase = true opt.ignorecase = true
@ -71,9 +64,5 @@ for _, plugin in pairs(disabled_built_ins) do
vim.g["loaded_" .. plugin] = 1 vim.g["loaded_" .. plugin] = 1
end end
local M = {}
-- file extension specific tabbing -- file extension specific tabbing
-- vim.cmd([[autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4]]) -- vim.cmd([[autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4]])
return M

View File

@ -16,9 +16,20 @@ return packer.startup(
event = "VimEnter" event = "VimEnter"
} }
use {
"jdhao/better-escape.vim",
event = "InsertEnter",
config = function()
require "plugins.others".escape()
end
}
use { use {
"akinsho/nvim-bufferline.lua", "akinsho/nvim-bufferline.lua",
after = "nvim-base16.lua" after = "nvim-base16.lua",
config = function()
require "plugins.bufferline"
end
} }
use { use {
@ -195,7 +206,7 @@ return packer.startup(
} }
use { use {
"tweekmonster/startuptime.vim", "dstein64/vim-startuptime",
cmd = "StartupTime" cmd = "StartupTime"
} }
@ -240,5 +251,12 @@ return packer.startup(
require("plugins.others").blankline() require("plugins.others").blankline()
end end
} }
use {
"tpope/vim-fugitive",
cmd = {
"Git"
}
}
end end
) )

View File

@ -104,12 +104,14 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.diagnostic.on_publish_diagnostics, vim.lsp.diagnostic.on_publish_diagnostics,
{ {
virtual_text = { virtual_text = {
-- prefix = "",
prefix = "", prefix = "",
spacing = 0 spacing = 0
}, },
signs = true, signs = true,
underline = true underline = true,
-- set this to true if you want diagnostics to show in insert mode
update_in_insert = false
} }
) )

View File

@ -15,6 +15,11 @@ M.comment = function()
end end
end end
M.escape = function()
vim.g.better_escape_interval = 300
vim.g.better_escape_shortcut = {"jk"}
end
M.lspkind = function() M.lspkind = function()
local present, lspkind = pcall(require, "lspkind") local present, lspkind = pcall(require, "lspkind")
if present then if present then

View File

@ -117,7 +117,14 @@ gls.right[1] = {
provider = function() provider = function()
local clients = vim.lsp.get_active_clients() local clients = vim.lsp.get_active_clients()
if next(clients) ~= nil then if next(clients) ~= nil then
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return " " .. "" .. " LSP " return " " .. "" .. " LSP "
end
end
return ""
else else
return "" return ""
end end

View File

@ -79,5 +79,6 @@ if
print("After completion of PackerSync, restart neovim.") print("After completion of PackerSync, restart neovim.")
-- Trigger packer compile on PackerComplete, so it properly waits for PackerSync -- Trigger packer compile on PackerComplete, so it properly waits for PackerSync
vim.cmd 'autocmd User PackerComplete ++once lua require("packer").compile()' vim.cmd 'autocmd User PackerComplete ++once lua require("packer").compile()'
require "pluginList"
require("packer").sync("telescope-fzf-native.nvim", "telescope-media-files.nvim") require("packer").sync("telescope-fzf-native.nvim", "telescope-media-files.nvim")
end end

View File

@ -3,13 +3,6 @@ vim.g.nvchad_theme = "onedark"
local present, base16 = pcall(require, "base16") local present, base16 = pcall(require, "base16")
if present then if present then
-- enabled these options, was disabled in options.lua
vim.cmd([[
syntax on
filetype on
filetype plugin indent on
]])
base16(base16.themes["onedark"], true) base16(base16.themes["onedark"], true)
require "highlights" require "highlights"
return true return true

33
lua/themes/javacafe.lua Normal file
View File

@ -0,0 +1,33 @@
local colors = {
white = "#b5bcc9",
darker_black = "#10171e",
black = "#131a21", -- nvim bg
black2 = "#1a2128",
one_bg = "#1e252c",
one_bg2 = "#272e35",
one_bg3 = "#2a3138",
grey = "#363d44",
grey_fg = "#4e555c",
grey_fg2 = "#51585f",
light_grey = "#545b62",
red = "#ef8891",
baby_pink = "#fca2aa",
pink = "#fca2af",
line = "#20272e", -- for lines like vertsplit
green = "#9ce5c0",
vibrant_green = "#a5d4af",
blue = "#99aee5",
nord_blue = "#9aa8cf",
yellow = "#fbdf90",
sun = "#fbdf9a",
purple = "#d7c1ed",
dark_purple = "#ccaced",
teal = "#92dbb6",
orange = "#EDA685",
cyan = "#b5c3ea",
statusline_bg = "#181f26",
lightbg = "#222930",
lightbg2 = "#1d242b"
}
return colors

View File

@ -2,7 +2,6 @@
vim.api.nvim_exec( vim.api.nvim_exec(
[[ [[
au TermOpen term://* setlocal nonumber laststatus=0 au TermOpen term://* setlocal nonumber laststatus=0
au TermClose term://* bd!
au BufEnter,BufWinEnter,WinEnter,CmdwinEnter * if bufname('%') == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif au BufEnter,BufWinEnter,WinEnter,CmdwinEnter * if bufname('%') == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif
]], ]],
false false