diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 5c1c87e..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* linguist-language=HolyC diff --git a/.gitignore b/.gitignore index b73044e..95ea976 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ *.zip *.pdf -lazy-lock.json diff --git a/.luarc.json b/.luarc.json index 8f4f08d..31fb163 100644 --- a/.luarc.json +++ b/.luarc.json @@ -1,9 +1,6 @@ { - "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", - "Lua.diagnostics.disable": [ - "unused-function", - "unused-local", - "redefined-local" - ], - "Lua.diagnostics.globals": ["vim"] + "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json", + "runtime.version": "LuaJIT", + "workspace.library": ["$VIMRUNTIME/lua"], + "diagnostics.globals": ["vim"] } diff --git a/lua/harrisonablack/init.lua b/lua/harrisonablack/init.lua index e4c913e..48420c3 100644 --- a/lua/harrisonablack/init.lua +++ b/lua/harrisonablack/init.lua @@ -1,5 +1,8 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + vim.loader.enable() -require "harrisonablack.plugins" require "harrisonablack.options" require "harrisonablack.keymaps" +require "harrisonablack.plugins" diff --git a/lua/harrisonablack/keymaps.lua b/lua/harrisonablack/keymaps.lua index ff33c30..5e19fc4 100644 --- a/lua/harrisonablack/keymaps.lua +++ b/lua/harrisonablack/keymaps.lua @@ -1,55 +1,64 @@ -local opts = { noremap = true, silent = true } -local map = vim.keymap.set - -local function with_desc(desc) - return vim.tbl_extend("force", opts, { desc = desc }) +local function map(mode, lhs, rhs, desc) + vim.keymap.set(mode, lhs, rhs, { silent = true, desc = desc }) end -map("n", "o", ":update:source", opts) -map("n", "w", ":w", opts) -map("n", "q", ":q", opts) -map("n", "Q", ":wqa", opts) -map("n", "bd", ":bd", opts) -map("n", "bp", ":bp", opts) -map("n", "v", ":vsplit", opts) - -map("n", "", "Open .", opts) -map("n", "e", "Oil", opts) - -map("n", "f", "Telescope find_files", opts) -map("n", "r", "Telescope buffers", opts) -map("n", "g", "Telescope live_grep", opts) +map("n", "o", "restart", "Restart Neovim") +map("n", "w", "write", "Write buffer") +map("n", "q", "quit", "Quit window") +map("n", "Q", "wqall", "Write all and quit") +map("n", "bd", "bdelete", "Delete buffer") +map("n", "bp", "bprevious", "Previous buffer") +map("n", "bn", "bnext", "Next buffer") +map("n", "v", "vsplit", "Split window vertically") +map("n", "Wv", "vsplit", "Split window vertically") +map("n", "Ws", "split", "Split window horizontally") +map("n", "Wq", "close", "Close window") -map("n", "", ":wincmd h", opts) -map("n", "", ":wincmd j", opts) -map("n", "", ":wincmd k", opts) -map("n", "", ":wincmd l", opts) +map("n", "", function() + vim.ui.open(vim.fn.getcwd()) +end, "Open working directory externally") +map("n", "e", "Oil", "Explore files") -map("n", "", ":vert res -5", opts) -map("n", "", ":res -5", opts) -map("n", "", ":res +5", opts) -map("n", "", ":vert res +5", opts) - -map({ "n", "v", "x" }, ";", ":", opts) -map({ "n", "v", "x" }, ":", ";", opts) +local function telescope(picker) + return function() + require("telescope.builtin")[picker]() + end +end +map("n", "f", telescope "find_files", "Find files") +map("n", "r", telescope "buffers", "Find buffers") +map("n", "g", telescope "live_grep", "Search text") +map("n", "sf", telescope "find_files", "Find files") +map("n", "sg", telescope "live_grep", "Search text") +map("n", "sh", telescope "help_tags", "Search help") +map("n", "sr", telescope "oldfiles", "Find recent files") +map("n", "sd", telescope "diagnostics", "Search diagnostics") -map("n", "", "noh", opts) +map("n", "", "wincmd h", "Focus left window") +map("n", "", "wincmd j", "Focus lower window") +map("n", "", "wincmd k", "Focus upper window") +map("n", "", "wincmd l", "Focus right window") +map("n", "", "vertical resize -5", "Narrow window") +map("n", "", "resize -5", "Shorten window") +map("n", "", "resize +5", "Heighten window") +map("n", "", "vertical resize +5", "Widen window") -require("which-key").add { - { "l", group = "LSP / Diagnostics", mode = { "n", "x" } }, -} +map({ "n", "v" }, ";", ":", "Enter command line") +map({ "n", "v" }, ":", ";", "Repeat character search") +map("n", "", "nohlsearch", "Clear search highlighting") -local telescope = require "telescope.builtin" +map("n", "gd", vim.lsp.buf.definition, "LSP: Go to definition") +map("n", "gD", vim.lsp.buf.declaration, "LSP: Go to declaration") +map("n", "ly", vim.lsp.buf.type_definition, "LSP: Go to type definition") +map({ "n", "x" }, "la", vim.lsp.buf.code_action, "LSP: Code actions") +map("n", "ln", vim.lsp.buf.rename, "LSP: Rename symbol") +map("n", "lf", function() + vim.lsp.buf.format { bufnr = 0, async = true } +end, "LSP: Format buffer") +map("n", "ls", telescope "lsp_document_symbols", "LSP: Find document symbols") +map("n", "li", telescope "lsp_implementations", "LSP: Find implementations") +map("n", "lr", telescope "lsp_references", "LSP: Find references") -map("n", "lq", "Trouble qflist toggle", with_desc "LSP: Trouble quickfix list") -map("n", "ll", "Trouble loclist toggle", with_desc "LSP: Trouble location list") -map({ "n", "x" }, "la", vim.lsp.buf.code_action, with_desc "LSP: Code actions") -map("n", "lf", vim.lsp.buf.format, with_desc "LSP: Format buffer") -map("n", "ly", vim.lsp.buf.type_definition, with_desc "LSP: Go to type definition") -map("n", "ls", telescope.lsp_document_symbols, with_desc "LSP: Find document symbols") -map("n", "li", telescope.lsp_implementations, with_desc "LSP: Find implementations") -map("n", "lr", telescope.lsp_references, with_desc "LSP: Find references") -map("n", "gd", vim.lsp.buf.definition, with_desc "LSP: Go to definition") -map("n", "gD", vim.lsp.buf.declaration, with_desc "LSP: Go to declaration") -map("n", "lD", "Trouble diagnostics toggle", with_desc "LSP: Trouble global diagnostics") -map("n", "ld", "Trouble diagnostics toggle filter.buf=0", with_desc "LSP: Trouble diagnostics") +map("n", "lq", "Trouble qflist toggle", "Trouble: Quickfix list") +map("n", "ll", "Trouble loclist toggle", "Trouble: Location list") +map("n", "lD", "Trouble diagnostics toggle", "Trouble: Global diagnostics") +map("n", "ld", "Trouble diagnostics toggle filter.buf=0", "Trouble: Buffer diagnostics") diff --git a/lua/harrisonablack/options.lua b/lua/harrisonablack/options.lua index b606682..4d265b7 100644 --- a/lua/harrisonablack/options.lua +++ b/lua/harrisonablack/options.lua @@ -1,11 +1,9 @@ -local o, g = vim.opt, vim.g +local o = vim.opt -g.mapleader = " " -g.have_nerd_font = true +vim.g.have_nerd_font = true o.number = true o.relativenumber = true o.winborder = "rounded" -o.smartindent = true o.termguicolors = true o.signcolumn = "yes" o.clipboard = "unnamedplus" @@ -13,12 +11,32 @@ o.laststatus = 3 o.softtabstop = 2 o.tabstop = 2 o.shiftwidth = 2 +o.expandtab = true +o.shiftround = true +o.smartindent = false +vim.cmd "filetype plugin indent on" o.cursorcolumn = false o.ignorecase = true +o.smartcase = true o.conceallevel = 2 o.cmdheight = 0 +o.undofile = true +o.splitbelow = true +o.splitright = true +o.confirm = true +o.updatetime = 250 +o.timeoutlen = 400 +o.scrolloff = 5 +o.sidescrolloff = 5 + vim.diagnostic.config { - virtual_text = true, + severity_sort = true, + update_in_insert = false, + virtual_text = { spacing = 2, source = "if_many" }, + float = { border = "rounded", source = "if_many" }, } -require("vim._core.ui2").enable() +-- UI2 is private and may move or change between nightly builds. +pcall(function() + require("vim._core.ui2").enable() +end) diff --git a/lua/harrisonablack/plugins.lua b/lua/harrisonablack/plugins.lua deleted file mode 100644 index 5b14d92..0000000 --- a/lua/harrisonablack/plugins.lua +++ /dev/null @@ -1,140 +0,0 @@ -local gh = function(x) - return "https://github.com/" .. x -end - -vim.pack.add { - gh "stevearc/oil.nvim", - gh "EdenEast/nightfox.nvim", - gh "nvim-telescope/telescope.nvim.git", - gh "nvim-telescope/telescope-ui-select.nvim.git", - gh "nvim-lua/plenary.nvim.git", - gh "nvim-tree/nvim-web-devicons.git", - gh "malewicz1337/oil-git.nvim.git", - gh "lukas-reineke/indent-blankline.nvim", - gh "MunifTanjim/nui.nvim", - gh "mason-org/mason.nvim.git", - gh "neovim/nvim-lspconfig.git", - gh "mason-org/mason-lspconfig.nvim.git", - gh "mfussenegger/nvim-dap", - gh "nvim-mini/mini.pairs.git", - gh "nvim-treesitter/nvim-treesitter.git", - gh "windwp/nvim-ts-autotag.git", - gh "j-hui/fidget.nvim.git", - gh "vyfor/cord.nvim", - gh "obsidian-nvim/obsidian.nvim.git", - gh "lewis6991/gitsigns.nvim.git", - gh "saghen/blink.lib", - gh "saghen/blink.cmp", - gh "MeanderingProgrammer/render-markdown.nvim.git", - gh "folke/which-key.nvim", - gh "folke/trouble.nvim", -} - -require("oil").setup() -require("oil-git").setup() -require("mason").setup() -require("mason-lspconfig").setup() -require("telescope").setup { - defaults = { - prompt_title = false, - results_title = false, - preview_title = false, - preview = { treesitter = true }, - color_devicons = true, - sorting_strategy = "ascending", - borderchars = { - "", -- top - "", -- right - "", -- bottom - "", -- left - "", -- top-left - "", -- top-right - "", -- bottom-right - "", -- bottom-left - }, - path_displays = { "smart" }, - layout_config = { - height = 100, - width = 400, - prompt_position = "top", - preview_cutoff = 40, - }, - }, - pickers = { - find_files = { - prompt_title = "", - preview_title = "", - }, - live_grep = { - prompt_title = "", - preview_title = "", - }, - grep_string = { - prompt_title = "", - preview_title = "", - }, - buffers = { - prompt_title = "", - preview_title = "", - }, - prompt_prefix = "", - selection_caret = "", - entry_prefix = "", - }, -} -require("telescope").load_extension "ui-select" -require("mini.pairs").setup() -require("ibl").setup() -require("nvim-ts-autotag").setup() -require("fidget").setup() - -require("cord").setup { - display = { - theme = "classic", - }, - advanced = { - discord = { - reconnect = { - enabled = true, - }, - }, - }, -} - -vim.cmd "colorscheme carbonfox" - -require("obsidian").setup { - legacy_commands = false, - workspaces = { - { - name = "notes", - path = "~/notes/", - }, - }, -} - -require("gitsigns").setup() - -local cmp = require "blink.cmp" -cmp.build():pwait() -cmp.setup { - fuzzy = { implementation = "lua" }, - keymap = { - preset = "default", - [""] = { "select_and_accept", "fallback" }, - }, - completion = { - menu = { - draw = { - columns = { - { "kind_icon" }, - { "label" }, - { "label_description" }, - }, - }, - }, - }, -} - -require("render-markdown").setup {} -require("trouble").setup() diff --git a/lua/harrisonablack/plugins/editor.lua b/lua/harrisonablack/plugins/editor.lua new file mode 100644 index 0000000..151974f --- /dev/null +++ b/lua/harrisonablack/plugins/editor.lua @@ -0,0 +1,78 @@ +require("oil").setup() +require("oil-git").setup() + +require("telescope").setup { + defaults = { + prompt_title = false, + results_title = false, + preview_title = false, + sorting_strategy = "ascending", + selection_caret = "", + entry_prefix = "", + preview = { treesitter = true }, + layout_strategy = "horizontal", + + borderchars = { + "", -- top + "", -- right + "", -- bottom + "", -- left + "", -- top-left + "", -- top-right + "", -- bottom-right + "", -- bottom-left + }, + path_displays = { "smart" }, + layout_config = { + height = 100, + width = 400, + prompt_position = "top", + preview_cutoff = 40, + }, + }, + pickers = { + find_files = { + prompt_title = "", + preview_title = "", + }, + live_grep = { + prompt_title = "", + preview_title = "", + }, + grep_string = { + prompt_title = "", + preview_title = "", + }, + buffers = { + prompt_title = "", + preview_title = "", + }, + prompt_prefix = "", + selection_caret = "", + entry_prefix = "", + }, +} + +require("telescope").load_extension "ui-select" + +require("nvim-treesitter").setup() +require("nvim-ts-autotag").setup() +require("mini.pairs").setup() +require("ibl").setup() +require("gitsigns").setup { + on_attach = function(bufnr) + local gs = require "gitsigns" + local function map(lhs, rhs, desc) + vim.keymap.set("n", lhs, rhs, { buffer = bufnr, silent = true, desc = desc }) + end + map("hj", function() + gs.nav_hunk "next" + end, "Git: Next hunk") + map("hk", function() + gs.nav_hunk "prev" + end, "Git: Previous hunk") + map("hp", gs.preview_hunk, "Git: Preview hunk") + map("hs", gs.stage_hunk, "Git: Stage hunk") + map("hr", gs.reset_hunk, "Git: Reset hunk") + end, +} diff --git a/lua/harrisonablack/plugins/init.lua b/lua/harrisonablack/plugins/init.lua new file mode 100644 index 0000000..4c6a465 --- /dev/null +++ b/lua/harrisonablack/plugins/init.lua @@ -0,0 +1,36 @@ +local function gh(repo) + return "https://github.com/" .. repo +end + +vim.pack.add { + gh "nvim-lua/plenary.nvim", + gh "nvim-tree/nvim-web-devicons", + gh "MunifTanjim/nui.nvim", + gh "saghen/blink.lib", + gh "stevearc/oil.nvim", + gh "malewicz1337/oil-git.nvim", + gh "EdenEast/nightfox.nvim", + gh "nvim-telescope/telescope.nvim", + gh "nvim-telescope/telescope-ui-select.nvim", + gh "lukas-reineke/indent-blankline.nvim", + gh "mason-org/mason.nvim", + gh "neovim/nvim-lspconfig", + gh "mason-org/mason-lspconfig.nvim", + gh "mfussenegger/nvim-dap", + gh "nvim-mini/mini.pairs", + gh "nvim-treesitter/nvim-treesitter", + gh "windwp/nvim-ts-autotag", + gh "j-hui/fidget.nvim", + gh "vyfor/cord.nvim", + gh "saghen/blink.cmp", + gh "obsidian-nvim/obsidian.nvim", + gh "lewis6991/gitsigns.nvim", + gh "MeanderingProgrammer/render-markdown.nvim", + gh "folke/which-key.nvim", + gh "folke/trouble.nvim", + gh "nvim-java/nvim-java", +} + +require "harrisonablack.plugins.editor" +require "harrisonablack.plugins.lsp" +require "harrisonablack.plugins.ui" diff --git a/lua/harrisonablack/plugins/lsp.lua b/lua/harrisonablack/plugins/lsp.lua new file mode 100644 index 0000000..ef5e09e --- /dev/null +++ b/lua/harrisonablack/plugins/lsp.lua @@ -0,0 +1,40 @@ +local cmp = require "blink.cmp" +cmp.build():pwait() +cmp.setup { + fuzzy = { implementation = "lua" }, + keymap = { + preset = "default", + [""] = { "select_and_accept", "fallback" }, + }, + completion = { + menu = { + border = "none", + draw = { + padding = 0, + columns = { + { "kind_icon" }, + { "label" }, + { "label_description" }, + }, + }, + }, + }, + signature = { enabled = true }, +} + +-- Set completion capabilities before Mason or Java enables any server. +vim.lsp.config("*", { capabilities = cmp.get_lsp_capabilities() }) +require("mason").setup() +require("mason-lspconfig").setup { + automatic_enable = { exclude = { "jdtls" } }, +} + +-- Java owns JDTLS configuration, test support, and nvim-dap integration. +require("java").setup { + jdk = { auto_install = false }, + spring_boot_tools = { enable = false }, +} +vim.lsp.enable "jdtls" + +require("fidget").setup() +require("trouble").setup() diff --git a/lua/harrisonablack/plugins/ui.lua b/lua/harrisonablack/plugins/ui.lua new file mode 100644 index 0000000..6bf1b40 --- /dev/null +++ b/lua/harrisonablack/plugins/ui.lua @@ -0,0 +1,24 @@ +vim.cmd "colorscheme carbonfox" + +require("which-key").setup { win = { border = "rounded" } } +require("which-key").add { + { "s", group = "Files / Search" }, + { "b", group = "Buffers" }, + { "W", group = "Windows" }, + { "h", group = "Git hunks" }, + { "l", group = "LSP / Diagnostics", mode = { "n", "x" } }, +} + +require("obsidian").setup { + legacy_commands = false, + workspaces = { + { name = "notes", path = vim.fn.expand "~/notes/" }, + }, + picker = { name = "telescope.nvim" }, +} +require("render-markdown").setup {} + +require("cord").setup { + display = { theme = "classic" }, + advanced = { discord = { reconnect = { enabled = true } } }, +} diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..c4a4469 --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,108 @@ +{ + "plugins": { + "blink.cmp": { + "rev": "8219b58f1c11a2fb1644d3c7116c509fa8348ec0", + "src": "https://github.com/saghen/blink.cmp" + }, + "blink.lib": { + "rev": "fd9a48ebbe6ec30d5dfcc5b42c243941ccdca1aa", + "src": "https://github.com/saghen/blink.lib" + }, + "cord.nvim": { + "rev": "85f295e43550bc968b66d95d8bfd6e12bb17df08", + "src": "https://github.com/vyfor/cord.nvim" + }, + "fidget.nvim": { + "rev": "9e0201673e08e997e7cf52afca5565c70bd117f3", + "src": "https://github.com/j-hui/fidget.nvim" + }, + "gitsigns.nvim": { + "rev": "070a5d7b985546cc57e1fc61e5bc507fecac6045", + "src": "https://github.com/lewis6991/gitsigns.nvim" + }, + "indent-blankline.nvim": { + "rev": "f1e186e44d3b7f9ae918008e2c28ce37c6023d2d", + "src": "https://github.com/lukas-reineke/indent-blankline.nvim" + }, + "mason-lspconfig.nvim": { + "rev": "b3298993d55fa194279b5eb9dbfb3a43da65cadf", + "src": "https://github.com/mason-org/mason-lspconfig.nvim" + }, + "mason.nvim": { + "rev": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d", + "src": "https://github.com/mason-org/mason.nvim" + }, + "mini.pairs": { + "rev": "b1c5a726921b7a8c9321e9a7a208aa0571de5810", + "src": "https://github.com/nvim-mini/mini.pairs" + }, + "nightfox.nvim": { + "rev": "4dacd3f0185a2227bdf3b6c0975a8f0bf87cac9a", + "src": "https://github.com/EdenEast/nightfox.nvim" + }, + "nui.nvim": { + "rev": "10fc361835c856ba4233ef5ea135b919bf3dce97", + "src": "https://github.com/MunifTanjim/nui.nvim" + }, + "nvim-dap": { + "rev": "cfa2d58f4537aca6ca83e2de1a0d9f1491121264", + "src": "https://github.com/mfussenegger/nvim-dap" + }, + "nvim-java": { + "rev": "db5536b4cb3da153084e50016596fd0e3a319aae", + "src": "https://github.com/nvim-java/nvim-java" + }, + "nvim-lspconfig": { + "rev": "a9bb4d5f4276aa5cddc015faa3ecc5a7b5a26b14", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-treesitter": { + "rev": "728e031f6b11d03d1f0708b7dc4fb0f1d9c8a137", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" + }, + "nvim-ts-autotag": { + "rev": "88c1453db4ba7dd24131086fe51fdf74e587d275", + "src": "https://github.com/windwp/nvim-ts-autotag" + }, + "nvim-web-devicons": { + "rev": "58447c1fca354bbf184425e4a8d01deecbd6f3c4", + "src": "https://github.com/nvim-tree/nvim-web-devicons" + }, + "obsidian.nvim": { + "rev": "1212014bb22a1f44a655e8e706659892b8e43e59", + "src": "https://github.com/obsidian-nvim/obsidian.nvim" + }, + "oil-git.nvim": { + "rev": "8eac25d26386d663cee62aada79a79bd831ed7eb", + "src": "https://github.com/malewicz1337/oil-git.nvim" + }, + "oil.nvim": { + "rev": "b73018b75affd13fa38e2fc94ef753b465f770d7", + "src": "https://github.com/stevearc/oil.nvim" + }, + "plenary.nvim": { + "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "render-markdown.nvim": { + "rev": "640a3ec6d538bad17c328be373c7cad0293d9589", + "src": "https://github.com/MeanderingProgrammer/render-markdown.nvim" + }, + "telescope-ui-select.nvim": { + "rev": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2", + "src": "https://github.com/nvim-telescope/telescope-ui-select.nvim" + }, + "telescope.nvim": { + "rev": "40aedd8a68c78a656a10a8d62d80c54af59420fb", + "src": "https://github.com/nvim-telescope/telescope.nvim" + }, + "trouble.nvim": { + "rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a", + "src": "https://github.com/folke/trouble.nvim" + }, + "which-key.nvim": { + "rev": "3aab2147e74890957785941f0c1ad87d0a44c15a", + "src": "https://github.com/folke/which-key.nvim" + } + } +}