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
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("_general_settings", { clear = true }),
pattern = { "qf", "help", "man", "lspinfo" },
group = vim.api.nvim_create_augroup("_general_settings_filetype", { clear = true }),
pattern = { "qf", "help", "man", "lspinfo", "lazygit" },
command = "nnoremap <silent> <buffer> q :close<CR>",
})
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 = "*",
callback = function()
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", {
group = vim.api.nvim_create_augroup("_general_settings", { clear = true }),
group = vim.api.nvim_create_augroup("_general_settings_buffer_enter", { clear = true }),
pattern = "*",
command = "set formatoptions-=cro",
})
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",
command = "set nobuflisted",
})
@ -48,15 +49,23 @@ vim.api.nvim_create_autocmd("VimResized", {
-- Alpha dashboard auto commands
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",
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", {
group = vim.api.nvim_create_augroup("_alpha", { clear = true }),
pattern = "AlphaReady",
command = "<buffer> set laststatus=2 | <buffer> set showtabline=2 | <buffer> set mouse=a",
group = vim.api.nvim_create_augroup("_alpha_buffer", { clear = true }),
pattern = "*",
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

View File

@ -4,7 +4,7 @@ if not status_ok then
return
end
npairs.setup {
npairs.setup({
check_ts = true,
ts_config = {
lua = { "string", "source" },
@ -23,11 +23,11 @@ npairs.setup {
highlight = "PmenuSel",
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")
if not cmp_status_ok then
return
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()
local check_backspace = function()
local col = vim.fn.col "." - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
end
--   פּ ﯟ   some other good icons
@ -45,7 +45,7 @@ local kind_icons = {
}
-- find more here: https://www.nerdfonts.com/cheat-sheet
cmp.setup {
cmp.setup({
snippet = {
expand = function(args)
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-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-e>"] = cmp.mapping {
["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
}),
-- Accept currently selected item. If none selected, `select` first item.
-- 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)
if cmp.visible() then
cmp.select_next_item()
@ -128,16 +128,16 @@ cmp.setup {
ghost_text = false,
native_menu = false,
},
}
cmp.setup.cmdline(':', {
sources = {
{ name = 'cmdline' }
}
})
cmp.setup.cmdline('/', {
cmp.setup.cmdline(":", {
sources = {
{ name = 'buffer' }
}
{ name = "cmdline" },
},
})
cmp.setup.cmdline("/", {
sources = {
{ name = "buffer" },
},
})

View File

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

View File

@ -3,9 +3,9 @@ if not status_ok then
return
end
comment.setup {
comment.setup({
pre_hook = function(ctx)
local U = require "Comment.utils"
local U = require("Comment.utils")
local location = nil
if ctx.ctype == U.ctype.block then
@ -14,9 +14,9 @@ comment.setup {
location = require("ts_context_commentstring.utils").get_visual_start_location()
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",
location = location,
}
})
end,
}
})

View File

@ -3,7 +3,7 @@ if not status_ok then
return
end
gitsigns.setup {
gitsigns.setup({
signs = {
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
change = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
@ -45,4 +45,4 @@ gitsigns.setup {
yadm = {
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-k>", "<C-\\><C-N><C-w>k", term_opts)
keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)

View File

@ -1,40 +1,56 @@
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 = {
"diagnostics",
sources = {"nvim_diagnostic"},
sections = {"error", "warn"},
symbols = {error = "", warn = ""},
sources = { "nvim_diagnostic" },
sections = { "error", "warn" },
symbols = { error = "", warn = "" },
colored = false,
update_in_insert = false,
always_visible = true
always_visible = true,
}
local diff = {
"diff",
colored = false,
symbols = {added = "", modified = "", removed = ""}, -- changes diff symbols
cond = hide_in_width
symbols = { added = "", modified = "", removed = "" }, -- changes diff symbols
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 }
local branch = {"branch", icons_enabled = true, icon = ""}
local branch = { "branch", icons_enabled = true, icon = "" }
local location = {"location", padding = 0}
local location = { "location", padding = 0 }
-- cool function for progress
local progress = function()
local current_line = vim.fn.line(".")
local total_lines = vim.fn.line("$")
local chars = {
"__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆",
"▇▇", "██"
"__",
"▁▁",
"▂▂",
"▃▃",
"▄▄",
"▅▅",
"▆▆",
"▇▇",
"██",
}
local line_ratio = current_line / total_lines
local index = math.ceil(line_ratio * #chars)
@ -49,30 +65,34 @@ lualine.setup({
options = {
icons_enabled = true,
theme = "minimalmistakes-nvim",
component_separators = {left = "", right = ""},
section_separators = {left = "", right = ""},
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
"alpha", "dashboard", "NvimTree", "Outline", "packer"
"alpha",
"dashboard",
"NvimTree",
"Outline",
"packer",
},
always_divide_middle = true
always_divide_middle = true,
},
sections = {
lualine_a = {branch, diagnostics},
lualine_b = {mode},
lualine_a = { branch, diagnostics },
lualine_b = { mode },
lualine_c = {},
-- lualine_x = { "encoding", "fileformat", "filetype" },
lualine_x = {diff, spaces, "encoding", filetype},
lualine_y = {location},
lualine_z = {progress}
lualine_x = { diff, spaces, "encoding", filetype },
lualine_y = { location },
lualine_z = { progress },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {"filename"},
lualine_x = {"location"},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {}
lualine_z = {},
},
tabline = {},
extensions = {"nvim-tree"}
extensions = { "nvim-tree" },
})

View File

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

View File

@ -3,7 +3,7 @@ local options = {
backup = false, -- creates a backup file
clipboard = "unnamedplus", -- allows neovim to access the system clipboard
cmdheight = 1, -- more space in the neovim command line for displaying messages
completeopt = {"menuone", "noselect"}, -- mostly just for cmp
completeopt = { "menuone", "noselect" }, -- mostly just for cmp
conceallevel = 0, -- so that `` is visible in markdown files
fileencoding = "utf-8", -- the encoding written to a file
hlsearch = true, -- highlight all matches on previous search pattern
@ -34,15 +34,17 @@ local options = {
scrolloff = 8, -- is one of my fav
sidescrolloff = 8,
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.listchars:append "space:⋅"
vim.opt.listchars:append "eol:↴"
vim.opt.shortmess:append("c")
vim.opt.listchars:append("space:⋅")
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 iskeyword+=-]]
vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work
vim.cmd("set whichwrap+=<,>,[,],h,l")
vim.cmd([[set iskeyword+=-]])
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
end
telescope.load_extension('projects')
telescope.load_extension("projects")

View File

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

View File

@ -27,16 +27,16 @@ toggleterm.setup({
})
function _G.set_terminal_keymaps()
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', '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-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-l>', [[<C-\><C-n><C-W>l]], opts)
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", "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-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-l>", [[<C-\><C-n><C-W>l]], opts)
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 lazygit = Terminal:new({ cmd = "lazygit", hidden = true })

View File

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