From 452abf20295dc83355292adccf49f21218637a4f Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Wed, 5 Jul 2023 10:06:18 -0500 Subject: [PATCH] formatting --- init.lua | 35 ++- lua/autocommands.lua | 36 +-- lua/keymaps.lua | 133 ++++---- lua/options.lua | 6 +- lua/plugins/README.md | 16 +- lua/plugins/auto-save.lua | 29 +- lua/plugins/colorpicker_ccc.lua | 8 +- lua/plugins/comments.lua | 17 +- lua/plugins/http_rest.lua | 16 +- lua/plugins/lsp.lua | 370 +++++++++++------------ lua/plugins/markdown_glow.lua | 16 +- lua/plugins/neo-tree.lua | 25 +- lua/plugins/null-ls.lua | 13 +- lua/plugins/open-github.lua | 6 +- lua/plugins/telescope.lua | 96 ++++-- lua/plugins/theme_material.lua | 10 +- lua/plugins/treesitter.lua | 158 +++++----- lua/plugins/undotree.lua | 3 +- lua/plugins/util_plenary.lua | 1 - lua/plugins_disabled/cmp.lua | 10 +- lua/plugins_disabled/lsp-zero.lua | 63 ++-- lua/plugins_disabled/tabstops_sleuth.lua | 2 +- lua/tools/init.lua | 5 +- lua/tools/scratch-files.lua | 74 +++-- lua/util.lua | 23 +- 25 files changed, 635 insertions(+), 536 deletions(-) diff --git a/init.lua b/init.lua index e55447d..90987f8 100644 --- a/init.lua +++ b/init.lua @@ -1,29 +1,28 @@ -require "options" -require "keymaps" +require("options") +require("keymaps") local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - local output = vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) - if vim.api.nvim_get_vvar "shell_error" ~= 0 then - vim.api.nvim_err_writeln("Error cloning lazy.nvim repository...\n\n" .. output) - end + local output = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) + if vim.api.nvim_get_vvar("shell_error") ~= 0 then + vim.api.nvim_err_writeln("Error cloning lazy.nvim repository...\n\n" .. output) + end end vim.opt.rtp:prepend(lazypath) require("lazy").setup("plugins", { change_detection = { enabled = false, - } + }, }) -vim.cmd 'colorscheme material' -require "tools" -require "autocommands" - +vim.cmd("colorscheme material") +require("tools") +require("autocommands") diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 195427c..d62d16f 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -1,5 +1,7 @@ function isEmpty() - return vim.api.nvim_buf_get_name(0) == "" or vim.fn.filereadable(vim.api.nvim_buf_get_name(0)) == 0 or vim.fn.line('$') == 1 and vim.fn.col('$') == 1 + return vim.api.nvim_buf_get_name(0) == "" + or vim.fn.filereadable(vim.api.nvim_buf_get_name(0)) == 0 + or vim.fn.line("$") == 1 and vim.fn.col("$") == 1 end --vim.api.nvim_create_autocmd({ "VimEnter" }, { @@ -10,25 +12,25 @@ end -- end --}) -vim.api.nvim_create_autocmd('BufRead', { - pattern = ".env*", - command = "set filetype=sh" -}) - -vim.api.nvim_create_autocmd('BufRead', { - pattern = ".*rc", - command = "set filetype=sh" -}) - -vim.api.nvim_create_autocmd('BufRead', { - pattern = "Dockerfile.*", - command = "set filetype=dockerfile" +vim.api.nvim_create_autocmd("BufRead", { + pattern = ".env*", + command = "set filetype=sh", }) vim.api.nvim_create_autocmd("BufRead", { - callback = function() - vim.cmd.CccHighlighterEnable() - end, + pattern = ".*rc", + command = "set filetype=sh", +}) + +vim.api.nvim_create_autocmd("BufRead", { + pattern = "Dockerfile.*", + command = "set filetype=dockerfile", +}) + +vim.api.nvim_create_autocmd("BufRead", { + callback = function() + vim.cmd.CccHighlighterEnable() + end, }) --vim.api.nvim_create_autocmd('BufEnter', { diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 9380149..e9dad76 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -11,63 +11,78 @@ vim.g.maplocalleader = " " -- term_mode = "t", -- command_mode = "c", -require('util').keymaps({ - n = { - [";"] = { ":", desc = "No shift command mode" }, - ["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" }, - ["Q"] = { ":qa", desc = "Quit all" }, - ["J"] = { "mzJ`z", desc = "Move line below onto this line" }, - -- window navigation - [""] = { "h", desc = "Move window left current" }, - [""] = { "j", desc = "Move window below current" }, - [""] = { "k", desc = "Move window above current" }, - [""] = { "l", desc = "Move window right current" }, - -- reformat LSP - ["lf"] = { function() vim.lsp.buf.format() end, desc = "Reformat file" }, - ["ld"] = { function() vim.diagnostic.open_float() end, desc = "Show diagnostic message"}, - ["ll"] = { function() vim.diagnostic.setloclist() end, desc = "Show diagnostic list"}, - ["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 = { - ["p"] = { '"_dP', desc = "Paste w/o copying replaced content" }, - ["h//g', desc = "Replace current selection"}, - }, - t = { - [""] = { "", desc = "Escape the terminal" }, - }, +require("util").keymaps({ + n = { + [";"] = { ":", desc = "No shift command mode" }, + ["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" }, + ["a"] = { "ggVG", desc = "Select all" }, + ["w"] = { "w", desc = "Save" }, + ["q"] = { "confirm q", desc = "Quit" }, + ["cq"] = { "bd", desc = "Close current buffer" }, + ["|"] = { "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" }, + ["Q"] = { ":qa", desc = "Quit all" }, + ["J"] = { "mzJ`z", desc = "Move line below onto this line" }, + -- window navigation + [""] = { "h", desc = "Move window left current" }, + [""] = { "j", desc = "Move window below current" }, + [""] = { "k", desc = "Move window above current" }, + [""] = { "l", desc = "Move window right current" }, + -- reformat LSP + ["lf"] = { + function() + vim.lsp.buf.format() + end, + desc = "Reformat file", + }, + ["ld"] = { + function() + vim.diagnostic.open_float() + end, + desc = "Show diagnostic message", + }, + ["ll"] = { + function() + vim.diagnostic.setloclist() + end, + desc = "Show diagnostic list", + }, + ["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 = { + ["p"] = { '"_dP', desc = "Paste w/o copying replaced content" }, + ["h//g', desc = "Replace current selection" }, + }, + t = { + [""] = { "", desc = "Escape the terminal" }, + }, }) - - diff --git a/lua/options.lua b/lua/options.lua index 9510ec1..24cd8c1 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -43,6 +43,6 @@ vim.opt.splitright = true -- Set completeopt to have a better completion experience vim.o.completeopt = "menuone,noselect" -vim.diagnostic.config{ - float={border="single"} -} +vim.diagnostic.config({ + float = { border = "single" }, +}) diff --git a/lua/plugins/README.md b/lua/plugins/README.md index 1e40d73..ccea1b4 100644 --- a/lua/plugins/README.md +++ b/lua/plugins/README.md @@ -1,4 +1,5 @@ # Plugins to look into + - https://github.com/lvimuser/lsp-inlayhints.nvim/tree/anticonceal - https://github.com/theHamsta/nvim-dap-virtual-text/tree/inline-text - https://github.com/andythigpen/nvim-coverage @@ -6,13 +7,13 @@ - 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" }, + [","] = { 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 - https://github.com/folke/noice.nvim - greg's: https://github.com/gblock0/dotfiles/blob/master/nvim/.config/nvim/lua/gb/plugins.lua @@ -21,4 +22,3 @@ - https://github.com/numToStr/Comment.nvim - https://github.com/windwp/nvim-autopairs - https://github.com/lukas-reineke/indent-blankline.nvim - diff --git a/lua/plugins/auto-save.lua b/lua/plugins/auto-save.lua index 73ba86b..a9f3ccb 100644 --- a/lua/plugins/auto-save.lua +++ b/lua/plugins/auto-save.lua @@ -1,15 +1,18 @@ return { - "Pocco81/auto-save.nvim", - event = "BufEnter", - opts = { - trigger_events = { "InsertLeave", "TextChanged", "TextChangedI", "BufLeave" }, - condition = function (buf) - local disallowed_filetypes = {"TelescopePrompt"} - local utils = require('auto-save.utils.data') - if vim.fn.getbufvar(buf, "&modifiable") == 1 and utils.not_in(vim.fn.getbufvar(buf, "&filetype"), disallowed_filetypes) then - return true - end - return false - end - } + "Pocco81/auto-save.nvim", + event = "BufEnter", + opts = { + trigger_events = { "InsertLeave", "TextChanged", "TextChangedI", "BufLeave" }, + condition = function(buf) + local disallowed_filetypes = { "TelescopePrompt" } + local utils = require("auto-save.utils.data") + if + vim.fn.getbufvar(buf, "&modifiable") == 1 + and utils.not_in(vim.fn.getbufvar(buf, "&filetype"), disallowed_filetypes) + then + return true + end + return false + end, + }, } diff --git a/lua/plugins/colorpicker_ccc.lua b/lua/plugins/colorpicker_ccc.lua index cc44d02..700c882 100644 --- a/lua/plugins/colorpicker_ccc.lua +++ b/lua/plugins/colorpicker_ccc.lua @@ -1,7 +1,7 @@ return { - "uga-rosa/ccc.nvim", - event = "BufRead", - keys = { - { "cp", ":CccPick ", desc = "Color Picker" } + "uga-rosa/ccc.nvim", + event = "BufRead", + keys = { + { "cp", ":CccPick ", desc = "Color Picker" }, }, } diff --git a/lua/plugins/comments.lua b/lua/plugins/comments.lua index 7a1528a..7ce9f0c 100644 --- a/lua/plugins/comments.lua +++ b/lua/plugins/comments.lua @@ -1,10 +1,15 @@ vim.g.NERDCreateDefaultMappings = 0 -vim.cmd('filetype plugin on') +vim.cmd("filetype plugin on") return { - "preservim/nerdcommenter", - keys = { - { "/", ':call nerdcommenter#Comment(0, "toggle")', desc = "Toggle comments on selection" }, - { "/", ':call nerdcommenter#Comment(0, "toggle")', desc = "Toggle comments on selection", mode = "v" }, - }, + "preservim/nerdcommenter", + keys = { + { "/", ':call nerdcommenter#Comment(0, "toggle")', desc = "Toggle comments on selection" }, + { + "/", + ':call nerdcommenter#Comment(0, "toggle")', + desc = "Toggle comments on selection", + mode = "v", + }, + }, } diff --git a/lua/plugins/http_rest.lua b/lua/plugins/http_rest.lua index ae81f96..04a68b8 100644 --- a/lua/plugins/http_rest.lua +++ b/lua/plugins/http_rest.lua @@ -1,8 +1,14 @@ return { - "rest-nvim/rest.nvim", - event = "BufEnter *.http", - requires = { "nvim-lua/plenary.nvim" }, + "rest-nvim/rest.nvim", + event = "BufEnter *.http", + requires = { "nvim-lua/plenary.nvim" }, keys = { - { "r", function() require("rest-nvim").run() end, desc = "Send selected http request" } - } + { + "r", + function() + require("rest-nvim").run() + end, + desc = "Send selected http request", + }, + }, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 757c6cf..7f57373 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,206 +1,206 @@ local servers = { - rust_analyzer = { - -- rust - -- to enable rust-analyzer settings visit: - -- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc - ["rust-analyzer"] = { - cargo = { - allFeatures = true, - }, - checkOnSave = { - allFeatures = true, - command = "clippy", - }, - }, - }, - tsserver = { - -- typescript/javascript - }, - pyright = { - -- python - }, - lua_ls = { - -- lua - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - }, - }, - bashls = { - -- bash - }, - cssls = { - -- css - }, - cssmodules_ls = { - -- css modules - }, - dockerls = { - -- docker - }, - docker_compose_language_service = { - -- docker compose - }, - jsonls = { - -- json - }, - marksman = { - -- markdown - }, - taplo = { - -- toml - }, - yamlls = { - -- yaml - }, - lemminx = { - -- xml - }, - rnix = { - -- Nix - }, - ansiblels = { - -- ansible - }, + rust_analyzer = { + -- rust + -- to enable rust-analyzer settings visit: + -- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + }, + checkOnSave = { + allFeatures = true, + command = "clippy", + }, + }, + }, + tsserver = { + -- typescript/javascript + }, + pyright = { + -- python + }, + lua_ls = { + -- lua + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, + bashls = { + -- bash + }, + cssls = { + -- css + }, + cssmodules_ls = { + -- css modules + }, + dockerls = { + -- docker + }, + docker_compose_language_service = { + -- docker compose + }, + jsonls = { + -- json + }, + marksman = { + -- markdown + }, + taplo = { + -- toml + }, + yamlls = { + -- yaml + }, + lemminx = { + -- xml + }, + rnix = { + -- Nix + }, + ansiblels = { + -- ansible + }, } -- LSP config -- Took lots of inspiration from this kickstart lua file: https://github.com/hjr3/dotfiles/blob/main/.config/nvim/init.lua return { - { - -- Autocompletion - "hrsh7th/nvim-cmp", - dependencies = { "hrsh7th/cmp-nvim-lsp", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip" }, - }, - { - "williamboman/mason.nvim", - cmd = { - "Mason", - "MasonUpdate", - "MasonInstall", - "MasonInstallAll", - "MasonUninstall", - "MasonUninstallAll", - "MasonLog", - }, - build = ":MasonUpdate", - opts = {}, - }, - { - "williamboman/mason-lspconfig.nvim", - }, - { "folke/neodev.nvim", opts = {} }, - { - "neovim/nvim-lspconfig", - after = { "nvim-telescope/telescope.nvim" }, - config = function() - local config = require("lspconfig") - local util = require("lspconfig/util") - local mason_lspconfig = require("mason-lspconfig") - local cmp = require("cmp") - local luasnip = require("luasnip") + { + -- Autocompletion + "hrsh7th/nvim-cmp", + dependencies = { "hrsh7th/cmp-nvim-lsp", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip" }, + }, + { + "williamboman/mason.nvim", + cmd = { + "Mason", + "MasonUpdate", + "MasonInstall", + "MasonInstallAll", + "MasonUninstall", + "MasonUninstallAll", + "MasonLog", + }, + build = ":MasonUpdate", + opts = {}, + }, + { + "williamboman/mason-lspconfig.nvim", + }, + { "folke/neodev.nvim", opts = {} }, + { + "neovim/nvim-lspconfig", + after = { "nvim-telescope/telescope.nvim" }, + config = function() + local config = require("lspconfig") + local util = require("lspconfig/util") + local mason_lspconfig = require("mason-lspconfig") + local cmp = require("cmp") + local luasnip = require("luasnip") - -- LSP - -- This function gets run when an LSP connects to a particular buffer. - local on_attach = function(client, bufnr) - local nmap = function(keys, func, desc) - if desc then - desc = "LSP: " .. desc - end + -- LSP + -- This function gets run when an LSP connects to a particular buffer. + local on_attach = function(client, bufnr) + local nmap = function(keys, func, desc) + if desc then + desc = "LSP: " .. desc + end - vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) - end + vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) + end - nmap("lr", vim.lsp.buf.rename, "[R]ename") - nmap("la", vim.lsp.buf.code_action, "Code [A]ction") + nmap("lr", vim.lsp.buf.rename, "[R]ename") + nmap("la", vim.lsp.buf.code_action, "Code [A]ction") - nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") - nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") - nmap("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation") - nmap("D", vim.lsp.buf.type_definition, "Type [D]efinition") + nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") + nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") + nmap("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation") + nmap("D", vim.lsp.buf.type_definition, "Type [D]efinition") - -- See `:help K` for why this keymap - nmap("K", vim.lsp.buf.hover, "Hover Documentation") - nmap("", vim.lsp.buf.signature_help, "Signature Documentation") + -- See `:help K` for why this keymap + nmap("K", vim.lsp.buf.hover, "Hover Documentation") + nmap("", vim.lsp.buf.signature_help, "Signature Documentation") - -- Lesser used LSP functionality - nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + -- Lesser used LSP functionality + nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") - -- disable tsserver so it does not conflict with prettier - if client.name == "tsserver" then - client.server_capabilities.document_formatting = false - end - end + -- disable tsserver so it does not conflict with prettier + if client.name == "tsserver" then + client.server_capabilities.document_formatting = false + end + end - -- nvim-cmp supports additional completion capabilities, so broadcast that to servers - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) + -- nvim-cmp supports additional completion capabilities, so broadcast that to servers + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) - -- Install servers used - mason_lspconfig.setup({ - ensure_installed = vim.tbl_keys(servers), - }) + -- Install servers used + mason_lspconfig.setup({ + ensure_installed = vim.tbl_keys(servers), + }) - local flags = { - allow_incremental_sync = true, - debounce_text_changes = 200, - } + local flags = { + allow_incremental_sync = true, + debounce_text_changes = 200, + } - mason_lspconfig.setup_handlers({ - function(server_name) - require("lspconfig")[server_name].setup({ - flags = flags, - capabilities = capabilities, - on_attach = on_attach, - settings = servers[server_name], - }) - end, - }) + mason_lspconfig.setup_handlers({ + function(server_name) + require("lspconfig")[server_name].setup({ + flags = flags, + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + }) + end, + }) - -- Completion - luasnip.config.setup({}) + -- Completion + luasnip.config.setup({}) - cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete({}), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - }, - }) - end, - }, + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete({}), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, + }) + end, + }, } diff --git a/lua/plugins/markdown_glow.lua b/lua/plugins/markdown_glow.lua index 9bd84da..0d3b225 100644 --- a/lua/plugins/markdown_glow.lua +++ b/lua/plugins/markdown_glow.lua @@ -1,12 +1,12 @@ return { - "lnc3l0t/glow.nvim", - branch = "advanced_window", - config = { - default_type = "keep", - }, - cmd = "Glow", + "lnc3l0t/glow.nvim", + branch = "advanced_window", + config = { + default_type = "keep", + }, + cmd = "Glow", keys = { - { "m","", desc = " Markdown" }, - { "mp",":Glow ", desc = "Markdown preview" }, + { "m", "", desc = " Markdown" }, + { "mp", ":Glow ", desc = "Markdown preview" }, }, } diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua index 61f34b9..f706150 100644 --- a/lua/plugins/neo-tree.lua +++ b/lua/plugins/neo-tree.lua @@ -2,9 +2,11 @@ return { "nvim-neo-tree/neo-tree.nvim", dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons" }, cmd = "Neotree", - init = function() vim.g.neo_tree_remove_legacy_commands = true end, + init = function() + vim.g.neo_tree_remove_legacy_commands = true + end, pin = true, - tag = '2.56', + tag = "2.56", opts = { auto_clean_after_session_restore = true, close_if_last_window = true, @@ -30,13 +32,16 @@ return { }, 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" }, + { + "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/null-ls.lua b/lua/plugins/null-ls.lua index 86155e0..5effa45 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -19,7 +19,6 @@ return { "jose-elias-alvarez/null-ls.nvim", after = { "williamboman/mason.nvim" }, opts = function(_, config) - -- config variable is the default definitions table for the setup function call local null_ls = require("null-ls") @@ -51,10 +50,10 @@ return { return config end, }, - { - "jay-babu/mason-null-ls.nvim", - opts = { - ensure_installed = { "rustfmt", "stylelua", "prettier", "black" } - } - } + { + "jay-babu/mason-null-ls.nvim", + opts = { + ensure_installed = { "rustfmt", "stylelua", "prettier", "black" }, + }, + }, } diff --git a/lua/plugins/open-github.lua b/lua/plugins/open-github.lua index b078554..70496a2 100644 --- a/lua/plugins/open-github.lua +++ b/lua/plugins/open-github.lua @@ -1,7 +1,7 @@ return { - "Almo7aya/openingh.nvim", - event = "BufEnter", + "Almo7aya/openingh.nvim", + event = "BufEnter", keys = { - { "gf", ":OpenInGHFile ", desc = "Open in git" } + { "gf", ":OpenInGHFile ", desc = "Open in git" }, }, } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index ac9307f..9f20fc8 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,32 +1,68 @@ 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" }, - { "fb", function() require('telescope.builtin').buffers() end, desc = "Find Commands" }, - }, - opts = { - defaults = { - vimgrep_arguments = { - "rg", - "-L", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - } - } - }, + "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", + }, + { + "fb", + function() + require("telescope.builtin").buffers() + end, + desc = "Find Commands", + }, + }, + opts = { + defaults = { + vimgrep_arguments = { + "rg", + "-L", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + }, + }, } diff --git a/lua/plugins/theme_material.lua b/lua/plugins/theme_material.lua index 06a3e6a..374232a 100644 --- a/lua/plugins/theme_material.lua +++ b/lua/plugins/theme_material.lua @@ -2,7 +2,7 @@ return { "marko-cerovac/material.nvim", config = function() vim.g.material_style = "darker" - require("material").setup { + require("material").setup({ plugins = { "dashboard", "gitsigns", @@ -11,8 +11,8 @@ return { "which-key", }, high_visibility = { - darker = true - } - } - end + darker = true, + }, + }) + end, } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 45f6eba..8d7c33f 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,87 +1,87 @@ local auto = true local output = vim.fn.system({ - "which", - "tree-sitter", + "which", + "tree-sitter", }) if output == nil or output == "" then - auto = false + auto = false end return { - "nvim-treesitter/nvim-treesitter", - dependencies = { "windwp/nvim-ts-autotag", "JoosepAlviste/nvim-ts-context-commentstring" }, - build = ":TSUpdate", - event = "BufRead", - cmd = { - "TSBufDisable", - "TSBufEnable", - "TSBufToggle", - "TSDisable", - "TSEnable", - "TSToggle", - "TSInstall", - "TSInstallInfo", - "TSInstallSync", - "TSModuleInfo", - "TSUninstall", - "TSUpdate", - "TSUpdateSync", - }, - opts = { - -- ensure_installed = 'all', - ensure_installed = { - "lua", - "http", - "json", - "bash", - "css", - "diff", - "dockerfile", - "dot", - "git_rebase", - "gitattributes", - "html", - "java", - "javascript", - "jq", - "jsdoc", - "json5", - "kotlin", - "latex", - "make", - "markdown", - "markdown_inline", - "nix", - "python", - "regex", - "rst", - "rust", - "scss", - "sql", - "terraform", - "toml", - "tsx", - "jsx", - "typescript", - "vue", - "yaml", - }, - auto_install = auto, - highlight = { - enable = true, - use_languagetree = true, - -- disable = function(_, bufnr) return vim.api.nvim_buf_line_count(bufnr) > 10000 end, - additional_vim_regex_highlighting = false, - }, - incremental_selection = { enable = true }, - ident = { enable = true }, - autotag = { enable = true }, - context_commentstring = { enable = true, enable_autocmd = false }, - rainbow = { - enable = true, - extended_mode = true, - max_file_lines = nil, - }, - }, - "nvim-treesitter/playground", + "nvim-treesitter/nvim-treesitter", + dependencies = { "windwp/nvim-ts-autotag", "JoosepAlviste/nvim-ts-context-commentstring" }, + build = ":TSUpdate", + event = "BufRead", + cmd = { + "TSBufDisable", + "TSBufEnable", + "TSBufToggle", + "TSDisable", + "TSEnable", + "TSToggle", + "TSInstall", + "TSInstallInfo", + "TSInstallSync", + "TSModuleInfo", + "TSUninstall", + "TSUpdate", + "TSUpdateSync", + }, + opts = { + -- ensure_installed = 'all', + ensure_installed = { + "lua", + "http", + "json", + "bash", + "css", + "diff", + "dockerfile", + "dot", + "git_rebase", + "gitattributes", + "html", + "java", + "javascript", + "jq", + "jsdoc", + "json5", + "kotlin", + "latex", + "make", + "markdown", + "markdown_inline", + "nix", + "python", + "regex", + "rst", + "rust", + "scss", + "sql", + "terraform", + "toml", + "tsx", + "jsx", + "typescript", + "vue", + "yaml", + }, + auto_install = auto, + highlight = { + enable = true, + use_languagetree = true, + -- disable = function(_, bufnr) return vim.api.nvim_buf_line_count(bufnr) > 10000 end, + additional_vim_regex_highlighting = false, + }, + incremental_selection = { enable = true }, + ident = { enable = true }, + autotag = { enable = true }, + context_commentstring = { enable = true, enable_autocmd = false }, + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = nil, + }, + }, + "nvim-treesitter/playground", } diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua index fcde095..c23e75c 100644 --- a/lua/plugins/undotree.lua +++ b/lua/plugins/undotree.lua @@ -1,8 +1,7 @@ return { - "mbbill/undotree", + "mbbill/undotree", event = "BufEnter", keys = { { "u", vim.cmd.UndotreeToggle, desc = "Undo Tree Toggle" }, }, } - diff --git a/lua/plugins/util_plenary.lua b/lua/plugins/util_plenary.lua index e4b0a5c..dfc4697 100644 --- a/lua/plugins/util_plenary.lua +++ b/lua/plugins/util_plenary.lua @@ -1,4 +1,3 @@ return { "nvim-lua/plenary.nvim", } - diff --git a/lua/plugins_disabled/cmp.lua b/lua/plugins_disabled/cmp.lua index 43f29e6..ea0a869 100644 --- a/lua/plugins_disabled/cmp.lua +++ b/lua/plugins_disabled/cmp.lua @@ -35,11 +35,9 @@ return { { "hrsh7th/cmp-nvim-lsp" }, }, config = function() - vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) - local cmp = require("cmp") local snip_status_ok, luasnip = pcall(require, "luasnip") local lspkind_status_ok, lspkind = pcall(require, "lspkind") @@ -131,8 +129,8 @@ return { }) end, }, - { - "folke/neodev.nvim", - opts = {} - } + { + "folke/neodev.nvim", + opts = {}, + }, } diff --git a/lua/plugins_disabled/lsp-zero.lua b/lua/plugins_disabled/lsp-zero.lua index 47bf7b8..b08ab0b 100644 --- a/lua/plugins_disabled/lsp-zero.lua +++ b/lua/plugins_disabled/lsp-zero.lua @@ -16,7 +16,7 @@ return { "MasonLog", }, build = ":MasonUpdate", - event = "BufRead", + event = "BufRead", }, { "williamboman/mason-lspconfig.nvim" }, -- Autocompletion @@ -61,7 +61,6 @@ return { local config = require("lspconfig") local util = require("lspconfig/util") - local capabilities = require("cmp_nvim_lsp").default_capabilities() capabilities = vim.tbl_deep_extend("keep", capabilities, vim.lsp.protocol.make_client_capabilities()) capabilities.textDocument.completion.completionItem = { @@ -88,65 +87,67 @@ return { lsp.default_keymaps({ buffer = bufnr }) - local opts = { buffer = bufnr } - local bind = function(map, cmd, mode) vim.keymap.set('n', map, cmd, opts) end + local opts = { buffer = bufnr } + local bind = function(map, cmd, mode) + vim.keymap.set("n", map, cmd, opts) + end - -- diagnostics - bind("ld", "lua vim.diagnostic.open_float()") - bind("[d", "lua vim.diagnostic.goto_prev()") - bind("]d", "lua vim.diagnostic.goto_next()") + -- diagnostics + bind("ld", "lua vim.diagnostic.open_float()") + bind("[d", "lua vim.diagnostic.goto_prev()") + bind("]d", "lua vim.diagnostic.goto_next()") - bind("la", "lua vim.lsp.buf.code_action()") + bind("la", "lua vim.lsp.buf.code_action()") end lsp.on_attach(on_attach) - local servers = { + local servers = { -- -- https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers - -- lua + -- lua "lua_ls", - -- rust + -- rust "rust_analyzer", - -- ts/js | web + -- ts/js | web "tsserver", - "html", + "html", "eslint", "cssls", "cssmodules_ls", - -- python + -- python "pyright", - -- docker + -- docker "dockerls", "docker_compose_language_service", } lsp.ensure_installed(servers) - local default = require('util').spread { - on_attach = on_attach, + local default = require("util").spread({ + on_attach = on_attach, capabilities = capabilities, - } + }) config.lua_ls.setup(lsp.nvim_lua_ls()) - config.rust_analyzer.setup(default {}) + config.rust_analyzer.setup(default({})) - config.tsserver.setup(default { - root_dir = util.root_pattern("tsconfig.json", ".git"), - }) - config.html.setup(default {}) - config.eslint.setup(default {}) - config.cssls.setup(default {}) - config.cssmodules_ls.setup(default {}) + config.tsserver.setup(default({ + root_dir = util.root_pattern("tsconfig.json", ".git"), + })) + config.html.setup(default({})) + config.eslint.setup(default({})) + config.cssls.setup(default({})) + config.cssmodules_ls.setup(default({})) - config.pyright.setup(default {}) + config.pyright.setup(default({})) - config.dockerls.setup(default {}) - config.docker_compose_language_service.setup(default {}) + config.dockerls.setup(default({})) + config.docker_compose_language_service.setup(default({})) lsp.setup() - local cmp = require("cmp") + local cmp = require("cmp") local cmp_action = require("lsp-zero").cmp_action() cmp.setup({ diff --git a/lua/plugins_disabled/tabstops_sleuth.lua b/lua/plugins_disabled/tabstops_sleuth.lua index 0884e6b..fddd2af 100644 --- a/lua/plugins_disabled/tabstops_sleuth.lua +++ b/lua/plugins_disabled/tabstops_sleuth.lua @@ -1,3 +1,3 @@ return { - 'tpope/vim-sleuth', + "tpope/vim-sleuth", } diff --git a/lua/tools/init.lua b/lua/tools/init.lua index 2c8ba37..9ffdb1f 100644 --- a/lua/tools/init.lua +++ b/lua/tools/init.lua @@ -1,8 +1,7 @@ -- 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 +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) + require("tools." .. tool) end end - diff --git a/lua/tools/scratch-files.lua b/lua/tools/scratch-files.lua index 5ec9fab..0e44b83 100644 --- a/lua/tools/scratch-files.lua +++ b/lua/tools/scratch-files.lua @@ -1,37 +1,71 @@ -- 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 .. "'") + 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({ +require("util").keymaps({ n = { - ["fsw"] = { + ["fsw"] = { function() - require("telescope.builtin").live_grep { + require("telescope.builtin").live_grep({ search_dirs = { "~/dev/scratches/" }, - } + }) end, desc = "Find Words in Scratches", }, - ["fsf"] = { + ["fsf"] = { function() - require("telescope.builtin").find_files{ + 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" }, - ["sm"] = { function() scratch ".md" end, desc = "New markdown 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" }, - } + ["ss"] = { + function() + scratch(".txt") + end, + desc = "New text scratch file", + }, + ["sn"] = { + function() + scratch(".json") + end, + desc = "New json scratch file", + }, + ["sm"] = { + function() + scratch(".md") + end, + desc = "New markdown 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/util.lua b/lua/util.lua index 94239a9..7d22e99 100644 --- a/lua/util.lua +++ b/lua/util.lua @@ -1,4 +1,4 @@ -local M = {}; +local M = {} function M.keymaps(mappings) for mode, maps in pairs(mappings) do @@ -21,18 +21,17 @@ function M.keymaps(mappings) end function M.spread(template) - local result = {} - for key, value in pairs(template) do - result[key] = value - end + local result = {} + for key, value in pairs(template) do + result[key] = value + end - return function(table) - for key, value in pairs(table) do - result[key] = value - end - return result - end + return function(table) + for key, value in pairs(table) do + result[key] = value + end + return result + end end return M -