Update neovim configs

Signed-off-by: The-Repo-Club <wayne6324@gmail.com>
This commit is contained in:
The-Repo-Club 2022-08-16 17:45:51 +01:00
parent 25a8fe783e
commit 37908c0944
No known key found for this signature in database
GPG Key ID: E30EC2FBFB05C44F
15 changed files with 662 additions and 632 deletions

View File

@ -1,12 +1,13 @@
local alpha = require("alpha")
-- General Settings auto commands -- General Settings auto commands
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("_general_settings", { clear = true }), group = vim.api.nvim_create_augroup("_general_settings_filetype", { clear = true }),
pattern = { "qf", "help", "man", "lspinfo" }, pattern = { "qf", "help", "man", "lspinfo", "lazygit" },
command = "nnoremap <silent> <buffer> q :close<CR>", command = "nnoremap <silent> <buffer> q :close<CR>",
}) })
vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd("TextYankPost", {
group = vim.api.nvim_create_augroup("_general_settings", { clear = true }), group = vim.api.nvim_create_augroup("_general_settings_yank_text", { clear = true }),
pattern = "*", pattern = "*",
callback = function() callback = function()
require("vim.highlight").on_yank({ higroup = "Visual", timeout = 200 }) require("vim.highlight").on_yank({ higroup = "Visual", timeout = 200 })
@ -14,13 +15,13 @@ vim.api.nvim_create_autocmd("TextYankPost", {
}) })
vim.api.nvim_create_autocmd("BufWinEnter", { vim.api.nvim_create_autocmd("BufWinEnter", {
group = vim.api.nvim_create_augroup("_general_settings", { clear = true }), group = vim.api.nvim_create_augroup("_general_settings_buffer_enter", { clear = true }),
pattern = "*", pattern = "*",
command = "set formatoptions-=cro", command = "set formatoptions-=cro",
}) })
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("_general_settings", { clear = true }), group = vim.api.nvim_create_augroup("_general_settings_filetype", { clear = true }),
pattern = "qf", pattern = "qf",
command = "set nobuflisted", command = "set nobuflisted",
}) })
@ -48,15 +49,23 @@ vim.api.nvim_create_autocmd("VimResized", {
-- Alpha dashboard auto commands -- Alpha dashboard auto commands
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
group = vim.api.nvim_create_augroup("_alpha", { clear = true }), group = vim.api.nvim_create_augroup("_alpha_user", { clear = true }),
pattern = "AlphaReady", pattern = "AlphaReady",
command = "<buffer> set laststatus=0 | <buffer> set showtabline=0 | <buffer> set mouse=a", command = "set laststatus=0 | set showtabline=0 | set mouse=",
}) })
vim.api.nvim_create_autocmd("BufUnload", { vim.api.nvim_create_autocmd("BufUnload", {
group = vim.api.nvim_create_augroup("_alpha", { clear = true }), group = vim.api.nvim_create_augroup("_alpha_buffer", { clear = true }),
pattern = "AlphaReady", pattern = "*",
command = "<buffer> set laststatus=2 | <buffer> set showtabline=2 | <buffer> set mouse=a", command = "set laststatus=2 | set showtabline=2 | set mouse=a",
})
vim.api.nvim_create_autocmd("TabNewEntered", {
group = vim.api.nvim_create_augroup("_alpha_newtab", { clear = true }),
pattern = "*",
callback = function()
alpha.start()
end,
}) })
-- LSP auto commands -- LSP auto commands

View File

@ -4,7 +4,7 @@ if not status_ok then
return return
end end
npairs.setup { npairs.setup({
check_ts = true, check_ts = true,
ts_config = { ts_config = {
lua = { "string", "source" }, lua = { "string", "source" },
@ -23,11 +23,11 @@ npairs.setup {
highlight = "PmenuSel", highlight = "PmenuSel",
highlight_grey = "LineNr", highlight_grey = "LineNr",
}, },
} })
local cmp_autopairs = require "nvim-autopairs.completion.cmp" local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp_status_ok, cmp = pcall(require, "cmp") local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then if not cmp_status_ok then
return return
end end
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))

View File

@ -11,8 +11,8 @@ end
require("luasnip/loaders/from_vscode").lazy_load() require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function() local check_backspace = function()
local col = vim.fn.col "." - 1 local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
end end
--   פּ ﯟ   some other good icons --   פּ ﯟ   some other good icons
@ -45,7 +45,7 @@ local kind_icons = {
} }
-- find more here: https://www.nerdfonts.com/cheat-sheet -- find more here: https://www.nerdfonts.com/cheat-sheet
cmp.setup { cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users. luasnip.lsp_expand(args.body) -- For `luasnip` users.
@ -58,13 +58,13 @@ cmp.setup {
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), ["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping. ["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = cmp.mapping { ["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(), i = cmp.mapping.abort(),
c = cmp.mapping.close(), c = cmp.mapping.close(),
}, }),
-- Accept currently selected item. If none selected, `select` first item. -- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items. -- Set `select` to `false` to only confirm explicitly selected items.
["<CR>"] = cmp.mapping.confirm { select = true }, ["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
@ -128,16 +128,16 @@ cmp.setup {
ghost_text = false, ghost_text = false,
native_menu = false, native_menu = false,
}, },
}
cmp.setup.cmdline(':', {
sources = {
{ name = 'cmdline' }
}
}) })
cmp.setup.cmdline('/', { cmp.setup.cmdline(":", {
sources = { sources = {
{ name = 'buffer' } { name = "cmdline" },
} },
})
cmp.setup.cmdline("/", {
sources = {
{ name = "buffer" },
},
}) })

View File

@ -1,8 +1,8 @@
vim.cmd [[ vim.cmd([[
try try
colorscheme minimalmistakes colorscheme minimalmistakes
catch /^Vim\%((\a\+)\)\=:E185/ catch /^Vim\%((\a\+)\)\=:E185/
colorscheme default colorscheme default
set background=dark set background=dark
endtry endtry
]] ]])

View File

@ -3,9 +3,9 @@ if not status_ok then
return return
end end
comment.setup { comment.setup({
pre_hook = function(ctx) pre_hook = function(ctx)
local U = require "Comment.utils" local U = require("Comment.utils")
local location = nil local location = nil
if ctx.ctype == U.ctype.block then if ctx.ctype == U.ctype.block then
@ -14,9 +14,9 @@ comment.setup {
location = require("ts_context_commentstring.utils").get_visual_start_location() location = require("ts_context_commentstring.utils").get_visual_start_location()
end end
return require("ts_context_commentstring.internal").calculate_commentstring { return require("ts_context_commentstring.internal").calculate_commentstring({
key = ctx.ctype == U.ctype.line and "__default" or "__multiline", key = ctx.ctype == U.ctype.line and "__default" or "__multiline",
location = location, location = location,
} })
end, end,
} })

View File

@ -3,7 +3,7 @@ if not status_ok then
return return
end end
gitsigns.setup { gitsigns.setup({
signs = { signs = {
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
change = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, change = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
@ -45,4 +45,4 @@ gitsigns.setup {
yadm = { yadm = {
enable = false, enable = false,
}, },
} })

View File

@ -66,4 +66,3 @@ keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts)
keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts) keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts)
keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts) keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts)
keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts) keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)

View File

@ -1,7 +1,11 @@
local status_ok, lualine = pcall(require, "lualine") local status_ok, lualine = pcall(require, "lualine")
if not status_ok then return end if not status_ok then
return
end
local hide_in_width = function() return vim.fn.winwidth(0) > 80 end local hide_in_width = function()
return vim.fn.winwidth(0) > 80
end
local diagnostics = { local diagnostics = {
"diagnostics", "diagnostics",
@ -10,17 +14,22 @@ local diagnostics = {
symbols = { error = "", warn = "" }, symbols = { error = "", warn = "" },
colored = false, colored = false,
update_in_insert = false, update_in_insert = false,
always_visible = true always_visible = true,
} }
local diff = { local diff = {
"diff", "diff",
colored = false, colored = false,
symbols = { added = "", modified = "", removed = "" }, -- changes diff symbols symbols = { added = "", modified = "", removed = "" }, -- changes diff symbols
cond = hide_in_width cond = hide_in_width,
} }
local mode = {"mode", fmt = function(str) return "-- " .. str .. " --" end} local mode = {
"mode",
fmt = function(str)
return "-- " .. str .. " --"
end,
}
local filetype = { "filetype", icons_enabled = false, icon = nil } local filetype = { "filetype", icons_enabled = false, icon = nil }
@ -33,8 +42,15 @@ local progress = function()
local current_line = vim.fn.line(".") local current_line = vim.fn.line(".")
local total_lines = vim.fn.line("$") local total_lines = vim.fn.line("$")
local chars = { local chars = {
"__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "__",
"▇▇", "██" "▁▁",
"▂▂",
"▃▃",
"▄▄",
"▅▅",
"▆▆",
"▇▇",
"██",
} }
local line_ratio = current_line / total_lines local line_ratio = current_line / total_lines
local index = math.ceil(line_ratio * #chars) local index = math.ceil(line_ratio * #chars)
@ -52,9 +68,13 @@ lualine.setup({
component_separators = { left = "", right = "" }, component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" }, section_separators = { left = "", right = "" },
disabled_filetypes = { disabled_filetypes = {
"alpha", "dashboard", "NvimTree", "Outline", "packer" "alpha",
"dashboard",
"NvimTree",
"Outline",
"packer",
}, },
always_divide_middle = true always_divide_middle = true,
}, },
sections = { sections = {
lualine_a = { branch, diagnostics }, lualine_a = { branch, diagnostics },
@ -63,7 +83,7 @@ lualine.setup({
-- lualine_x = { "encoding", "fileformat", "filetype" }, -- lualine_x = { "encoding", "fileformat", "filetype" },
lualine_x = { diff, spaces, "encoding", filetype }, lualine_x = { diff, spaces, "encoding", filetype },
lualine_y = { location }, lualine_y = { location },
lualine_z = {progress} lualine_z = { progress },
}, },
inactive_sections = { inactive_sections = {
lualine_a = {}, lualine_a = {},
@ -71,8 +91,8 @@ lualine.setup({
lualine_c = { "filename" }, lualine_c = { "filename" },
lualine_x = { "location" }, lualine_x = { "location" },
lualine_y = {}, lualine_y = {},
lualine_z = {} lualine_z = {},
}, },
tabline = {}, tabline = {},
extensions = {"nvim-tree"} extensions = { "nvim-tree" },
}) })

View File

@ -10,7 +10,7 @@ end
local tree_cb = nvim_tree_config.nvim_tree_callback local tree_cb = nvim_tree_config.nvim_tree_callback
nvim_tree.setup { nvim_tree.setup({
update_focused_file = { update_focused_file = {
enable = true, enable = true,
update_cwd = true, update_cwd = true,
@ -59,10 +59,10 @@ nvim_tree.setup {
side = "left", side = "left",
mappings = { mappings = {
list = { list = {
{ key = { "l", "<CR>", "o" }, cb = tree_cb "edit" }, { key = { "l", "<CR>", "o" }, cb = tree_cb("edit") },
{ key = "h", cb = tree_cb "close_node" }, { key = "h", cb = tree_cb("close_node") },
{ key = "v", cb = tree_cb "vsplit" }, { key = "v", cb = tree_cb("vsplit") },
}, },
}, },
}, },
} })

View File

@ -34,15 +34,17 @@ local options = {
scrolloff = 8, -- is one of my fav scrolloff = 8, -- is one of my fav
sidescrolloff = 8, sidescrolloff = 8,
laststatus = 2, laststatus = 2,
guifont = "monospace:h17" -- the font used in graphical neovim applications guifont = "monospace:h17", -- the font used in graphical neovim applications
} }
vim.opt.shortmess:append "c" vim.opt.shortmess:append("c")
vim.opt.listchars:append "space:⋅" vim.opt.listchars:append("space:⋅")
vim.opt.listchars:append "eol:↴" vim.opt.listchars:append("eol:↴")
for k, v in pairs(options) do vim.opt[k] = v end for k, v in pairs(options) do
vim.opt[k] = v
end
vim.cmd "set whichwrap+=<,>,[,],h,l" vim.cmd("set whichwrap+=<,>,[,],h,l")
vim.cmd [[set iskeyword+=-]] vim.cmd([[set iskeyword+=-]])
vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work

View File

@ -45,4 +45,4 @@ if not tele_status_ok then
return return
end end
telescope.load_extension('projects') telescope.load_extension("projects")

View File

@ -3,9 +3,9 @@ if not status_ok then
return return
end end
local actions = require "telescope.actions" local actions = require("telescope.actions")
telescope.setup { telescope.setup({
defaults = { defaults = {
prompt_prefix = "", prompt_prefix = "",
@ -93,4 +93,4 @@ telescope.setup {
-- } -- }
-- please take a look at the readme of the extension you want to configure -- please take a look at the readme of the extension you want to configure
}, },
} })

View File

@ -28,15 +28,15 @@ toggleterm.setup({
function _G.set_terminal_keymaps() function _G.set_terminal_keymaps()
local opts = { noremap = true } local opts = { noremap = true }
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts) vim.api.nvim_buf_set_keymap(0, "t", "<esc>", [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts) vim.api.nvim_buf_set_keymap(0, "t", "jk", [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts) vim.api.nvim_buf_set_keymap(0, "t", "<C-h>", [[<C-\><C-n><C-W>h]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts) vim.api.nvim_buf_set_keymap(0, "t", "<C-j>", [[<C-\><C-n><C-W>j]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts) vim.api.nvim_buf_set_keymap(0, "t", "<C-k>", [[<C-\><C-n><C-W>k]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts) vim.api.nvim_buf_set_keymap(0, "t", "<C-l>", [[<C-\><C-n><C-W>l]], opts)
end end
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
local Terminal = require("toggleterm.terminal").Terminal local Terminal = require("toggleterm.terminal").Terminal
local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) local lazygit = Terminal:new({ cmd = "lazygit", hidden = true })

View File

@ -79,7 +79,7 @@ local opts = {
} }
local mappings = { local mappings = {
["a"] = { "<cmd>Alpha<cr>", "Alpha" }, ["a"] = { "<cmd>lua require('alpha').start()<cr>", "Alpha" },
["b"] = { ["b"] = {
"<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})<cr>", "<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})<cr>",
"Buffers", "Buffers",