From ddbcf98ee387f11c4981b55fe97af6b819a88354 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 20 Jun 2022 11:22:38 -0500 Subject: [PATCH] update lvim config --- home/private_dot_config/lvim/config.lua | 50 +------- .../lvim/ftplugin/alpha.lua | 19 --- .../lvim/ftplugin/markdown.lua | 5 +- .../lvim/lua/autocommands.lua | 8 ++ home/private_dot_config/lvim/lua/commands.lua | 78 +++++++++++ .../lvim/lua/config/alpha.lua | 73 ----------- .../lvim/lua/keybindings.lua | 58 +++++---- home/private_dot_config/lvim/lua/plugins.lua | 121 +++++++++--------- home/private_dot_config/lvim/lua/settings.lua | 27 ++++ 9 files changed, 215 insertions(+), 224 deletions(-) delete mode 100644 home/private_dot_config/lvim/ftplugin/alpha.lua create mode 100644 home/private_dot_config/lvim/lua/autocommands.lua create mode 100644 home/private_dot_config/lvim/lua/commands.lua delete mode 100644 home/private_dot_config/lvim/lua/config/alpha.lua create mode 100644 home/private_dot_config/lvim/lua/settings.lua diff --git a/home/private_dot_config/lvim/config.lua b/home/private_dot_config/lvim/config.lua index 9a57c53..4b617f7 100644 --- a/home/private_dot_config/lvim/config.lua +++ b/home/private_dot_config/lvim/config.lua @@ -1,47 +1,5 @@ -require("plugins") -require("keybindings") - --- general -lvim.log.level = "warn" -lvim.format_on_save = false - --- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -lvim.builtin.notify.active = true -lvim.builtin.terminal.active = true -lvim.builtin.nvimtree.setup.view.side = "left" -lvim.builtin.nvimtree.show_icons.git = 0 - --- if you don't want all the parsers change this to a table of the ones you want -lvim.builtin.treesitter.ensure_installed = { - "bash", - "haskell", - "javascript", - "json", - "lua", - "python", - -- "typescript", - "css", - -- "rust", - "yaml", - "go" -} - -lvim.builtin.treesitter.highlight.enabled = true - --- colorscheme -lvim.builtin.lualine.options.theme = "catppuccin" -lvim.colorscheme = "catppuccin" - --- settings -local opt = vim.opt -opt.timeoutlen = 200 -opt.cmdheight = 1 - -lvim.autocommands.custom_groups = { - -- On entering insert mode in any file, scroll the window so the cursor line is centered - {"InsertEnter", "*", ":normal zz"}, - -- Auto disbale spell checking on buffer open - {"BufNewFile,BufReadPost,FilterReadPost,FileReadPost","*",":set nospell"}, -} - +require('settings') +require('plugins') +require('keybindings') +require('autocommands') diff --git a/home/private_dot_config/lvim/ftplugin/alpha.lua b/home/private_dot_config/lvim/ftplugin/alpha.lua deleted file mode 100644 index 45190f7..0000000 --- a/home/private_dot_config/lvim/ftplugin/alpha.lua +++ /dev/null @@ -1,19 +0,0 @@ -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 index e99e38f..c6d39a4 100644 --- a/home/private_dot_config/lvim/ftplugin/markdown.lua +++ b/home/private_dot_config/lvim/ftplugin/markdown.lua @@ -1,5 +1,8 @@ + +local _, util = pcall(require, "zk.util") + -- Add the key mappings only for Markdown files in a zk notebook. -if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then +if 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. diff --git a/home/private_dot_config/lvim/lua/autocommands.lua b/home/private_dot_config/lvim/lua/autocommands.lua new file mode 100644 index 0000000..4f2445f --- /dev/null +++ b/home/private_dot_config/lvim/lua/autocommands.lua @@ -0,0 +1,8 @@ +-- Is this necessary? +vim.api.nvim_create_autocmd("FileType", { + pattern = "zsh", + callback = function() + -- let treesitter use bash highlight for zsh files as well + require("nvim-treesitter.highlight").attach(0, "bash") + end, +}) diff --git a/home/private_dot_config/lvim/lua/commands.lua b/home/private_dot_config/lvim/lua/commands.lua new file mode 100644 index 0000000..d0db091 --- /dev/null +++ b/home/private_dot_config/lvim/lua/commands.lua @@ -0,0 +1,78 @@ +-- local _, zk = pcall(require, "zk") +-- local _, commands = pcall(require, "zk.commands") + +-- TODO: figure out what's wrong with these .... +-- local function dump(o) +-- if type(o) == 'table' then +-- local s = '{ ' +-- for k, v in pairs(o) do +-- if type(k) ~= 'number' then k = '"' .. k .. '"' end +-- s = s .. '[' .. k .. '] = ' .. dump(v) .. ',' +-- end +-- return s .. '} ' +-- else +-- return tostring(o) +-- end +-- end + +-- commands.add("ZkLinkTo", function(options) +-- zk.pick_notes(options, { title = "ZkLinkTo" }, function(notes) +-- local note = notes[1] +-- local title = '' +-- print(dump(note)) +-- if note.title then +-- title = note.title +-- else +-- title = "Untitled" +-- end +-- local link = "[" .. title .. "](" .. note.absPath .. ")" +-- print(link) +-- -- notes = { notes } +-- for i, note in ipairs(notes) do +-- print(i) +-- print(note.title) +-- if note.title then +-- print("[" .. note.title .. "](" .. note.absPath .. ")") +-- link = "[" .. note.title .. "](" .. note.absPath .. ")" +-- else +-- print('no title brah') +-- link = 'other lin' +-- print(link) +-- end +-- print(link) +-- print(note.absPath) +-- -- -- vim.cmd("e " .. note.absPath) +-- end +-- end) +-- end) + +-- commands.add("ZkListLin", function(options) +-- zk.pick_notes(options, { title = "ZkLinkTo" }, function(notes) +-- local note = notes[1] +-- local title = '' +-- print(dump(note)) +-- if note.title then +-- title = note.title +-- else +-- title = "Untitled" +-- end +-- local link = "[" .. title .. "](" .. note.absPath .. ")" +-- print(link) +-- -- notes = { notes } +-- for i, note in ipairs(notes) do +-- print(i) +-- print(note.title) +-- if note.title then +-- print("[" .. note.title .. "](" .. note.absPath .. ")") +-- link = "[" .. note.title .. "](" .. note.absPath .. ")" +-- else +-- print('no title brah') +-- link = 'other lin' +-- print(link) +-- end +-- print(link) +-- print(note.absPath) +-- -- -- vim.cmd("e " .. note.absPath) +-- end +-- end) +-- end) diff --git a/home/private_dot_config/lvim/lua/config/alpha.lua b/home/private_dot_config/lvim/lua/config/alpha.lua deleted file mode 100644 index e3ee136..0000000 --- a/home/private_dot_config/lvim/lua/config/alpha.lua +++ /dev/null @@ -1,73 +0,0 @@ --- 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 7b5edda..9a8be7a 100644 --- a/home/private_dot_config/lvim/lua/keybindings.lua +++ b/home/private_dot_config/lvim/lua/keybindings.lua @@ -1,25 +1,21 @@ -- Map a key with optional options local function map(mode, keys, action, options) if options == nil then - options = {noremap=true} + options = { noremap = true } end - vim.api.nvim_set_keymap(mode,keys,action,options) + vim.api.nvim_set_keymap(mode, keys, action, options) end vim.g.mapleader = " " -map('i','jk','',{noremap=true}) -map('v','jk','',{noremap=true}) - -map('n', "H", "^",{noremap=true}) -map('n', "L", "$",{noremap=true}) - -map('n','j',"v:count ? 'j' : 'gj'",{expr=true,noremap=true}) -map('n','k',"v:count ? 'k' : 'gk'",{expr=true,noremap=true}) +map('i', 'jk', '', { noremap = true }) +map('v', 'jk', '', { noremap = true }) +map('n', "H", "^", { noremap = true }) +map('n', "L", "$", { noremap = true }) +map('n', 'j', "v:count ? 'j' : 'gj'", { expr = true, noremap = true }) +map('n', 'k', "v:count ? 'k' : 'gk'", { expr = true, noremap = true }) -- zettelkasten keybindings - - -- Create a new note after asking for its title. -- map("n", "zn", "ZkNew { title = vim.fn.input('Title: ') }") @@ -31,23 +27,37 @@ map('n','k',"v:count ? 'k' : 'gk'",{expr=true,noremap=true}) -- -- Search for the notes matching a given query. -- map("n", "zf", "ZkNotes { sort = { 'modified' }, match = vim.fn.input('Search: ') }") -- -- Search for the notes matching the current visual selection. + map("v", "zf", ":'<,'>ZkMatch") 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" }, + 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"} +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] --- lvim.leader = "space" --- add your own keymapping -lvim.keys.normal_mode[""] = ":w" +-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. +-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet. +local _, actions = pcall(require, "telescope.actions") +lvim.builtin.telescope.defaults.mappings = { + -- for input mode + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + }, + -- for normal mode + n = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, +} diff --git a/home/private_dot_config/lvim/lua/plugins.lua b/home/private_dot_config/lvim/lua/plugins.lua index 426fd7b..fbb7173 100644 --- a/home/private_dot_config/lvim/lua/plugins.lua +++ b/home/private_dot_config/lvim/lua/plugins.lua @@ -2,79 +2,78 @@ local p = function(name) return string.format("require'config.%s'", name) end -- extra plugins lvim.plugins = { - { 'chrisbra/Colorizer' }, - { - 'catppuccin/nvim', - as = 'catppuccin' - }, - { 'NoahTheDuke/vim-just' }, - { 'Mofiqul/dracula.nvim' }, - { 'ggandor/lightspeed.nvim' }, - { 'elkowar/yuck.vim' }, - { 'goolord/alpha-nvim', - config = p"alpha" - }, - { - 'mickael-menu/zk-nvim', - config = function () - require("zk").setup({ - -- can be "telescope", "fzf" or "select" (`vim.ui.select`) - -- it's recommended to use "telescope" or "fzf" - picker = "telescope", - lsp = { - -- `config` is passed to `vim.lsp.start_client(config)` - config = { - cmd = { "zk", "lsp" }, - name = "zk", - -- on_attach = ... - -- etc, see `:h vim.lsp.start_client()` - }, - - -- automatically attach buffers in a zk notebook that match the given filetypes - auto_attach = { - enabled = true, - filetypes = { "markdown" }, - }, + { 'chrisbra/Colorizer' }, + { + 'catppuccin/nvim', + as = 'catppuccin' + }, + -- { 'axelf4/vim-strip-trailing-whitespace' }, + { 'NoahTheDuke/vim-just' }, + { 'ggandor/lightspeed.nvim' }, + { 'elkowar/yuck.vim' }, + { + 'mickael-menu/zk-nvim', + config = function() + require("zk").setup({ + -- can be "telescope", "fzf" or "select" (`vim.ui.select`) + -- it's recommended to use "telescope" or "fzf" + picker = "telescope", + lsp = { + -- `config` is passed to `vim.lsp.start_client(config)` + config = { + cmd = { "zk", "lsp" }, + name = "zk", + -- on_attach = ... + -- etc, see `:h vim.lsp.start_client()` }, - }) - end, - } + + -- automatically attach buffers in a zk notebook that match the given filetypes + auto_attach = { + enabled = true, + filetypes = { "markdown" }, + }, + }, + }) + end, + }, } -- default plugins settings +-- lvim.builtin.nvimtree.setup.git.ignore = false --- make telescope respect that hidden files exist --- lvim.builtin.telescope.pickers = { find_files = { hidden = true }} -lvim.builtin.nvimtree.setup.git.ignore = false +lvim.builtin.notify.active = true +lvim.builtin.terminal.active = true + + +lvim.builtin.alpha.dashboard.section.header.val = { + [[ _______________________________________ ]], + [[ |,---"-----------------------------"---,| ]], + [[ ||___ 16 bit.................... || ]], + [[ ||====\ :HHHHHHHHHHHHHHHHHHHHHHHHHHH || ]], + [[ ||=====):H c> lvim H || ]], + [[ ||====/ :H ╦ ╦ ╦╔╗╔╔═╗╦═╗╦ ╦╦╔╦╗ H || ]], + [[ || :H ║ ║ ║║║║╠═╣╠╦╝╚╗╔╝║║║║ H || ]], + [[ ||PORTFO:H ╩═╝╚═╝╝╚╝╩ ╩╩╚═ ╚╝ ╩╩ ╩ H || ]], + [[ || :HHHHHHHHHHHHHHHHHHHHHHHHHHH || ]], + [[ ||_____,_________________________,_____|| ]], + [[ |)_____)-----.| /I\ATARI |.------(_____(| ]], + [[ //"""""""|_____|=----------=|______|"""""""\ ]], + [[ // _| _| _| _| _| _| _| _| _| _| _| _| _| _| \ ]], + [[ // ___| _| _| _| _| _| _| _| _| _| _| _| | | \ ]], + [[ |/ ___| _| _| _| _| _| _| _| _| _| _| _| ______| \ ]], + [[ / __| _| _| _| _| _| _| _| _| _| _| _| _| _| ___| \ ]], + [[ / _| _| _| _| ________________________| _| _| _| _| \ ]], + [[|------"--------------------------------------"-------|]], + [[`-----------------------------------------------------']], +} -lvim.builtin.dashboard.custom_header = { -[[ _______________________________________ ]], -[[ |,---"-----------------------------"---,| ]], -[[ ||___ 16 bit.................... || ]], -[[ ||====\ :HHHHHHHHHHHHHHHHHHHHHHHHHHH || ]], -[[ ||=====):H c> lvim H || ]], -[[ ||====/ :H ╦ ╦ ╦╔╗╔╔═╗╦═╗╦ ╦╦╔╦╗ H || ]], -[[ || :H ║ ║ ║║║║╠═╣╠╦╝╚╗╔╝║║║║ H || ]], -[[ ||PORTFO:H ╩═╝╚═╝╝╚╝╩ ╩╩╚═ ╚╝ ╩╩ ╩ H || ]], -[[ || :HHHHHHHHHHHHHHHHHHHHHHHHHHH || ]], -[[ ||_____,_________________________,_____|| ]], -[[ |)_____)-----.| /I\ATARI |.------(_____(| ]], -[[ //"""""""|_____|=----------=|______|"""""""\ ]], -[[ // _| _| _| _| _| _| _| _| _| _| _| _| _| _| \ ]], -[[ // ___| _| _| _| _| _| _| _| _| _| _| _| | | \ ]], -[[ |/ ___| _| _| _| _| _| _| _| _| _| _| _| ______| \ ]], -[[ / __| _| _| _| _| _| _| _| _| _| _| _| _| _| ___| \ ]], -[[ / _| _| _| _| ________________________| _| _| _| _| \ ]], -[[|------"--------------------------------------"-------|]], -[[`-----------------------------------------------------']], - } -- simpler header --[[ ╦ ╦ ╦╔╗╔╔═╗╦═╗╦ ╦╦╔╦╗ ║ ║ ║║║║╠═╣╠╦╝╚╗╔╝║║║║ ╩═╝╚═╝╝╚╝╩ ╩╩╚═ ╚╝ ╩╩ ╩ -]]-- +]] -- --[[ _______________________________________ diff --git a/home/private_dot_config/lvim/lua/settings.lua b/home/private_dot_config/lvim/lua/settings.lua new file mode 100644 index 0000000..2ca2f9c --- /dev/null +++ b/home/private_dot_config/lvim/lua/settings.lua @@ -0,0 +1,27 @@ +-- settings +local opt = vim.opt +opt.timeoutlen = 200 +opt.cmdheight = 0 + +-- lvim specific settings +-- general +lvim.log.level = "warn" +lvim.format_on_save = false +lvim.colorscheme = "catppuccin" + +-- if you don't want all the parsers change this to a table of the ones you want +lvim.builtin.treesitter.ensure_installed = { + "bash", + "javascript", + "json", + "lua", + "python", + "typescript", + "tsx", + "css", + "rust", + "yaml", + "toml" +} + +lvim.builtin.treesitter.highlight.enabled = true