Whichkey rework, dashboard, yazi

This commit is contained in:
agryphus 2024-02-20 21:15:43 -05:00
parent d9ac8b2bd1
commit 92bd99d8ea
13 changed files with 197 additions and 39 deletions

View file

@ -191,13 +191,17 @@ vim.cmd[[colorscheme no-clown-fiesta]]
-- My own color overrides
local hl = vim.api.nvim_set_hl
hl(0, 'TSConstant', { fg = palette.yellow })
hl(0, 'EndOfBuffer', { fg = palette.medium_gray })
hl(0, 'ErrorMsg', { fg = palette.yellow })
hl(0, 'LineNr', { fg = palette.medium_gray })
hl(0, 'MasonNormal', { bg = palette.gray })
hl(0, 'NvimTreeCursorLine', { fg = palette.yellow })
hl(0, 'NvimTreeEndOfBuffer', { fg = palette.medium_gray })
hl(0, 'TSConstant', { fg = palette.yellow })
hl(0, 'EndOfBuffer', { fg = palette.medium_gray })
hl(0, 'ErrorMsg', { fg = palette.yellow })
hl(0, 'LineNr', { fg = palette.medium_gray })
hl(0, 'MasonNormal', { bg = palette.gray })
hl(0, 'NvimTreeCursorLine', { fg = palette.yellow })
hl(0, 'NvimTreeEndOfBuffer', { fg = palette.medium_gray })
hl(0, 'NvimTreeIndentMarker', { fg = palette.medium_gray })
hl(0, 'NvimTreeFolderIcon', { fg = palette.yellow })
hl(0, 'NvimTreeFolderIcon', { fg = palette.yellow })
hl(0, 'WhichKeyFloat', { bg = nil })
hl(0, 'WhichKeyDesc', { link = "function" })
hl(0, 'WhichKey', { fg = palette.medium_gray_blue })
hl(0, 'WhichKeyGroup', { fg = palette.gray_blue, bold = true })

View file

@ -0,0 +1,58 @@
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
math.randomseed(os.time())
local function pick_color()
local colors = {"String", "Identifier", "Keyword", "Number"}
return colors[math.random(#colors)]
end
local function footer()
local total_plugins = #vim.tbl_keys(packer_plugins)
local version = vim.version()
local nvim_version_info = " NVIM v" .. version.major .. "." .. version.minor .. "." .. version.patch
return nvim_version_info .. " 󰏖 " .. total_plugins .. " plugins"
end
-- Set header
dashboard.section.header.val = {
" ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣭⣿⣶⣿⣦⣼⣆ ",
" ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ",
" ⠈ ⠈⢿⣿⣟⠦⠄⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ",
" ⣸⣿⣿⢧⠄⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ",
" ⢠⣿⣿⣿⠈ ⠡⠌⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ",
" ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿ ",
" ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷⠄ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ",
"⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ",
"⠙⠃ ⣼⣿⡟⠌ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿⠐⣿⣿⡇ ⠛⠻⢷⣄",
" ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ⠁",
" ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣀⣤⣾⡿⠃ ",
"⢀⣀⠀⣠⣀⣠⣾⣿⣿⡿⠛⠋⠉⠉⠉ ⠉⠉⠉⠉⠛⠻⣿⣿⣷⣄⣀⢿⡽⢻⣦",
"⠻⠶⠾⠿⠿⠿⠋⠉ N E O V I M ⠉⠻⠿⠿⠿⠿⠿⠋",
}
-- Set menu
dashboard.section.buttons.val = {
dashboard.button( "e", " New file" , ":ene <BAR> startinsert <CR>"),
dashboard.button( "q", "󰩈 Quit NVIM", ":qa<CR>"),
}
vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
math.randomseed(os.time())
local fg_color = tostring(math.random(0, 12))
local hi_setter = "hi AlphaHeader ctermfg="
vim.cmd(hi_setter .. fg_color)
end
})
dashboard.section.footer.val = footer()
dashboard.section.header.opts.hl = "Include"
dashboard.section.footer.opts.hl = "String"
alpha.setup(dashboard.opts)

View file

@ -1,2 +1,4 @@
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
local wk = require("which-key")
wk.register({g = { name = "git" }, prefix = "<leader>"})
vim.keymap.set("n", "<leader>gs", vim.cmd.Git, { desc = "Git status" })

View file

@ -1,4 +1,4 @@
vim.keymap.set("n", "<leader>e", function ()
vim.cmd("Lf")
end)
-- vim.keymap.set("n", "<leader>e", function ()
-- vim.cmd("Lf")
-- end)

View file

@ -9,17 +9,23 @@ lsp_zero.on_attach(function(client, bufnr)
lsp_zero.default_keymaps({buffer = bufnr})
end)
-- LUA
lspconfig.lua_ls.setup({
settings = {
Lua = {
diagnostics = {
-- Making sure that lua recognizes the global variable 'vim'
globals = { 'vim' },
globals = { 'vim', 'xplr' },
},
},
},
})
-- RUST
-- Must run `rustup default stable` and then `rustup component add rust-analyzer`
-- upon first install
lspconfig.rust_analyzer.setup({})
lspconfig.clangd.setup({
capabilities = lsp_capabilities,
})
@ -53,3 +59,11 @@ cmp.setup({
}
})
-- DIAGNOSTICS
-- Show all diagnostics on current line in floating window
vim.api.nvim_set_keymap(
'n', 'gl', ':lua vim.diagnostic.open_float()<CR>',
{ noremap = true, silent = true }
)

View file

@ -1,6 +1,7 @@
vim.cmd([[
vim.keymap.set("n", "<leader>mp", "<Plug>MarkdownPreview",
{ desc = "Markdown prewview" })
nmap <leader>mp <Plug>MarkdownPreview
vim.cmd([[
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0

View file

@ -1,14 +1,29 @@
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>pf", builtin.find_files, {})
vim.keymap.set("n", "<leader>ps", function()
builtin.grep_string({ search = vim.fn.input("Grep > ") })
end)
vim.keymap.set("n", "<leader>ht", builtin.colorscheme, {})
require("telescope").setup{
defaults = {
file_ignore_patterns = { ".git\\", ".pyc", ".mypy_cache\\", "node_modules\\", ".svg" }
}
}
local wk = require("which-key")
-- <leader> p
wk.register({p = { name = "project" }, prefix = "<leader>"})
vim.keymap.set("n", "<leader>pf", builtin.find_files, {desc = "Project find"})
vim.keymap.set("n", "<leader>ps", function ()
builtin.grep_string({ search = vim.fn.input("Grep > ") })
end , {desc = "Project search"})
-- <leader> f
wk.register({f = { name = "find" }, prefix = "<leader>"})
vim.keymap.set("n", "<leader>fr", builtin.oldfiles, { desc = "Find recent" })
-- <leader> h
wk.register({h = { name = "help" }, prefix = "<leader>"})
vim.keymap.set("n", "<leader>ht", builtin.colorscheme, { desc = "Load theme" })
vim.keymap.set("n", "<leader>hf", builtin.commands , { desc = "Describe function" })
vim.keymap.set("n", "<leader>hk", builtin.keymaps , { desc = "Describe key" })
vim.keymap.set("n", "<leader>hv", builtin.vim_options, { desc = "Describe key" })
vim.keymap.set("n", "<leader>hh", builtin.help_tags , { desc = "Search local wiki" })

16
after/plugin/whichkey.lua Normal file
View file

@ -0,0 +1,16 @@
require("which-key").setup({
window = {
border = "single", -- none, single, double, shadow
position = "bottom", -- bottom, top
margin = { 0, 0, 0, 0 }, -- extra window margin [top, right, bottom, left]. When between 0 and 1, will be treated as a percentage of the screen size.
padding = { 0, 2, 0, 2 }, -- extra window padding [top, right, bottom, left]
winblend = 0, -- value between 0-100 0 for fully opaque and 100 for fully transparent
zindex = 1000, -- positive value to position WhichKey above other floating windows.
},
layout = {
height = { min = 4, max = 25 }, -- min and max height of the columns
width = { min = 20, max = 50 }, -- min and max width of the columns
spacing = 3, -- spacing between columns
align = "left", -- align columns left, center or right
},
})

4
after/plugin/yazi.lua Normal file
View file

@ -0,0 +1,4 @@
vim.keymap.set("n", "<leader>e", function ()
vim.cmd("Yazi")
end)