From 59509ae476c46eaea26ddc62488d45009406ccf6 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 8 Feb 2022 13:42:16 -0600 Subject: [PATCH] add zk and alpha lvim configs --- home/private_dot_config/lvim/config.lua | 1 - .../lvim/ftplugin/alpha.lua | 19 +++++ .../lvim/ftplugin/markdown.lua | 26 +++++++ .../lvim/lua/config/alpha.lua | 73 +++++++++++++++++++ .../lvim/lua/keybindings.lua | 7 +- home/private_dot_config/lvim/lua/plugins.lua | 6 +- 6 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 home/private_dot_config/lvim/ftplugin/alpha.lua create mode 100644 home/private_dot_config/lvim/ftplugin/markdown.lua create mode 100644 home/private_dot_config/lvim/lua/config/alpha.lua diff --git a/home/private_dot_config/lvim/config.lua b/home/private_dot_config/lvim/config.lua index 4f8fb9b..476dc04 100644 --- a/home/private_dot_config/lvim/config.lua +++ b/home/private_dot_config/lvim/config.lua @@ -6,7 +6,6 @@ lvim.log.level = "warn" lvim.format_on_save = true -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -lvim.builtin.dashboard.active = true lvim.builtin.notify.active = true lvim.builtin.terminal.active = true lvim.builtin.nvimtree.setup.view.side = "left" diff --git a/home/private_dot_config/lvim/ftplugin/alpha.lua b/home/private_dot_config/lvim/ftplugin/alpha.lua new file mode 100644 index 0000000..45190f7 --- /dev/null +++ b/home/private_dot_config/lvim/ftplugin/alpha.lua @@ -0,0 +1,19 @@ +local wk = require("which-key") +-- local opts = lvim.builtin.which_key.opts + + +local opts = { + mode = "n", -- NORMAL mode + prefix = "", + buffer = 0, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = false, -- use `nowait` when creating keymaps +} + +local mappings = { + C = "Edit Configuration" +} + +wk.register(mappings,opts) + diff --git a/home/private_dot_config/lvim/ftplugin/markdown.lua b/home/private_dot_config/lvim/ftplugin/markdown.lua new file mode 100644 index 0000000..e99e38f --- /dev/null +++ b/home/private_dot_config/lvim/ftplugin/markdown.lua @@ -0,0 +1,26 @@ +-- Add the key mappings only for Markdown files in a zk notebook. +if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then + local function map(...) vim.api.nvim_buf_set_keymap(0, ...) end + local opts = { noremap=true, silent=false } + -- Open the link under the caret. + map("n", "", "lua vim.lsp.buf.definition()", opts) + -- Create a new note after asking for its title. + -- This overrides the global `zn` mapping to create the note in the same directory as the current buffer. + map("n", "zn", "ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", opts) + -- Create a new note in the same directory as the current buffer, using the current selection for title. + map("v", "znt", ":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }", opts) + -- Create a new note in the same directory as the current buffer, using the current selection for note content and asking for its title. + map("v", "znc", ":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", opts) + + -- Open notes linking to the current buffer. + map("n", "zb", "ZkBacklinks", opts) + -- Alternative for backlinks using pure LSP and showing the source context. + --map('n', 'zb', 'lua vim.lsp.buf.references()', opts) + -- Open notes linked by the current buffer. + map("n", "zl", "ZkLinks", opts) + + -- Preview a linked note. + map("n", "K", "lua vim.lsp.buf.hover()", opts) + -- Open the code actions for a visual selection. + map("v", "za", ":'<,'>lua vim.lsp.buf.range_code_action()", opts) +end diff --git a/home/private_dot_config/lvim/lua/config/alpha.lua b/home/private_dot_config/lvim/lua/config/alpha.lua new file mode 100644 index 0000000..e3ee136 --- /dev/null +++ b/home/private_dot_config/lvim/lua/config/alpha.lua @@ -0,0 +1,73 @@ +-- ref: https://github.com/dtr2300/nvim/blob/main/lua/config/plugins/alpha.lua +local alpha = require("alpha") +local dashboard = require("alpha.themes.dashboard") +math.randomseed(os.time()) + +local function button(sc, txt, keybind, keybind_opts) + local b = dashboard.button(sc, txt, keybind, keybind_opts) + b.opts.hl = "Function" + b.opts.hl_shortcut = "Type" + return b +end + +local function pick_color() + local colors = { "String", "Identifier", "Keyword", "Number", "Constant" } + return colors[math.random(#colors)] +end + +local function footer() + local plugins = #vim.tbl_keys(packer_plugins) + local v = vim.version() + local datetime = os.date " %d-%m-%Y  %H:%M:%S" + return string.format(" %s  v%s.%s.%s %s", plugins, v.major, v.minor, v.patch, datetime) +end + +dashboard.section.header.val = { + [[ _______________________________________ ]], + [[ |,---"-----------------------------"---,| ]], + [[ ||___ 16 bit.................... || ]], + [[ ||====\ :HHHHHHHHHHHHHHHHHHHHHHHHHHH || ]], + [[ ||=====):H c> lvim H || ]], + [[ ||====/ :H ╦ ╦ ╦╔╗╔╔═╗╦═╗╦ ╦╦╔╦╗ H || ]], + [[ || :H ║ ║ ║║║║╠═╣╠╦╝╚╗╔╝║║║║ H || ]], + [[ ||PORTFO:H ╩═╝╚═╝╝╚╝╩ ╩╩╚═ ╚╝ ╩╩ ╩ H || ]], + [[ || :HHHHHHHHHHHHHHHHHHHHHHHHHHH || ]], + [[ ||_____,_________________________,_____|| ]], + [[ |)_____)-----.| /I\ATARI |.------(_____(| ]], + [[ //"""""""|_____|=----------=|______|"""""""\ ]], + [[ // _| _| _| _| _| _| _| _| _| _| _| _| _| _| \ ]], + [[ // ___| _| _| _| _| _| _| _| _| _| _| _| | | \ ]], + [[ |/ ___| _| _| _| _| _| _| _| _| _| _| _| ______| \ ]], + [[ / __| _| _| _| _| _| _| _| _| _| _| _| _| _| ___| \ ]], + [[ / _| _| _| _| ________________________| _| _| _| _| \ ]], + [[|------"--------------------------------------"-------|]], + [[`-----------------------------------------------------']], +} + +dashboard.section.header.opts.hl = pick_color() + +dashboard.section.buttons.val = { + button( "n", " New file" , ":ene startinsert "), + button( "SPC f"," Find File", "Telescope find_files"), + button( "SPC s p"," Recent Projects", "Telescope projects" ), + button( "SPC s r"," Recently Used Files", "Telescope oldfiles"), + button( "SPC s w", " Find Word","Telescope live_grep"), + button( "SPC C"," Configuration",":e ~/.config/lvim/config.lua" ), + button( "q", " Quit NVIM" , ":qa"), +} + +dashboard.section.footer.val = footer() +dashboard.section.footer.opts.hl = dashboard.section.header.opts.hl + + +-- hide tabline and statusline on startup +vim.cmd [[ +augroup alpha_tabline + au! + au FileType alpha set showtabline=0 laststatus=0 noruler | au BufUnload set showtabline=2 ruler laststatus=2 +augroup END +]] + + +alpha.setup(dashboard.opts) + diff --git a/home/private_dot_config/lvim/lua/keybindings.lua b/home/private_dot_config/lvim/lua/keybindings.lua index 0205a54..a247e27 100644 --- a/home/private_dot_config/lvim/lua/keybindings.lua +++ b/home/private_dot_config/lvim/lua/keybindings.lua @@ -30,13 +30,18 @@ map('n', "L", "$",{noremap=true}) -- -- Search for the notes matching the current visual selection. map("v", "zf", ":'<,'>ZkMatch") -lvim.builtin.which_key.mappings["z"] = { +local mappings = lvim.builtin.which_key.mappings + +mappings["z"] = { name = "zk", n = { "ZkNew { title = vim.fn.input('Title: ') }", "New"}, o = { "ZkNotes { sort = { 'modified' } }", "Open" }, t = { "ZkTags", "Tags"}, f = { "ZkNotes { sort = { 'modified' }, match = vim.fn.input('Search: ') }", "Fuzzy Search" }, } +mappings["s"]["p"] = {"Telescope projects","Recent Projects"} +mappings["s"]["w"] = {"Telescope live_grep","Find Word"} +mappings[';'] = { "Alpha", "Dashboard"} -- keymappings [view all the defaults by pressing Lk] diff --git a/home/private_dot_config/lvim/lua/plugins.lua b/home/private_dot_config/lvim/lua/plugins.lua index c33bbff..a660772 100644 --- a/home/private_dot_config/lvim/lua/plugins.lua +++ b/home/private_dot_config/lvim/lua/plugins.lua @@ -1,7 +1,12 @@ +local p = function(name) return string.format("require'config.%s'", name) end + -- extra plugins lvim.plugins = { { 'Mofiqul/dracula.nvim' }, { 'ggandor/lightspeed.nvim' }, + { 'goolord/alpha-nvim', + config = p"alpha" + }, { 'mickael-menu/zk-nvim', config = function () @@ -35,7 +40,6 @@ lvim.plugins = { lvim.builtin.telescope.pickers = { find_files = { hidden = true }} lvim.builtin.nvimtree.setup.git.ignore = false - lvim.builtin.dashboard.custom_header = { [[ _______________________________________ ]], [[ |,---"-----------------------------"---,| ]],