From 764b890c5801fbfb68b01c5a8d148bbffe6280cc Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Wed, 7 Jun 2023 03:19:56 -0500 Subject: [PATCH] More work, LSP is not working yet need to figure that out more --- init.lua | 5 +- lazy-lock.json | 28 +-- lua/autocommands.lua | 52 ----- lua/keymaps.lua | 199 ++++-------------- lua/lsp.lua | 21 ++ lua/options.lua | 22 ++ lua/plugins/README.md | 15 ++ lua/{user => plugins}/auto-save.lua | 0 lua/{user => plugins}/http_rest.lua | 8 +- lua/plugins/layout-side-bar_neo-tree.lua | 41 ++++ lua/plugins/lsp-zero.lua | 20 ++ .../markdown_glow.lua} | 10 +- lua/plugins/open-github.lua | 8 + lua/plugins/telescope.lua | 18 ++ lua/{user => plugins}/theme_material.lua | 0 .../treesitter.lua} | 2 +- lua/plugins/undotree.lua | 9 + lua/{user => plugins}/util-plenary.lua | 0 lua/{user => plugins}/util_which-key.lua | 0 lua/{user => plugins_disabled}/autoswap.lua | 2 + .../ide_lsp_mason.lua | 18 +- .../layout-msg-popups_noice.lua | 0 lua/{user => plugins_disabled}/rust-tools.lua | 0 lua/tools/init.lua | 8 + lua/tools/scratch-files.lua | 36 ++++ lua/user/README.md | 5 - lua/user/gitsigns.lua | 15 -- lua/user/layout-side-bar_neo-tree.lua | 46 ---- lua/user/layout_telescope.lua | 42 ---- lua/user/open-github.lua | 10 - lua/user/welcome-screen_alpha.lua | 67 ------ lua/util.lua | 24 +++ 32 files changed, 290 insertions(+), 441 deletions(-) create mode 100644 lua/lsp.lua create mode 100644 lua/plugins/README.md rename lua/{user => plugins}/auto-save.lua (100%) rename lua/{user => plugins}/http_rest.lua (56%) create mode 100644 lua/plugins/layout-side-bar_neo-tree.lua create mode 100644 lua/plugins/lsp-zero.lua rename lua/{user/markdown-preview_glow.lua => plugins/markdown_glow.lua} (54%) create mode 100644 lua/plugins/open-github.lua create mode 100644 lua/plugins/telescope.lua rename lua/{user => plugins}/theme_material.lua (100%) rename lua/{user/syntax-highlighting_treesitter.lua => plugins/treesitter.lua} (98%) create mode 100644 lua/plugins/undotree.lua rename lua/{user => plugins}/util-plenary.lua (100%) rename lua/{user => plugins}/util_which-key.lua (100%) rename lua/{user => plugins_disabled}/autoswap.lua (50%) rename lua/{user => plugins_disabled}/ide_lsp_mason.lua (86%) rename lua/{user => plugins_disabled}/layout-msg-popups_noice.lua (100%) rename lua/{user => plugins_disabled}/rust-tools.lua (100%) create mode 100644 lua/tools/init.lua create mode 100644 lua/tools/scratch-files.lua delete mode 100644 lua/user/README.md delete mode 100644 lua/user/gitsigns.lua delete mode 100644 lua/user/layout-side-bar_neo-tree.lua delete mode 100644 lua/user/layout_telescope.lua delete mode 100644 lua/user/open-github.lua delete mode 100644 lua/user/welcome-screen_alpha.lua create mode 100644 lua/util.lua diff --git a/init.lua b/init.lua index 9def82b..0e66676 100644 --- a/init.lua +++ b/init.lua @@ -18,13 +18,14 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) -require("lazy").setup("user", { +require("lazy").setup("plugins", { change_detection = { enabled = false, } }) vim.cmd 'colorscheme material' - +require "tools" require "autocommands" +require "lsp" diff --git a/lazy-lock.json b/lazy-lock.json index 6ce65f2..9293c73 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,32 +1,26 @@ { - "SchemaStore.nvim": { "branch": "main", "commit": "15f37630d3abfb98607dd8e4625b731a8558b96d" }, - "alpha-nvim": { "branch": "main", "commit": "1838ae926e8d49fe5330d1498ee8289ae2c340bc" }, + "LuaSnip": { "branch": "master", "commit": "51ebb4b6637290e1b8e0fb0d6f38b605d3c24940" }, "auto-save.nvim": { "branch": "main", "commit": "979b6c82f60cfa80f4cf437d77446d0ded0addf0" }, - "gitsigns.nvim": { "branch": "main", "commit": "c18b7ca0b5b50596722f3a1572eb9b8eb520c0f1" }, - "glow.nvim": { "branch": "advanced_window", "commit": "f1157d4cb7e46e830c72004e7e1adb81a1f9b04c" }, - "lazy.nvim": { "branch": "main", "commit": "6610b15dfd76f7992423916e2b87f031881d7b25" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, + "glow.nvim": { "branch": "advanced_window", "commit": "bbd0473d72a45094495ee5600b5577823543eefe" }, + "lazy.nvim": { "branch": "main", "commit": "ae25448d39fb2bdc38a139339233270edec44484" }, + "lsp-zero.nvim": { "branch": "v2.x", "commit": "8fda9a849d6ab4196ecf129905764ddefdfb64b5" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "c55d18f3947562e699d34d89681edbf9f0e250d3" }, - "mason-null-ls.nvim": { "branch": "main", "commit": "54d702020bf94e4eefd357f0b738317af30217eb" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "c836e511e796d2b6a25ad9f164f5b25d8b9ff705" }, "mason.nvim": { "branch": "main", "commit": "08b2fd308e0107eab9f0b59d570b69089fd0b522" }, "material.nvim": { "branch": "main", "commit": "0c725897bc3d22c45fbf25a602002ee02f06f619" }, "neo-tree.nvim": { "branch": "v2.x", "commit": "20c2f2f5ba083bbb1e37b8bc3d590621434f31e9" }, - "neodev.nvim": { "branch": "main", "commit": "2daabebac1b0b2ab7abba298c1a8f07a542866a6" }, - "noice.nvim": { "branch": "main", "commit": "f5178da0097e964b37951a0ebc078fdcc14280f3" }, - "nui.nvim": { "branch": "main", "commit": "698e75814cd7c56b0dd8af4936bcef2d13807f3c" }, - "null-ls.nvim": { "branch": "main", "commit": "77e53bc3bac34cc273be8ed9eb9ab78bcf67fa48" }, - "nvim-dap": { "branch": "master", "commit": "56118cee6af15cb9ddba9d080880949d8eeb0c9f" }, + "nui.nvim": { "branch": "main", "commit": "d5a82aae64426a805e19d8ef5a379292f9dc55d3" }, + "nvim-cmp": { "branch": "main", "commit": "fc0f694af1a742ada77e5b1c91ff405c746f4a26" }, "nvim-lspconfig": { "branch": "master", "commit": "1c13e529bd5683b54a39b633a560d2f00fcb25af" }, - "nvim-notify": { "branch": "master", "commit": "f3024b912073774111202f5fa6518b0cd2a74432" }, "nvim-treesitter": { "branch": "master", "commit": "f2778bd1a28b74adf5b1aa51aa57da85adfa3d16" }, "nvim-ts-autotag": { "branch": "main", "commit": "40615e96075c743ef47aaf9de966dc348bec6459" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "0bf8fbc2ca8f8cdb6efbd0a9e32740d7a991e4c3" }, "openingh.nvim": { "branch": "main", "commit": "374c081409dc238018cd986410f16190d8f9f680" }, "plenary.nvim": { "branch": "master", "commit": "9ac3e9541bbabd9d73663d757e4fe48a675bb054" }, "rest.nvim": { "branch": "main", "commit": "d8dc204e9f6fd930d9d1d709f0d19138f804431a" }, - "rust-tools.nvim": { "branch": "master", "commit": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, - "telescope.nvim": { "branch": "master", "commit": "40c31fdde93bcd85aeb3447bb3e2a3208395a868" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, + "telescope.nvim": { "branch": "master", "commit": "c1a2af0af69e80e14e6b226d3957a064cd080805" }, + "undotree": { "branch": "master", "commit": "485f01efde4e22cb1ce547b9e8c9238f36566f21" }, "vim-autoswap": { "branch": "master", "commit": "e587e4b14a605d8921942ba65a37583813289272" }, "which-key.nvim": { "branch": "main", "commit": "e271c28118998c93a14d189af3395812a1aa646c" } -} +} \ No newline at end of file diff --git a/lua/autocommands.lua b/lua/autocommands.lua index b79a80d..8b13789 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -1,53 +1 @@ -function is_available(plugin) - local lazy_config_avail, lazy_config = pcall(require, "lazy.core.config") - return lazy_config_avail and lazy_config.plugins[plugin] ~= nil -end -local augroup = vim.api.nvim_create_augroup -local autocmd = vim.api.nvim_create_autocmd -local cmd = vim.api.nvim_create_user_command -local namespace = vim.api.nvim_create_namespace - -if is_available "alpha-nvim" then - local group_name = augroup("alpha_settings", { clear = true }) - autocmd({ "User", "BufEnter" }, { - desc = "Disable status and tablines for alpha", - group = group_name, - callback = function(event) - if - ( - (event.event == "User" and event.file == "AlphaReady") - or (event.event == "BufEnter" and vim.api.nvim_get_option_value("filetype", { buf = event.buf }) == "alpha") - ) and not vim.g.before_alpha - then - vim.g.before_alpha = { showtabline = vim.opt.showtabline:get(), laststatus = vim.opt.laststatus:get() } - vim.opt.showtabline, vim.opt.laststatus = 0, 0 - elseif - vim.g.before_alpha - and event.event == "BufEnter" - and vim.api.nvim_get_option_value("buftype", { buf = event.buf }) ~= "nofile" - then - vim.opt.laststatus, vim.opt.showtabline = vim.g.before_alpha.laststatus, vim.g.before_alpha.showtabline - vim.g.before_alpha = nil - end - end, - }) - autocmd("VimEnter", { - desc = "Start Alpha when vim is opened with no arguments", - group = group_name, - callback = function() - local should_skip = false - if vim.fn.argc() > 0 or vim.fn.line2byte(vim.fn.line "$") ~= -1 or not vim.o.modifiable then - should_skip = true - else - for _, arg in pairs(vim.v.argv) do - if arg == "-b" or arg == "-c" or vim.startswith(arg, "+") or arg == "-S" then - should_skip = true - break - end - end - end - if not should_skip then require("alpha").start(true, require("alpha").default_config) end - end, - }) -end diff --git a/lua/keymaps.lua b/lua/keymaps.lua index ae10bb6..28d339b 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -1,10 +1,5 @@ --- Shorten function name -local keymap = vim.keymap.set --- Silent keymap option -local opts = { silent = true } - ---Remap space as leader key -keymap("", "", "", opts) +-- Remap space as leader key +vim.keymap.set("", "", "", { silent = true }) vim.g.mapleader = " " -- Modes @@ -15,161 +10,53 @@ vim.g.mapleader = " " -- term_mode = "t", -- command_mode = "c", -local scratch = function(extension) - os.execute "mkdir -p ~/dev/scratches/" - local date = os.date "%Y-%m-%dT%H:%M:%S" - local filepath = "~/dev/scratches/scratch_" .. date .. extension - vim.cmd("execute 'edit " .. filepath .. "'") -end - -local mappings = { - n = { +require('util').keymaps({ + n = { + ["n"] = { "nzzzv", desc = "Next search result centered" }, + ["N"] = { "Nzzzv", desc = "Previous search result centered" }, + [""] = { ":noh", desc = "Clear search on escape" }, + [""] = {":noh", desc = "Clear search on return" }, ["w"] = { "w", desc = "Save" }, ["q"] = { "confirm q", desc = "Quit" }, ["|"] = { "vsplit", desc = "Vertical Split" }, ["\\"] = { "split", desc = "Horizontal Split" }, - [""] = { "zz", desc = "Vertical half page down and center cursor" }, - [""] = { "zz", desc = "Vertical half page up and center cursor" }, - ["y"] = { '"*y', desc = "Copy to system clipboard" }, - ["p"] = { '"*p', desc = "Paste from system clipboard" }, - -- TODO L-c to close buffer + [""] = { "zz", desc = "Vertical half page down and center cursor" }, + [""] = { "zz", desc = "Vertical half page up and center cursor" }, + ["y"] = { '"*y', desc = "Copy to system clipboard" }, + ["p"] = { '"*p', desc = "Paste from system clipboard" }, + ["Q"] = { ":qa", desc = "Quit all" }, - ["fs"] = { - function() - require("telescope.builtin").live_grep { - search_dirs = { "~/dev/scratches/" }, - } - end, - desc = "Find words in scratches", - }, - ["s"] = { name = " Scratch File" }, - ["ss"] = { function() scratch ".txt" end, desc = "New text scratch file" }, - ["sn"] = { function() scratch ".json" end, desc = "New json scratch file" }, - ["sq"] = { function() scratch ".sql" end, desc = "New sql scratch file" }, - ["st"] = { function() scratch ".ts" end, desc = "New ts scratch file" }, - ["sb"] = { function() scratch ".sh" end, desc = "New shell scratch file" }, - ["sj"] = { function() scratch ".js" end, desc = "New js scratch file" }, - - - ["Q"] = { ":qa", desc = "Quit all" }, - [","] = { name = " Misc Tools" }, - [",c"] = { name = " Casing" }, - [",cs"] = { ":Snek", desc = "To Snek Case" }, - [",cc"] = { ":Camel", desc = "To Camel Case" }, - [",cp"] = { ":CamelB", desc = "To Pascal Case" }, - [",ck"] = { ":Kebab", desc = "To Kebab Case" }, - [",ce"] = { ":Screm", desc = "To Screm Case" }, - [",j"] = { name = " Jest Tests" }, - [",jr"] = { function() require("jester").run() end, desc = "Run test under cursor" }, - [",jf"] = { function() require("jester").run_file() end, desc = "Run tests for file" }, - [",jl"] = { function() require("jester").run_last() end, desc = "Run last ran test" }, - ["lz"] = { ":LspRestart", desc = "Restart LSP Server" }, - }, - v = { - ["gf"] = { ":OpenInGHFile ", desc = "Open in github" }, - ["y"] = { '"*y', desc = "Copy to system clipboard" }, - ["p"] = { '"*p', desc = "Paste from system clipboard" }, - ["∆"] = { - cmd = ":m '>+1gv=gv", - desc = "Move the selected text up", - }, - ["˚"] = { - cmd = ":m '<-2gv=gv", - desc = "Move the selected text down", - }, - [","] = { name = " Misc Tools" }, - [",c"] = { name = " Casing" }, - [",cs"] = { ":Snek", desc = "To Snek Case" }, - [",cc"] = { ":Camel", desc = "To Camel Case" }, - [",cp"] = { ":CamelB", desc = "To Pascal Case" }, - [",ck"] = { ":Kebab", desc = "To Kebab Case" }, - [",ce"] = { ":Screm", desc = "To Screm Case" }, - }, + -- [",j"] = { name = " Jest Tests" }, + -- [",jr"] = { function() require("jester").run() end, desc = "Run test under cursor" }, + -- [",jf"] = { function() require("jester").run_file() end, desc = "Run tests for file" }, + -- [",jl"] = { function() require("jester").run_last() end, desc = "Run last ran test" }, + -- ["lz"] = { ":LspRestart", desc = "Restart LSP Server" }, + }, + v = { + ["y"] = { '"*y', desc = "Copy to system clipboard" }, + ["p"] = { '"*p', desc = "Paste from system clipboard" }, + ["J"] = { ":m '>+1gv=gv", desc = "Visually move block down"}, + ["K"] = { ":m '<-2gv=gv", desc = "Visually move block up"}, + }, + i = { + [""] = { "", desc = "Up" }, + [""] = { "", desc = "Down" }, + [""] = { "", desc = "Left" }, + [""] = { "", desc = "Right" }, + [""] = { "", desc = "End" }, + [""] = { "", desc = "Home" }, + }, + c = { + [""] = { "", desc = "Left" }, + [""] = { "", desc = "Down" }, + [""] = { "", desc = "Up" }, + [""] = { "", desc = "Right" }, + [""] = { "", desc = "End" }, + [""] = { "", desc = "Home" }, + }, x = { - ["∆"] = { - cmd = ":m '>+1gv=gv", - desc = "Move the selected text up", - }, - ["˚"] = { - desc = "Move the selected text down", - cmd = ":m '<-2gv=gv", - }, + ["p"] = { '"_dP', desc = "Paste w/o copying replaced content" }, }, - i = { - [""] = { "", desc = "Up" }, - [""] = { "", desc = "Down" }, - [""] = { "", desc = "Left" }, - [""] = { "", desc = "Right" }, - }, - c = { - [""] = { "", desc = "Left" }, - [""] = { "", desc = "Down" }, - [""] = { "", desc = "Up" }, - [""] = { "", desc = "Right" }, - }, -} +}) -for _, file in ipairs(vim.fn.readdir(vim.fn.stdpath('config')..'/lua/user', [[v:val =~ '\.lua$']])) do - local uplugin = require('user.'..file:gsub('%.lua$', '')) - -- if (uplugin[1] ~= nil) then - if (uplugin.mappings ~= nil) then - for mode, keymaps in pairs(uplugin.mappings) do - -- Add new mode if not already existing - if (mappings[mode] == nil) then - mappings[mode] = {} - end - - for key, value in pairs(keymaps) do - mappings[mode][key] = value; - end - end - end - -- end -end - -local M = {} -local which_key_queue = nil -function M.which_key_register() - if which_key_queue then - local wk_avail, wk = pcall(require, "which-key") - if wk_avail then - for mode, registration in pairs(which_key_queue) do - wk.register(registration, { mode = mode }) - end - which_key_queue = nil - end - end -end - -function set_mappings(map_table, base) - -- iterate over the first keys for each mode - base = base or {} - for mode, maps in pairs(map_table) do - -- iterate over each keybinding set in the current mode - for keymap, options in pairs(maps) do - -- build the options for the command accordingly - if options then - local cmd = options - local keymap_opts = base - if type(options) == "table" then - cmd = options[1] - keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options) - keymap_opts[1] = nil - end - if not cmd or keymap_opts.name then -- if which-key mapping, queue it - if not which_key_queue then which_key_queue = {} end - if not which_key_queue[mode] then which_key_queue[mode] = {} end - which_key_queue[mode][keymap] = keymap_opts - else -- if not which-key mapping, set it - vim.keymap.set(mode, keymap, cmd, keymap_opts) - end - end - end - end - if package.loaded["which-key"] then M.which_key_register() end -- if which-key is loaded already, register -end - -set_mappings(mappings); - -return M diff --git a/lua/lsp.lua b/lua/lsp.lua new file mode 100644 index 0000000..b3b8641 --- /dev/null +++ b/lua/lsp.lua @@ -0,0 +1,21 @@ +local lsp = require('lsp-zero').preset({}) + +lsp.on_attach(function(client, bufnr) + lsp.default_keymaps({buffer = bufnr}) +end) + +lsp.ensure_installed({ + "tsserver", + "eslint", + "lua_ls", + "rust_analyzer", + "cssls", + "cssmodules_ls", + "pyright", +}) + +-- (Optional) Configure lua language server for neovim +require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls()) + +lsp.setup() + diff --git a/lua/options.lua b/lua/options.lua index 469f385..006b2ae 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -1,20 +1,42 @@ -- allow use of system keyboard vim.opt.clipboard = "unnamedplus" + -- allow use of mouse vim.opt.mouse = 'a' + -- line numbering, relative vim.opt.number = true vim.wo.number = true vim.wo.relativenumber = true + -- Highlights the results of previous search, which is annoying when we are done searching vim.opt.hlsearch = false + -- Wrap lines in files vim.opt.wrap = true + -- preseve indentation of virtual wrapped lines vim.opt.breakindent = true + +-- be smart with indents +vim.opt.smartindent = true + -- set tab length vim.opt.tabstop = 2; +vim.opt.softtabstop = 2; vim.opt.shiftwidth = 2; +vim.opt.expandtab = true + +-- Dont use swap files, use undotree +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv('HOME') .. '/.vim/undodir' +vim.opt.undofile = true + +-- Search settings +vim.opt.hlsearch = true +vim.opt.incsearch = true + -- split to the right or below always vim.opt.splitbelow = true vim.opt.splitright = true diff --git a/lua/plugins/README.md b/lua/plugins/README.md new file mode 100644 index 0000000..fc97816 --- /dev/null +++ b/lua/plugins/README.md @@ -0,0 +1,15 @@ +# Plugins to look into +- https://github.com/andythigpen/nvim-coverage +- https://github.com/lukas-reineke/indent-blankline.nvim +- https://github.com/johmsalas/text-case.nvim +- gitsigns? +- casing plugins? + [","] = { name = " Misc Tools" }, + [",c"] = { name = " Casing" }, + [",cs"] = { ":Snek", desc = "To Snek Case" }, + [",cc"] = { ":Camel", desc = "To Camel Case" }, + [",cp"] = { ":CamelB", desc = "To Pascal Case" }, + [",ck"] = { ":Kebab", desc = "To Kebab Case" }, + [",ce"] = { ":Screm", desc = "To Screm Case" }, +- https://github.com/tpope/vim-fugitive + diff --git a/lua/user/auto-save.lua b/lua/plugins/auto-save.lua similarity index 100% rename from lua/user/auto-save.lua rename to lua/plugins/auto-save.lua diff --git a/lua/user/http_rest.lua b/lua/plugins/http_rest.lua similarity index 56% rename from lua/user/http_rest.lua rename to lua/plugins/http_rest.lua index 4b11dfc..87cd26b 100644 --- a/lua/user/http_rest.lua +++ b/lua/plugins/http_rest.lua @@ -3,9 +3,7 @@ return { commit = "d8dc204e9f6fd930d9d1d709f0d19138f804431a", event = "BufEnter *.http", requires = { "nvim-lua/plenary.nvim" }, - mappings = { - n = { - ["r"] = { function() require("rest-nvim").run() end, desc = "Send http request" }, - } - }, + keys = { + { "r", function() require("rest-nvim").run() end, desc = "Send http request" } + } } diff --git a/lua/plugins/layout-side-bar_neo-tree.lua b/lua/plugins/layout-side-bar_neo-tree.lua new file mode 100644 index 0000000..1211582 --- /dev/null +++ b/lua/plugins/layout-side-bar_neo-tree.lua @@ -0,0 +1,41 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + commit = "e5594d53986b34e584e8afe2ea6ad99d6f6d2105", + dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" }, + cmd = "Neotree", + init = function() vim.g.neo_tree_remove_legacy_commands = true end, + pin = true, + tag = '2.56', + opts = { + auto_clean_after_session_restore = true, + close_if_last_window = true, + sources = { "filesystem" }, + filesystem = { + follow_current_file = true, + group_empty_dirs = true, + filtered_items = { + visible = true, + hide_dotfiles = false, + hide_gitignored = false, + hide_by_name = { + ".DS_Store", + }, + }, + }, + nesting_rules = { + ["ts"] = { ".cjs", ".cjs.map", ".d.ts", ".d.ts.map", ".js", ".js.map", ".mjs", ".mjs.map", ".test.ts" }, + ["tsx"] = { ".d.ts", ".d.ts.map", ".js;", ".js.map;", ".jsx;", ".jsx.map;", ".module.scss;", ".svg" }, + ["scss"] = { ".css", ".css.map" }, + }, + }, + keys = { + { "e", "Neotree toggle", desc = "Toggle Explorer" }, + { "o",function() + if vim.bo.filetype == "neo-tree" then + vim.cmd.wincmd "p" + else + vim.cmd.Neotree "focus" + end + end , desc = "Toggle Explorer Focus" }, + }, +} diff --git a/lua/plugins/lsp-zero.lua b/lua/plugins/lsp-zero.lua new file mode 100644 index 0000000..55c2e08 --- /dev/null +++ b/lua/plugins/lsp-zero.lua @@ -0,0 +1,20 @@ +return { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + dependencies = { + -- LSP Support + {'neovim/nvim-lspconfig'}, -- Required + { -- Optional + 'williamboman/mason.nvim', + build = function() + pcall(vim.cmd, 'MasonUpdate') + end, + }, + {'williamboman/mason-lspconfig.nvim'}, -- Optional + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, -- Required + {'hrsh7th/cmp-nvim-lsp'}, -- Required + {'L3MON4D3/LuaSnip'}, -- Required +}, +} diff --git a/lua/user/markdown-preview_glow.lua b/lua/plugins/markdown_glow.lua similarity index 54% rename from lua/user/markdown-preview_glow.lua rename to lua/plugins/markdown_glow.lua index aaa3ff5..53e1ea2 100644 --- a/lua/user/markdown-preview_glow.lua +++ b/lua/plugins/markdown_glow.lua @@ -6,10 +6,8 @@ return { default_type = "keep", }, cmd = "Glow", - mappings = { - n = { - ["m"] = { "", name = " Markdown" }, - ["mp"] = { ":Glow ", desc = "Markdown preview" }, - } - } + keys = { + { "m","", desc = " Markdown" }, + { "mp",":Glow ", desc = "Markdown preview" }, + }, } diff --git a/lua/plugins/open-github.lua b/lua/plugins/open-github.lua new file mode 100644 index 0000000..56ed205 --- /dev/null +++ b/lua/plugins/open-github.lua @@ -0,0 +1,8 @@ +return { + "Almo7aya/openingh.nvim", + commit = "374c081409dc238018cd986410f16190d8f9f680", + event = "BufEnter", + keys = { + { "gf", ":OpenInGHFile ", desc = "Open in git" } + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..8a4506c --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,18 @@ +return { + "nvim-telescope/telescope.nvim", + tag = '0.1.1', + dependencies = { + { "nvim-lua/plenary.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable "make" == 1, build = "make" }, + }, + cmd = "Telescope", + keys = { + { "f", "", desc = "Find ..." }, + { "ff", function() require('telescope.builtin').find_files() end, desc = "Find Files" }, + { "fg", function() require('telescope.builtin').git_files() end, desc = "Find Git only Files" }, + { "fw", function() require('telescope.builtin').live_grep() end, desc = "Find Words" }, + { "fc", function() require('telescope.builtin').commands() end, desc = "Find Commands" }, + { "fk", function() require('telescope.builtin').keymaps() end, desc = "Find Commands" }, + }, + opts = {}, +} diff --git a/lua/user/theme_material.lua b/lua/plugins/theme_material.lua similarity index 100% rename from lua/user/theme_material.lua rename to lua/plugins/theme_material.lua diff --git a/lua/user/syntax-highlighting_treesitter.lua b/lua/plugins/treesitter.lua similarity index 98% rename from lua/user/syntax-highlighting_treesitter.lua rename to lua/plugins/treesitter.lua index 5f5b2fc..e55a071 100644 --- a/lua/user/syntax-highlighting_treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -60,7 +60,7 @@ return { "vue", "yaml", }, - -- auto_install = true, + auto_install = true, highlight = { enable = true, disable = function(_, bufnr) return vim.api.nvim_buf_line_count(bufnr) > 10000 end, diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua new file mode 100644 index 0000000..97e36fd --- /dev/null +++ b/lua/plugins/undotree.lua @@ -0,0 +1,9 @@ +return { + "mbbill/undotree", + commit = "485f01efde4e22cb1ce547b9e8c9238f36566f21", + event = "BufEnter", + keys = { + { "u", vim.cmd.UndotreeToggle, desc = "Undo Tree Toggle" }, + }, +} + diff --git a/lua/user/util-plenary.lua b/lua/plugins/util-plenary.lua similarity index 100% rename from lua/user/util-plenary.lua rename to lua/plugins/util-plenary.lua diff --git a/lua/user/util_which-key.lua b/lua/plugins/util_which-key.lua similarity index 100% rename from lua/user/util_which-key.lua rename to lua/plugins/util_which-key.lua diff --git a/lua/user/autoswap.lua b/lua/plugins_disabled/autoswap.lua similarity index 50% rename from lua/user/autoswap.lua rename to lua/plugins_disabled/autoswap.lua index 22ed228..b024cf3 100644 --- a/lua/user/autoswap.lua +++ b/lua/plugins_disabled/autoswap.lua @@ -1,3 +1,5 @@ +-- Disabled this because of undotree, turniung off swap files entirely, adding in undo tree history instead + return { "gioele/vim-autoswap", commit = "e587e4b14a605d8921942ba65a37583813289272", diff --git a/lua/user/ide_lsp_mason.lua b/lua/plugins_disabled/ide_lsp_mason.lua similarity index 86% rename from lua/user/ide_lsp_mason.lua rename to lua/plugins_disabled/ide_lsp_mason.lua index 834c018..983b431 100644 --- a/lua/user/ide_lsp_mason.lua +++ b/lua/plugins_disabled/ide_lsp_mason.lua @@ -70,24 +70,8 @@ return { "MasonUninstall", "MasonUninstallAll", "MasonLog", - "MasonUpdate", -- AstroNvim extension here as well - "MasonUpdateAll", -- AstroNvim specific }, - opts = { - ui = { - icons = { - package_installed = "✓", - package_uninstalled = "✗", - package_pending = "⟳", - }, - }, - }, - --config = function(_, opts) - --require('mason').setup(opts) - --for _, plugin in ipairs { "mason-lspconfig", "mason-null-ls", "mason-nvim-dap" } do - -- pcall(require, plugin) - --end - --end + opts = {} }, { "williamboman/mason-lspconfig.nvim", diff --git a/lua/user/layout-msg-popups_noice.lua b/lua/plugins_disabled/layout-msg-popups_noice.lua similarity index 100% rename from lua/user/layout-msg-popups_noice.lua rename to lua/plugins_disabled/layout-msg-popups_noice.lua diff --git a/lua/user/rust-tools.lua b/lua/plugins_disabled/rust-tools.lua similarity index 100% rename from lua/user/rust-tools.lua rename to lua/plugins_disabled/rust-tools.lua diff --git a/lua/tools/init.lua b/lua/tools/init.lua new file mode 100644 index 0000000..2c8ba37 --- /dev/null +++ b/lua/tools/init.lua @@ -0,0 +1,8 @@ +-- Autoload all files in this tools dir, minus this init again +for _, file in ipairs(vim.fn.readdir(vim.fn.stdpath('config')..'/lua/tools', [[v:val =~ '\.lua$']])) do + if file ~= "init.lua" then + local tool = string.sub(file, 0, -5) + require('tools.' .. tool) + end +end + diff --git a/lua/tools/scratch-files.lua b/lua/tools/scratch-files.lua new file mode 100644 index 0000000..f4f9ce6 --- /dev/null +++ b/lua/tools/scratch-files.lua @@ -0,0 +1,36 @@ +-- Scratch files +local scratch = function(extension) + os.execute "mkdir -p ~/dev/scratches/" + local date = os.date "%Y-%m-%dT%H:%M:%S" + local filepath = "~/dev/scratches/scratch_" .. date .. extension + vim.cmd("execute 'edit " .. filepath .. "'") +end + +require('util').keymaps({ + n = { + ["fsw"] = { + function() + require("telescope.builtin").live_grep { + search_dirs = { "~/dev/scratches/" }, + } + end, + desc = "Find Words in Scratches", + }, + ["fsf"] = { + function() + require("telescope.builtin").find_files{ + search_dirs = { "~/dev/scratches/" }, + } + end, + desc = "Find Scratches", + }, + ["s"] = { "", desc = " Scratch File" }, + ["ss"] = { function() scratch ".txt" end, desc = "New text scratch file" }, + ["sn"] = { function() scratch ".json" end, desc = "New json scratch file" }, + ["sq"] = { function() scratch ".sql" end, desc = "New sql scratch file" }, + ["st"] = { function() scratch ".ts" end, desc = "New ts scratch file" }, + ["sb"] = { function() scratch ".sh" end, desc = "New shell scratch file" }, + ["sj"] = { function() scratch ".js" end, desc = "New js scratch file" }, + } +}) + diff --git a/lua/user/README.md b/lua/user/README.md deleted file mode 100644 index 8be4273..0000000 --- a/lua/user/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Plugins to look into -- https://github.com/andythigpen/nvim-coverage -- https://github.com/lukas-reineke/indent-blankline.nvim -- https://github.com/johmsalas/text-case.nvim - diff --git a/lua/user/gitsigns.lua b/lua/user/gitsigns.lua deleted file mode 100644 index 82f901c..0000000 --- a/lua/user/gitsigns.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - "lewis6991/gitsigns.nvim", - commit = "c18b7ca0b5b50596722f3a1572eb9b8eb520c0f1", - event = "User AstroGitFile", - opts = { - signs = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "▎" }, - topdelete = { text = "󰐊" }, - changedelete = { text = "▎" }, - untracked = { text = "▎" }, - }, - }, -} diff --git a/lua/user/layout-side-bar_neo-tree.lua b/lua/user/layout-side-bar_neo-tree.lua deleted file mode 100644 index 59a79b1..0000000 --- a/lua/user/layout-side-bar_neo-tree.lua +++ /dev/null @@ -1,46 +0,0 @@ -return { - "nvim-neo-tree/neo-tree.nvim", - commit = "e5594d53986b34e584e8afe2ea6ad99d6f6d2105", - dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" }, - cmd = "Neotree", - init = function() vim.g.neo_tree_remove_legacy_commands = true end, - pin = true, - tag = '2.56', - opts = { - auto_clean_after_session_restore = true, - close_if_last_window = true, - sources = { "filesystem" }, - filesystem = { - follow_current_file = true, - group_empty_dirs = true, - filtered_items = { - visible = true, - hide_dotfiles = false, - hide_gitignored = false, - hide_by_name = { - ".DS_Store", - }, - }, - }, - nesting_rules = { - ["ts"] = { ".cjs", ".cjs.map", ".d.ts", ".d.ts.map", ".js", ".js.map", ".mjs", ".mjs.map", ".test.ts" }, - ["tsx"] = { ".d.ts", ".d.ts.map", ".js;", ".js.map;", ".jsx;", ".jsx.map;", ".module.scss;", ".svg" }, - ["scss"] = { ".css", ".css.map" }, - }, - }, - mappings = { - n = { - ["e"] = { "Neotree toggle", desc = "Toggle Explorer" }, - ["o"] = { - function() - if vim.bo.filetype == "neo-tree" then - vim.cmd.wincmd "p" - else - vim.cmd.Neotree "focus" - end - end, - desc = "Toggle Explorer Focus", - }, - } - } -} diff --git a/lua/user/layout_telescope.lua b/lua/user/layout_telescope.lua deleted file mode 100644 index a25a917..0000000 --- a/lua/user/layout_telescope.lua +++ /dev/null @@ -1,42 +0,0 @@ -return { - "nvim-telescope/telescope.nvim", - commit = "40c31fdde93bcd85aeb3447bb3e2a3208395a868", - dependencies = { - { "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable "make" == 1, build = "make" }, - }, - cmd = "Telescope", - opts = function() - local actions = require "telescope.actions" - local get_icon = require("astronvim.utils").get_icon - return { - defaults = { - prompt_prefix = string.format("%s ", get_icon "Search"), - selection_caret = string.format("%s ", get_icon "Selected"), - path_display = { "truncate" }, - sorting_strategy = "ascending", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.55, - }, - vertical = { - mirror = false, - }, - width = 0.87, - height = 0.80, - preview_cutoff = 120, - }, - - mappings = { - i = { - [""] = actions.cycle_history_next, - [""] = actions.cycle_history_prev, - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - }, - n = { ["q"] = actions.close }, - }, - }, - } - end, -} diff --git a/lua/user/open-github.lua b/lua/user/open-github.lua deleted file mode 100644 index b42c6af..0000000 --- a/lua/user/open-github.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - "Almo7aya/openingh.nvim", - commit = "374c081409dc238018cd986410f16190d8f9f680", - event = "User AstroFile", - mappings = { - n = { - ["gf"] = { ":OpenInGHFile ", desc = "Open in github" }, - }, - }, -} diff --git a/lua/user/welcome-screen_alpha.lua b/lua/user/welcome-screen_alpha.lua deleted file mode 100644 index 7fc725a..0000000 --- a/lua/user/welcome-screen_alpha.lua +++ /dev/null @@ -1,67 +0,0 @@ -return { - "goolord/alpha-nvim", - commit = "1838ae926e8d49fe5330d1498ee8289ae2c340bc", -- May 22, 2023 - cmd = "Alpha", - opts = function() - local dashboard = require "alpha.themes.dashboard" - dashboard.section.header.val = { - " ▒▒▒▒▒▒ ", - " ▒▒▓▓▓▓▒▒▒▒▒▒▒▒ ", - " ▓▓▒▒▒▒▒▒▒▒░░ ▓▓ ", - " ▒▒▓▓▓▓▓▓▓▓▓▓▓▓░░░░ ▒▒▒▒▓▓▒▒▒▒ ", - " ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░ ▒▒▓▓▓▓▓▓▒▒▒▒▒▒ ", - " ▓▓▓▓▓▓▓▓▓▓ ██▓▓▓▓▓▓▓▓ ▒▒▒▒ ██ ", - " ██▓▓▓▓ ▓▓████▓▓▓▓ ▒▒▒▒▒▒▒▒▓▓██▓▓ ▒▒▒▒▒▒ ", - " ██ ██ ▒▒▒▒▒▒░░░░ ▒▒▒▒▒▒ ▓▓▓▓▓▓ ▒▒▒▒▓▓▓▓██▓▓▒▒▒▒██▒▒▒▒▒▒▒▒▒▒ ", - " ▒▒▒▒▓▓ ▒▒▒▒▓▓▓▓▓▓▓▓▓▓▒▒░░ ░░▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒ ▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒ ██▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒ ▓▓ ▒▒ ", - " ▒▒▓▓▓▓██▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ ▒▒▓▓▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░██▓▓ ██▓▓ ▒▒ ▒▒▒▒▓▓▒▒▒▒▓▓ ▒▒ ▒▒ ", - " ▒▒▓▓▓▓▓▓██▓▓▓▓▓▓████▓▓▓▓▓▓▓▓▓▓ ▒▒ ▒▒▒▒▒▒▒▒▒▒ ▓▓▓▓▓▓▓▓▓▓██▓▓▓▓██▓▓▓▓▓▓▓▓ ████▓▓▓▓▓▓▒▒ ██▒▒██▒▒▓▓▓▓▒▒▓▓▓▓▒▒▓▓▓▓██▓▓ ", - " ▓▓▓▓▓▓▓▓██▓▓██ ████ ▓▓▓▓▓▓▓▓ ▒▒▒▒▒▒▒▒▒▒ ▒▒▓▓▒▒ ▒▒▒▒▒▒ ░░██ ▓▓▓▓▓▓▓▓██▓▓ ▓▓██▓▓ ▓▓ ▒▒▒▒▒▒▒▒▒▒▒▒ ██▓▓ ██▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▒▒▓▓▓▓▒▒▓▓", - " ░░▓▓▓▓░░░░████████░░ ░░▓▓▓▓░░ ░░▒▒▒▒▒▒▒▒░░▒▒▓▓▒▒░░▒▒▒▒░░ ░░██ ▓▓░░▓▓░░░░▓▓ ▓▓░░▓▓▒▒▓▓ ▒▒▓▓▓▓▓▓▓▓▒▒▒▒░░▒▒▓▓░░ ██▓▓▓▓▓▓██▓▓██░░██▓▓▓▓▓▓▒▒▓▓", - " ░░░░ ░░██▓▓░░ ░░░░ ░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ ░░██ ▓▓ ▓▓ ▓▓ ░░ ▓▓▓▓░░░░ ░░░░░░░░░░▓▓▓▓▒▒██░░ ░░░░░░ ▒▒░░▓▓▓▓▓▓██░░██▒▒░░▓▓██▓▓▓▓░░", - " ██▓▓ ▒▒ ▒▒▒▒▒▒▒▒ ▓▓▓▓▒▒▒▒▒▒▒▒ ░░ ▓▓ ▓▓ ██ ▓▓▓▓▓▓ ▓▓ ▓▓██▓▓▓▓ ▒▒▒▒▒▒▒▒▒▒ ██░░██ ██▓▓████ ░░ ", - " ██▓▓ ░░ ▒▒░░▓▓░░ ▓▓▒▒░░▒▒░░▒▒ ▓▓ ██ ░░ ▒▒▓▓░░▓▓ ▓▓ ░░░░████▒▒▓▓▓▓▓▓▒▒▒▒░░ ░░ ░░ ██▓▓░░░░ ", - " ██▓▓ ▒▒▒▒▒▒ ▓▓ ██▓▓ ██ ██ ████▓▓██ ▓▓ ▓▓▒▒ ████ ", - " ▓▓▓▓██▓▓▓▓▓▓ ▓▓▒▒ ▓▓▓▓ ██▓▓ ▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓ ", - " ████▓▓██████▓▓▓▓████ ▓▓▓▓▓▓▓▓▓▓▒▒▓▓▓▓██▓▓ ████████▓▓▓▓████████ ██████▓▓████ ██▒▒▓▓▓▓██████▓▓▓▓▒▒██ ", - " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▓▓▓▓▓▓▓▓ ▓▓▒▒▓▓██████▓▓▓▓▓▓▓▓▒▒██ ▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓ ▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒██ ", - " ██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒ ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒ ██▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██ ", - " ▓▓▓▓▓▓▓▓▒▒▓▓▓▓▓▓▓▓▒▒▒▒▓▓ ▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▓▓ ██▓▓▒▒▒▒▓▓▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒██ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒██ ", - " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▒▒▒▒░░░░░░░░░░░░░░░░▓▓ ░░██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██ ▓▓▓▓▓▓▒▒▒▒▒▒▓▓▒▒▒▒▓▓ ░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ", - " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░████████████████████░░ ██▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░ ░░ ████▓▓▓▓▓▓▓▓▓▓████░░", - "", - " ██╗ ██████╗ ███████╗██╗ ██╗", - " ██║██╔═══██╗██╔════╝██║ ██║", - " ██║██║ ██║███████╗███████║", - " ██ ██║██║ ██║╚════██║██╔══██║", - " ╚█████╔╝╚██████╔╝███████║██║ ██║", - " ╚════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝", - } - dashboard.section.header.opts.hl = "DashboardHeader" - - dashboard.section.buttons.val = { - } - -dashboard.config.layout[1].val = vim.fn.max { 2, vim.fn.floor(vim.fn.winheight(0) * 0.2) } - dashboard.config.layout[3].val = 5 - dashboard.config.opts.noautocmd = true - - return dashboard - end, - config = function(_, opts) - require("alpha").setup(opts.config) - - vim.api.nvim_create_autocmd("User", { - pattern = "LazyVimStarted", - desc = "Add Alpha dashboard footer", - once = true, - callback = function() - local stats = require("lazy").stats() - local ms = math.floor(stats.startuptime * 100 + 0.5) / 100 - opts.section.footer.val = - { " ", " ", " ", "Loaded " .. stats.count .. " plugins  in " .. ms .. "ms" } - pcall(vim.cmd.AlphaRedraw) - end, - }) -end, -} diff --git a/lua/util.lua b/lua/util.lua new file mode 100644 index 0000000..173cc2f --- /dev/null +++ b/lua/util.lua @@ -0,0 +1,24 @@ +local M = {}; + +function M.keymaps(mappings) + for mode, maps in pairs(mappings) do + for keymap, options in pairs(maps) do + if options then + local cmd = options + local keymap_opts = {} + if type(options) == "table" then + cmd = options[1] + keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options) + keymap_opts[1] = nil + end + + if mode and keymap and cmd and keymap_opts then + vim.keymap.set(mode, keymap, cmd, keymap_opts) + end + end + end + end +end + +return M +