From fb537df11b45c7b21f8e50dd8b530a588c7de41a Mon Sep 17 00:00:00 2001 From: Robert Morrison Date: Sun, 10 Sep 2023 22:22:30 +0100 Subject: [PATCH] chore(init): Initial working version Create and push an initial working version of this repo before I change things on this machine Signed-off-by: Robert Morrison --- .gitignore | 2 + .pre-commit-config.yaml | 12 +++ Readme.md | 96 +++++++++++++++++- ftplugin/mail.lua | 2 + ftplugin/markdown.lua | 2 + ftplugin/vimwiki.lua | 2 + init.lua | 1 + lazy-lock.json | 49 +++++++++ lua/core/autocommands.lua | 62 ++++++++++++ lua/core/hacks/cellWidths.lua | 23 +++++ lua/core/init.lua | 17 ++++ lua/core/keybinds.lua | 38 +++++++ lua/core/options.lua | 91 +++++++++++++++++ lua/core/utils/icons.lua | 6 ++ lua/core/utils/lazy.lua | 33 ++++++ lua/core/utils/window/init.lua | 21 ++++ lua/plugins/configs/UI/bufferline.lua | 5 + lua/plugins/configs/UI/lualine.lua | 63 ++++++++++++ lua/plugins/configs/UI/neo-tree.lua | 29 ++++++ lua/plugins/configs/UI/noice.lua | 28 +++++ lua/plugins/configs/UI/whichkey.lua | 46 +++++++++ lua/plugins/configs/UI/zen.lua | 25 +++++ lua/plugins/configs/completion/cmp.lua | 129 ++++++++++++++++++++++++ lua/plugins/configs/lsp/config.lua | 100 ++++++++++++++++++ lua/plugins/configs/lsp/native.lua | 6 ++ lua/plugins/configs/lsp/neodev.lua | 12 +++ lua/plugins/configs/treesitter/init.lua | 125 +++++++++++++++++++++++ lua/plugins/init.lua | 49 +++++++++ lua/plugins/specs/Coding.lua | 16 +++ lua/plugins/specs/Completion.lua | 45 +++++++++ lua/plugins/specs/LSP.lua | 127 +++++++++++++++++++++++ lua/plugins/specs/UI.lua | 123 ++++++++++++++++++++++ lua/plugins/specs/core.lua | 12 +++ lua/plugins/specs/editor.lua | 54 ++++++++++ lua/plugins/specs/previewers.lua | 13 +++ lua/plugins/specs/telescope.lua | 99 ++++++++++++++++++ lua/plugins/specs/vimwiki.lua | 53 ++++++++++ lua/sherlock5512/colourSwitch.lua | 23 +++++ luasnip/lua.lua | 18 ++++ spell/en.utf-8.add | 1 + spell/en.utf-8.add.spl | Bin 0 -> 37 bytes stylua.toml | 5 + 42 files changed, 1660 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 ftplugin/mail.lua create mode 100644 ftplugin/markdown.lua create mode 100644 ftplugin/vimwiki.lua create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/core/autocommands.lua create mode 100644 lua/core/hacks/cellWidths.lua create mode 100644 lua/core/init.lua create mode 100644 lua/core/keybinds.lua create mode 100644 lua/core/options.lua create mode 100644 lua/core/utils/icons.lua create mode 100644 lua/core/utils/lazy.lua create mode 100644 lua/core/utils/window/init.lua create mode 100644 lua/plugins/configs/UI/bufferline.lua create mode 100644 lua/plugins/configs/UI/lualine.lua create mode 100644 lua/plugins/configs/UI/neo-tree.lua create mode 100644 lua/plugins/configs/UI/noice.lua create mode 100644 lua/plugins/configs/UI/whichkey.lua create mode 100644 lua/plugins/configs/UI/zen.lua create mode 100644 lua/plugins/configs/completion/cmp.lua create mode 100644 lua/plugins/configs/lsp/config.lua create mode 100644 lua/plugins/configs/lsp/native.lua create mode 100644 lua/plugins/configs/lsp/neodev.lua create mode 100644 lua/plugins/configs/treesitter/init.lua create mode 100644 lua/plugins/init.lua create mode 100644 lua/plugins/specs/Coding.lua create mode 100644 lua/plugins/specs/Completion.lua create mode 100644 lua/plugins/specs/LSP.lua create mode 100644 lua/plugins/specs/UI.lua create mode 100644 lua/plugins/specs/core.lua create mode 100644 lua/plugins/specs/editor.lua create mode 100644 lua/plugins/specs/previewers.lua create mode 100644 lua/plugins/specs/telescope.lua create mode 100644 lua/plugins/specs/vimwiki.lua create mode 100644 lua/sherlock5512/colourSwitch.lua create mode 100644 luasnip/lua.lua create mode 100644 spell/en.utf-8.add create mode 100644 spell/en.utf-8.add.spl create mode 100644 stylua.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eaae5f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Readme.html +/lua/plugins/specs/DEV.lua diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c6a8b22 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,12 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: check-toml + - id: check-yaml + - id: mixed-line-ending + - repo: https://github.com/JohnnyMorganz/StyLua + rev: v0.18.0 + hooks: + - id: stylua # or stylua-system / stylua-github diff --git a/Readme.md b/Readme.md index 5c67cfe..c160a44 100644 --- a/Readme.md +++ b/Readme.md @@ -1,7 +1,97 @@ # NⅣM +The fourth in a lineage of configurations for neovim. -Yet again I grew tired of my previous configuration and hastened to create a new one. +## Important information +I **strongly** recommend against just copying my entire +configuration, what works for me might not work so well for you. +It would also deprive you of learning what you can do yourself. -Many things will stay the same, but other things shall change... +To use this configuration you **MUST** have a +[Nerd Font](https://www.nerdfonts.com) installed and +configured as your default terminal font (I personally use Blex mono). -As always I will be eating my own dogfood while developing the foundations of this config. +⚠️ This configuration is currently only tested against nightly versions of neovim and +may use features that are not available in the current stable version. + +## Current features +- [Lazy plugin loading](#lazy) +- [lualine](#lualine) +- [treesitter support](#treesitter) +- Filetype specific options (see [ftplugin](#ftplugin)) + +## Features to come (A.K.A TODO:) +- Full help written in proper help format. +- Crazy useful autocommands. +- Figure out why the keybind for knap doesn't appear immediately after the + `autocmd` is triggered. + +## In-depth feature details +In this section you can expect to find semi-detailed descriptions of each +feature, this should be enough info for you to understand what does what. + +### lazy +As part of this configuration I switched from using `Packer.nvim` to +[`Lazy.nvim`](https://github.com/folke/lazy.nvim) which allows me to easily +make plugins load lazily. +This, in theory, will greatly decrease load times and the overall resource +footprint since I only need to load the plugins that are actually used. + +While I haven't (nor do I plan to waste time making) any data to base this +on I certainly feel that using Lazy has made neovim feel faster and more +responsive. + +### lualine +[Lualine](https://github.com/nvim-lualine/lualine.nvim) is a slick fast +status line for neovim written in lua. + +As I prefer to have as much screen as possible dedicated to each open file +I have configured lualine to use a global line, this means it only displays +once at the bottom of the window. + +I also have my own bar module configured that shows if you have `spell` +enabled or not. + + +### Treesitter +Treesitter is natively supported in neovim and is a much better way of +highlighting files than the earlier regular expression based highlighting. + +Treesitter also fully parses the file into a syntax tree, allowing for more +features including +
+
Incremental selection:
+
Selecting portions of a file based on their scope
+
Indentation:
+
Indentation based purely on semantics, not on what came before.
+
Rainbow brackets
+
Brackets that are colour matched based purely on code scope
+
Folding
+
Code folding that requires no language server, markers, or regular + expressions and cares not for indentation
+
+
+ +### ftplugin + +Neovim is an advanced editor with many useful features. In some cases I +would like some of these features to be set certain ways when editing +specific file-types. This is configured using the `ftplugin` directory. + +Each file is named after the file-type I would like the options set for. +If you feel you want to make a specific file-type have specific options then +this is where you can make that happen. + +The headings below let you know what options are set for currently +configured file-types. + +#### mail +- spell enabled +- textwidth 75 + +#### markdown +- spell enabled +- textwidth 75 + +#### vimwiki +- spell enabled +- textwidth 75 diff --git a/ftplugin/mail.lua b/ftplugin/mail.lua new file mode 100644 index 0000000..9ad73f9 --- /dev/null +++ b/ftplugin/mail.lua @@ -0,0 +1,2 @@ +vim.wo.spell = true +vim.bo.textwidth = 75 diff --git a/ftplugin/markdown.lua b/ftplugin/markdown.lua new file mode 100644 index 0000000..9ad73f9 --- /dev/null +++ b/ftplugin/markdown.lua @@ -0,0 +1,2 @@ +vim.wo.spell = true +vim.bo.textwidth = 75 diff --git a/ftplugin/vimwiki.lua b/ftplugin/vimwiki.lua new file mode 100644 index 0000000..9ad73f9 --- /dev/null +++ b/ftplugin/vimwiki.lua @@ -0,0 +1,2 @@ +vim.wo.spell = true +vim.bo.textwidth = 75 diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..06e49b9 --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require('core').setup() diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..a55d06c --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,49 @@ +{ + "LuaSnip": { "branch": "master", "commit": "ea7d7ea510c641c4f15042becd27f35b3e5b3c2b" }, + "bufferline.nvim": { "branch": "main", "commit": "9961d87bb3ec008213c46ba14b3f384a5f520eb5" }, + "calendar-vim": { "branch": "master", "commit": "a7e73e02c92566bf427b2a1d6a61a8f23542cc21" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, + "cmp-conjure": { "branch": "master", "commit": "d97816d5007be2b060f3a4e09f5b144d97d96fe8" }, + "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "conjure": { "branch": "master", "commit": "58c46d1f4999679659a5918284b574c266a7ac83" }, + "friendly-snippets": { "branch": "main", "commit": "ebf6d6e83494cdd88a54a429340256f4dbb6a052" }, + "gruvbox": { "branch": "main", "commit": "7fb36e0f67aa6f3d7f3e54f37ca7032ea1af0b59" }, + "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" }, + "knap": { "branch": "main", "commit": "503010f541696e99ed5c62f658620e546cebf8b0" }, + "lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" }, + "lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, + "lspsaga.nvim": { "branch": "main", "commit": "798c1b650d541bb14492fb54d533673162fb848f" }, + "lualine-spell-status": { "branch": "main", "commit": "aa81c2c9a71e3ed3552c6cd75e150414ff9ac664" }, + "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "20fd7f50f34b59031a7c3bbc2c207f4f60037628" }, + "mason.nvim": { "branch": "main", "commit": "ee6a7f179ebf8aa9da9d53b1cf1b57d292ea0182" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "2d89ca96e08eb6e9c8e50e1bb4738bc5125c9f12" }, + "neodev.nvim": { "branch": "main", "commit": "f0e574687aa51c513017155f003e8e8950ec6ff4" }, + "nerdcommenter": { "branch": "master", "commit": "d2e21d417f6c788b11ae3b90d7ac478930dead36" }, + "noice.nvim": { "branch": "main", "commit": "74c2902146b080035beb19944baf6f014a954720" }, + "nui.nvim": { "branch": "main", "commit": "c8de23342caf8d50b15d6b28368d36a56a69d76f" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, + "nvim-lspconfig": { "branch": "master", "commit": "d177ad277a638f262edb73c75ffe33e377b95dc5" }, + "nvim-notify": { "branch": "master", "commit": "94859430020f5cf32a1b97ddd9e596fed9db7981" }, + "nvim-treesitter": { "branch": "master", "commit": "96a50241987531fdb8a516998b72c19f563ccd6c" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "bd103502252027434ec42f628d2dbf54821d4ce6" }, + "nvim-web-devicons": { "branch": "master", "commit": "ecdeb4e2a4af34fc873bbfbf1f4c4e447e632255" }, + "plenary.nvim": { "branch": "master", "commit": "0232372b906f275f76ac42029eba25eaf95e76b9" }, + "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, + "telekasten.nvim": { "branch": "main", "commit": "bd5d323581f24ee124b33688287e6a22244c6f2a" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope-media-files.nvim": { "branch": "master", "commit": "0826c7a730bc4d36068f7c85cf4c5b3fd9fb570a" }, + "telescope.nvim": { "branch": "master", "commit": "a19770625aed49ad2a9f591a5e3946707f7359f6" }, + "tidy.nvim": { "branch": "main", "commit": "86eab24e807ed2957d26ca43b2b76b92d0fbf8f4" }, + "ts-rainbow": { "branch": "master", "commit": "b3120cd5ae9ca524af9cb602f41e12e301fa985f" }, + "twilight.nvim": { "branch": "main", "commit": "a4843e6e67092a1e6fa9666f02bf0ab59174c1df" }, + "vim-dispatch-neovim": { "branch": "master", "commit": "c8c4e21a95c25032a041002f9bf6e45a75a73021" }, + "vim-jack-in": { "branch": "master", "commit": "4cefab20f02c44249499f43200442a3176315acd" }, + "vimwiki": { "branch": "dev", "commit": "f0fe154ede6b11e3db9b058b930005a056a3d1c6" }, + "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" }, + "zen-mode.nvim": { "branch": "main", "commit": "68f554702de63f4b7b6b6d4bcb10178f41a0acc7" } +} \ No newline at end of file diff --git a/lua/core/autocommands.lua b/lua/core/autocommands.lua new file mode 100644 index 0000000..7b4f841 --- /dev/null +++ b/lua/core/autocommands.lua @@ -0,0 +1,62 @@ +local map = vim.keymap.set + +-- Control the CursorLine option +local auGroupCursorLine = vim.api.nvim_create_augroup('CursorLine', { clear = true }) +local set_cursorline = function(event, value, pattern) + vim.api.nvim_create_autocmd(event, { + group = auGroupCursorLine, + pattern = pattern, + callback = function() + vim.opt_local.cursorline = value + end, + }) +end +set_cursorline('WinLeave', false) +set_cursorline('WinEnter', true) +set_cursorline('FileType', false, 'TelescopePrompt') + +-- Wrangle format options to work how I want +local auGroupFormatOptions = vim.api.nvim_create_augroup('FormatOptions', { clear = true }) +vim.api.nvim_create_autocmd('Filetype', { + group = auGroupFormatOptions, + pattern = '*', + callback = function() + vim.opt.formatoptions = vim.opt.formatoptions -- whatever is set + - 'r' -- without auto commenting + - 'o' -- especially when adding new lines + end, +}) + +local auGroupKnapKeybinds = vim.api.nvim_create_augroup('KnapKeybinds', { clear = true }) +vim.api.nvim_create_autocmd('FileType', { + group = auGroupKnapKeybinds, + pattern = { 'markdown', 'latex', 'html' }, + callback = function() + require('lazy').load { plugins = { 'knap' } } + vim.notify('Triggered KnapKeybinds autocmd') + map({ 'n' }, 'ko', function() + require('knap').process_once() + end, { + desc = '[Knap] process once', + buffer = 0, + }) + map({ 'n' }, 'kc', function() + require('knap').close_viewer() + end, { + desc = '[Knap] close viewer', + buffer = 0, + }) + map({ 'n' }, 'kk', function() + require('knap').toggle_autopreviewing() + end, { + desc = '[Knap] toggle autopreview', + buffer = 0, + }) + map({ 'n' }, 'kf', function() + require('knap').forward_jump() + end, { + desc = '[Knap] jump forward', + buffer = 0, + }) + end, +}) diff --git a/lua/core/hacks/cellWidths.lua b/lua/core/hacks/cellWidths.lua new file mode 100644 index 0000000..559e2d4 --- /dev/null +++ b/lua/core/hacks/cellWidths.lua @@ -0,0 +1,23 @@ +-- WARNING: this file may need tweaking for your own setup +-- I would suggest disabling this if you find things not rendering properly. + +-- Many nerd-font gyphs get "improperly" rendered in terminals. +-- To fix this I am using the setcellwidth function +-- to manually override the cell width for given character ranges. +-- In some cases this involves splitting the range many times to +-- only modify the characters that need it. + +-- This issue is likely caused due to the nerd-font glyphs being placed +-- where they can fit in the unicode space, and being stuck between other +-- characters. + +-- The glyph sets are accurate as of v3.0.0 of nerd-fonts + +-- TODO: Test and add other nerd-font glyphs +-- format {start codepoint, end codepoint, width} +-- WARNING: RANGES CANNOT OVERLAP +vim.fn.setcellwidths { + { 0xf0001, 0xf01fb, 2 }, -- material design + { 0xf01fc, 0xf01fc, 1 }, -- mdi-equals + { 0xf01fd, 0xf1af0, 2 }, -- material design +} diff --git a/lua/core/init.lua b/lua/core/init.lua new file mode 100644 index 0000000..3f1ad88 --- /dev/null +++ b/lua/core/init.lua @@ -0,0 +1,17 @@ +local M = {} + +M.setup = function() + require('core.options') + require('core.autocommands') + require('core.keybinds') + require('core.hacks.cellWidths') + require('plugins') + + -- always run this last to ensure it ovverides earlier settings + require('sherlock5512.colourSwitch') + + -- Load colourscheme only after loading plugins + vim.cmd.colorscheme('gruvbox') +end + +return M diff --git a/lua/core/keybinds.lua b/lua/core/keybinds.lua new file mode 100644 index 0000000..2727a38 --- /dev/null +++ b/lua/core/keybinds.lua @@ -0,0 +1,38 @@ +-- Non plugin keybindings +-- These are keybinds which I want to have defined at all times +-- They only operate using neovim functionality and lua code. + +local map = vim.keymap.set + +map('n', 'o', function() + vim.o.spell = not vim.o.spell +end, { desc = 'Toggle Spelling' }) + +-- Advanced window control. +local window = require('core.utils.window') +local windowMod = 1 +map('n', 'H', function() + window.Modwidth(0 - windowMod) +end, { desc = 'Decrease Width' }) +map('n', 'J', function() + window.Modheight(0 - windowMod) +end, { desc = 'Decrease Height' }) +map('n', 'K', function() + window.Modheight(windowMod) +end, { desc = 'Increase Height' }) +map('n', 'L', function() + window.Modwidth(windowMod) +end, { desc = 'Increase Width' }) + +map('n', '', function() + vim.cmd.wincmd('h') +end, { desc = 'Change window ' }) +map('n', '', function() + vim.cmd.wincmd('j') +end, { desc = 'Change window ' }) +map('n', '', function() + vim.cmd.wincmd('k') +end, { desc = 'Change Window ' }) +map('n', '', function() + vim.cmd.wincmd('l') +end, { desc = 'Change Window ' }) diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..8cc7da1 --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,91 @@ +-- options + +local opt = vim.opt + +vim.g.mapleader = '\\' +vim.g.maplocalleader = ',' + +-- Show the line number on the currentline, +-- and relative numbers on the others +opt.relativenumber = true +opt.number = true + +-- Make searching a litle nicer +opt.ignorecase = true +opt.smartcase = true +opt.hlsearch = true +opt.incsearch = true + +-- Split in a more logical manner +opt.splitright = true +opt.splitbelow = true + +-- making timeout super short makes which-key show up immediately +opt.timeout = true +opt.timeoutlen = 0 + +-- Try and keep some context on screen +opt.scrolloff = 15 +opt.sidescroll = 6 + +-- Force 24 colour support +opt.termguicolors = true + +-- Set terminal title +opt.title = true + +-- Spell in english by default +opt.spelllang = 'en_gb' + +-- Ignore compiled files in completion +opt.wildignore = { + '*pycache*', + '*.o', + '*~', + '*.pyc', +} + +-- folding +opt.foldmethod = 'expr' +opt.foldexpr = 'nvim_treesitter#foldexpr()' +opt.foldminlines = 5 +opt.foldclose = 'all' +opt.foldlevelstart = 1 + +-- control the sign column +opt.signcolumn = 'auto:2-5' + +-- Cursorline default +opt.cursorline = true + +-- UI +opt.showmode = false +opt.showcmd = true +opt.cmdheight = 1 +opt.background = 'dark' +opt.laststatus = 0 + +-- Indentation & wrapping +opt.autoindent = true +opt.cindent = true +opt.wrap = true + +opt.tabstop = 4 +opt.shiftwidth = 4 +opt.softtabstop = 4 +opt.expandtab = false + +opt.breakindent = true +opt.showbreak = '>' +opt.linebreak = true + +-- Misc +opt.belloff = 'all' +opt.clipboard = 'unnamedplus' +opt.mouse = 'a' + +opt.shortmess = '' + .. 's' -- don't give search messages + .. 'W' -- don't give file written messages + .. 'I' -- don't give intro message + .. 'F' -- don't give file info when editing diff --git a/lua/core/utils/icons.lua b/lua/core/utils/icons.lua new file mode 100644 index 0000000..794034a --- /dev/null +++ b/lua/core/utils/icons.lua @@ -0,0 +1,6 @@ +return { + Error = '', + Warn = '', + Hint = '', + Info = '', +} diff --git a/lua/core/utils/lazy.lua b/lua/core/utils/lazy.lua new file mode 100644 index 0000000..8d1c2f9 --- /dev/null +++ b/lua/core/utils/lazy.lua @@ -0,0 +1,33 @@ +-- This function is taken from `asyncedd/dots.nvim` +-- From what I can tell this just ensures that some plugins load +-- in the "right" place. I may not need this but since I am basing my config off this one I will use it for now. + +return function(plugin) + vim.api.nvim_create_autocmd({ 'BufRead', 'BufWinEnter', 'BufNewFile', 'WinEnter' }, { + callback = function() + if vim.fn.expand('%') ~= '' then + -- dont defer for treesitter as it will show slow highlighting + -- This deferring only happens only when we do "nvim filename" + if plugin ~= 'nvim-treesitter' then + vim.schedule(function() + require('lazy').load { plugins = plugin } + + if + plugin == 'nvim-lspconfig' + or plugin == 'null-ls.nvim' + or plugin == 'vim-matchup' + then + vim.cmd('silent! do FileType') + + if plugin == 'null-ls.nvim' then + require('null-ls.state').register_conditional_sources() + end + end + end) + else + require('lazy').load { plugins = plugin } + end + end + end, + }) +end diff --git a/lua/core/utils/window/init.lua b/lua/core/utils/window/init.lua new file mode 100644 index 0000000..d1ba695 --- /dev/null +++ b/lua/core/utils/window/init.lua @@ -0,0 +1,21 @@ +local M = {} + +M.Modheight = function(change) + local win = vim.api.nvim_get_current_win() + local height = vim.api.nvim_win_get_height(win) + height = height + change + + if height < 0 then height = 0 end + vim.api.nvim_win_set_height(win, height) +end + +M.Modwidth = function(change) + local win = vim.api.nvim_get_current_win() + local width = vim.api.nvim_win_get_width(win) + width = width + change + + if width < 0 then width = 0 end + vim.api.nvim_win_set_width(win, width) +end + +return M diff --git a/lua/plugins/configs/UI/bufferline.lua b/lua/plugins/configs/UI/bufferline.lua new file mode 100644 index 0000000..ceef78f --- /dev/null +++ b/lua/plugins/configs/UI/bufferline.lua @@ -0,0 +1,5 @@ +return { + options = { + diagnostics = 'nvim-lsp', + }, +} diff --git a/lua/plugins/configs/UI/lualine.lua b/lua/plugins/configs/UI/lualine.lua new file mode 100644 index 0000000..a554bb2 --- /dev/null +++ b/lua/plugins/configs/UI/lualine.lua @@ -0,0 +1,63 @@ +return { + options = { + icons_enabled = true, + theme = 'gruvbox', + component_separators = { + left = '|', + right = '|', + }, + section_separators = { + left = '', + right = '', + }, + disabled_filetypes = {}, + always_divide_middle = true, + globalstatus = true, + }, + sections = { + lualine_a = { + 'mode', + 'spell_status', + }, + lualine_b = { + 'branch', + 'diff', + 'diagnostics', + }, + lualine_c = { + { + 'filename', + path = 1, + }, + { + 'filetype', + icon_only = true, + }, + }, + lualine_x = { + 'encoding', + 'fileformat', + 'filetype', + { + require('lazy.status').updates, + cond = require('lazy.status').has_updates, + }, + { + require('noice').api.status.mode.get, + cond = require('noice').api.status.mode.has, + }, + }, + lualine_y = { + 'progress', + 'searchcount', + }, + lualine_z = { + 'location', + }, + }, + tabline = {}, + extensions = { + 'neo-tree', + 'quickfix', + }, +} diff --git a/lua/plugins/configs/UI/neo-tree.lua b/lua/plugins/configs/UI/neo-tree.lua new file mode 100644 index 0000000..1659f68 --- /dev/null +++ b/lua/plugins/configs/UI/neo-tree.lua @@ -0,0 +1,29 @@ +return { + enable_git_status = true, + enable_diagnostics = true, + sort_case_insensitive = true, + + filesystem = { + filtered_items = { + visible = false, + hide_dotfiles = true, + hide_gitignored = true, + hide_hidden = true, + }, + follow_current_file = { + enabled = true, + }, + hijack_netrw_behaviour = 'open_default', + use_libuv_file_watcher = true, + }, + + window = { + position = 'left', + }, + + buffers = { + follow_current_file = { + enabled = true, + }, + }, +} diff --git a/lua/plugins/configs/UI/noice.lua b/lua/plugins/configs/UI/noice.lua new file mode 100644 index 0000000..ccacf91 --- /dev/null +++ b/lua/plugins/configs/UI/noice.lua @@ -0,0 +1,28 @@ +return { + lsp = { + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, + }, + }, + presets = { + bottom_search = true, + command_palette = true, + long_message_to_split = true, + inc_rename = false, + lsp_doc_border = false, + }, + hover = { + enabled = true, + }, + signature = { + enabled = true, + auto_open = { + enabled = true, + trigger = true, -- Automatically show signature help when typing a trigger character from the LSP + luasnip = true, -- Will open signature help when jumping to Luasnip insert nodes + throttle = 50, -- Debounce lsp signature help request by 50ms + }, + }, +} diff --git a/lua/plugins/configs/UI/whichkey.lua b/lua/plugins/configs/UI/whichkey.lua new file mode 100644 index 0000000..55a37fc --- /dev/null +++ b/lua/plugins/configs/UI/whichkey.lua @@ -0,0 +1,46 @@ +M = {} + +M.config = { + plugins = { + marks = true, + registers = true, + spelling = { + enabled = true, + suggestions = 10, + }, + + presets = { + operators = true, + motions = true, + text_objects = true, + windows = true, + nav = true, + z = true, + g = true, + }, + }, + icons = { + breadcrumb = '󰇘', + separator = '󰇼', + group = '󰋃', + }, + + window = { + border = 'single', + position = 'bottom', + }, + -- ignore_missing = true, + disable = { + filetypes = { 'TelescopePrompt' }, + }, +} + +M.default_bindings = { + ['w'] = { name = '+vimwiki' }, + ['l'] = { name = '+LSP' }, + ['c'] = { name = '+NerdComment' }, + ['f'] = { name = '+File' }, + ['t'] = { name = '+telescope' }, +} + +return M diff --git a/lua/plugins/configs/UI/zen.lua b/lua/plugins/configs/UI/zen.lua new file mode 100644 index 0000000..c01f523 --- /dev/null +++ b/lua/plugins/configs/UI/zen.lua @@ -0,0 +1,25 @@ +return { + window = { + backdrop = 0.95, + width = 0.80, + height = 0.50, + options = { + signcolumn = 'no', + number = false, + relativenumber = false, + cursorline = true, + cursorcolumn = false, + foldcolumn = '0', + list = false, + }, + }, + plugins = { + options = { + enabled = true, + ruler = false, + showcmd = false, + }, + twilight = { enabled = true }, + gitsigns = { enabled = true }, + }, +} diff --git a/lua/plugins/configs/completion/cmp.lua b/lua/plugins/configs/completion/cmp.lua new file mode 100644 index 0000000..26b028b --- /dev/null +++ b/lua/plugins/configs/completion/cmp.lua @@ -0,0 +1,129 @@ +local M = {} + +local luasnip = require('luasnip') +local cmp = require('cmp') +local compare = require('cmp.config.compare') +local lspkind = require('lspkind') + +-- Global config table +M.cmp = { + preselect = cmp.PreselectMode.None, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + window = { + completion = { + scrollbar = false, + }, + }, + mapping = { + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_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.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping { + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } + else + fallback() + end + end, + s = cmp.mapping.confirm { select = false }, + c = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = false, + }, + }, + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.abort(), + }, + sources = cmp.config.sources { + { name = 'emoji', priority = 10000 }, + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer', keyword_length = 5 }, + { name = 'path' }, + { name = 'conjure' }, + }, + formatting = { + format = lspkind.cmp_format { + mode = 'symbol_text', + menu = { + buffer = '[BUF]', + nvim_lsp = '[LSP]', + path = '[PTH]', + luasnip = '[SNP]', + emoji = '[EMJ]', + }, + maxwidth = 50, + ellipsis_char = '', + }, + }, + experimental = { + ghost_text = true, + }, + sorting = { + priority_weight = 0.8, + comparators = { + compare.score, + compare.exact, + compare.offset, + compare.sort_text, + compare.scopes, + compare.recently_used, + compare.order, + compare.kind, + compare.length, + }, + }, + performance = { + fetching_timeout = 30, + }, +} + +--- Configure completion for commandline +M.cmd = function() + -- completion for searches + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' }, + }, + }) + + cmp.setup.cmdline({ '@' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'cmdline' }, + }, + }) + + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' }, + }, { + { name = 'cmdline' }, + }), + }) +end + +return M diff --git a/lua/plugins/configs/lsp/config.lua b/lua/plugins/configs/lsp/config.lua new file mode 100644 index 0000000..0ebac5b --- /dev/null +++ b/lua/plugins/configs/lsp/config.lua @@ -0,0 +1,100 @@ +local M = {} + +M.on_attach = function() + local auGroupOnAttach = vim.api.nvim_create_augroup('on_attach', { clear = true }) + vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local bufnr = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client == nil then return end + if client.server_capabilities.inlayHintProvider then vim.lsp.inlay_hint(bufnr, true) end + + if client.server_capabilities.documentFormattingProvider then + vim.keymap.set({ 'n' }, 'lf', function() + vim.lsp.buf.format() + end, { desc = 'Format buffer' }) + end + end, + group = auGroupOnAttach, + }) +end + +M.setup = function(opts) + local servers_to_not_setup = opts.servers_to_not_setup + + local capabilities = vim.lsp.protocol.make_client_capabilities() + + capabilities.textDocument = { + completion = { + completionItem = { + documentationFormat = { 'markdown', 'plaintext' }, + snippetSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + deprecatedSupport = true, + commitCharactersSupport = true, + tagSupport = { valueSet = { 1 } }, + resolveSupport = { + properties = { + 'documentation', + 'detail', + 'additionalTextEdits', + }, + }, + }, + }, + foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, + }, + } + + local checkIfExists = function(val, arr) + local y = false + for i in ipairs(arr) do + if arr[i] == val and y ~= true then y = true end + end + return y + end + + local servers = opts.servers + + local function setup(server) + if not checkIfExists(server, servers_to_not_setup) then + local server_opts = vim.tbl_deep_extend('force', { + capabilities = vim.deepcopy(capabilities), + }, servers[server] or {}) + + if opts.setup[server] then + if opts.setup[server](server, server_opts) then return end + elseif opts.setup['*'] then + if opts.setup['*'](server, server_opts) then return end + end + require('lspconfig')[server].setup(server_opts) + M.on_attach() + end + end + -- get all the servers that are available through mason-lspconfig + local have_mason, mlsp = pcall(require, 'mason-lspconfig') + local all_mslp_servers = {} + if have_mason then + all_mslp_servers = + vim.tbl_keys(require('mason-lspconfig.mappings.server').lspconfig_to_package) + end + + local ensure_installed = {} ---@type string[] + + for server, server_opts in pairs(servers) do + server_opts = server_opts == true and {} or server_opts + if not vim.tbl_contains(all_mslp_servers, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server + end + end + + if have_mason then mlsp.setup { ensure_installed = ensure_installed, handlers = { setup } } end +end + +return M diff --git a/lua/plugins/configs/lsp/native.lua b/lua/plugins/configs/lsp/native.lua new file mode 100644 index 0000000..4e2e3e2 --- /dev/null +++ b/lua/plugins/configs/lsp/native.lua @@ -0,0 +1,6 @@ +local icons = require('core.utils.icons') + +for name, icon in pairs(icons) do + name = 'DiagnosticSign' .. name + vim.fn.sign_define(name, { text = icon, texthl = name, numhl = '' }) +end diff --git a/lua/plugins/configs/lsp/neodev.lua b/lua/plugins/configs/lsp/neodev.lua new file mode 100644 index 0000000..d3e5ed7 --- /dev/null +++ b/lua/plugins/configs/lsp/neodev.lua @@ -0,0 +1,12 @@ +return function(opts) + local status, neodev = pcall(require, 'neodev') + if not status then return false end + + neodev.setup { + library = { + plugins = opts.plugins, + runtime = opts.runtime, + types = opts.types, + }, + } +end diff --git a/lua/plugins/configs/treesitter/init.lua b/lua/plugins/configs/treesitter/init.lua new file mode 100644 index 0000000..c6beeb7 --- /dev/null +++ b/lua/plugins/configs/treesitter/init.lua @@ -0,0 +1,125 @@ +return { + ensure_installed = { + 'bash', + 'c', + 'cpp', + 'css', + 'c_sharp', + 'diff', + 'git_config', + 'git_rebase', + 'gitcommit', + 'gitignore', + 'go', + 'gomod', + 'html', + 'ini', + 'javascript', + 'jsonnet', + 'latex', + 'lua', + 'luadoc', + 'luap', + 'make', + 'markdown', + 'markdown_inline', + 'python', + 'query', + 'regex', + 'rust', + 'scss', + 'toml', + 'vim', + 'vimdoc', + 'yuck', + 'yaml', + 'zig', + }, + auto_install = true, + + highlight = { + enable = true, + }, + + indent = { + enable = true, + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + scope_incremental = '', + node_incremental = '', + node_decremental = '', + }, + }, + + rainbow = { + enable = true, + query = { + 'rainbow-parens', + html = 'rainbow-tags', + latex = 'rainbow-blocks', + }, + strategy = require('ts-rainbow').strategy.global, + }, + + textobjects = { + select = { + enable = true, + lookahead = true, + + keymaps = { + ['af'] = { query = '@function.outer', desc = 'Select outer part of function' }, + ['if'] = { query = '@function.inner', desc = 'Select inner part of function' }, + ['ac'] = { query = '@class.outer', desc = 'Select outer part of class' }, + ['ic'] = { query = '@class.inner', desc = 'Select inner part of class' }, + }, + }, + + move = { + enable = true, + set_jumps = true, + + goto_next_start = { + [']m'] = { query = '@function.outer', desc = 'Next Function start' }, + [']]'] = { query = '@class.outer', desc = 'Next class start' }, + [']o'] = { query = '@loop.*', desc = 'Next loop component' }, + [']z'] = { query = '@fold', query_group = 'folds', desc = 'Next Fold' }, + }, + goto_next_end = { + [']M'] = { query = '@function.outer', desc = 'Next Function end' }, + [']['] = { query = '@class.outer', desc = 'Next class end' }, + }, + goto_previous_start = { + ['[m'] = { query = '@function.outer', desc = 'Previous Function start' }, + ['[]'] = { query = '@class.outer', desc = 'Previous class start' }, + ['[o'] = { query = '@loop.*', desc = 'Previous loop component' }, + ['[z'] = { query = '@fold', query_group = 'folds', desc = 'Previous Fold' }, + }, + goto_previous_end = { + ['[M'] = { query = '@function.outer', desc = 'Previous Function end' }, + ['[['] = { query = '@class.outer', desc = 'Previous class end' }, + }, + + goto_next = { + [']d'] = { query = '@conditional.*', desc = 'Next Conditional' }, + }, + goto_previous = { + ['[d'] = { query = '@conditional.*', desc = 'previous Conditional' }, + }, + }, + + lsp_interop = { + enable = true, + border = 'none', + floating_preview_opts = {}, + + peek_definition_code = { + ['df'] = { query = '@function.outer', desc = 'Peek function definition' }, + ['dF'] = { query = '@class.outer', desc = 'Peek class definition' }, + }, + }, + }, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..84acc3c --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,49 @@ +-- Bootstrap lazy + +local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' + +if not vim.loop.fs_stat(lazypath) then + print(' Bootstrapping lazy.nvim') + + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', + lazypath, + } +end +vim.opt.runtimepath:prepend(lazypath) + +require('lazy').setup({ import = 'plugins.specs' }, { + defaults = { + lazy = true, + version = false, + }, + + install = { + missing = true, + colorscheme = { 'gruvbox' }, + }, + + checker = { + enabled = 'true', + }, + performance = { + rtp = { + disabled_plugins = { + 'tutor', -- I know all I need to know + 'gzip', -- It's better to do this manually + 'tarPlugin', -- " + 'zipPlugin', -- " + 'netrwPlugin', -- I replace this with neotree so might as well not load it. + }, + }, + }, + dev = { + path = '~/Projects/VIM', + patterns = { 'closedless' }, + fallback = false, + }, +}) diff --git a/lua/plugins/specs/Coding.lua b/lua/plugins/specs/Coding.lua new file mode 100644 index 0000000..ecbd90a --- /dev/null +++ b/lua/plugins/specs/Coding.lua @@ -0,0 +1,16 @@ +return { + { + 'Olical/conjure', + ft = { + 'clojure', + 'scheme', + 'guile', + 'lua', + }, + dependencies = { + 'clojure-vim/vim-jack-in', + 'radenling/vim-dispatch-neovim', + 'PaterJason/cmp-conjure', + }, + }, +} diff --git a/lua/plugins/specs/Completion.lua b/lua/plugins/specs/Completion.lua new file mode 100644 index 0000000..6310d0e --- /dev/null +++ b/lua/plugins/specs/Completion.lua @@ -0,0 +1,45 @@ +-- Completion config. + +return { + { + 'L3MON4D3/LuaSnip', -- snippet engine + build = function() + if vim.fn.has('win32') == 0 then + return "echo -e 'NOTE: jsregexp is optional, failure here is ok' ; make install_jsregexp" + end + return nil + end, + config = function() + local lua_snippets = vim.fn.stdpath('config') .. '/luasnip' + local vscode_snippets = vim.fn.stdpath('config') .. '/snippets' + require('luasnip.loaders.from_vscode').lazy_load() -- load friendly-snippets + require('luasnip.loaders.from_vscode').lazy_load { paths = { vscode_snippets } } + require('luasnip.loaders.from_lua').lazy_load { paths = { lua_snippets } } + end, + dependencies = { + 'rafamadriz/friendly-snippets', + }, + }, + { + 'hrsh7th/nvim-cmp', + opts = function() + return require('plugins.configs.completion.cmp') + end, + config = function(_, opts) + local cmp = require('cmp') + cmp.setup(opts.cmp) + opts.cmd() + end, + event = { 'InsertEnter', 'VeryLazy', 'CmdlineEnter' }, + dependencies = { + 'LuaSnip', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-emoji', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + 'onsails/lspkind.nvim', + 'saadparwaiz1/cmp_luasnip', + }, + }, +} diff --git a/lua/plugins/specs/LSP.lua b/lua/plugins/specs/LSP.lua new file mode 100644 index 0000000..a28f54f --- /dev/null +++ b/lua/plugins/specs/LSP.lua @@ -0,0 +1,127 @@ +return { + + { + 'williamboman/mason.nvim', + config = true, + }, + + { + 'williamboman/mason-lspconfig.nvim', + dependencies = { + 'mason.nvim', + }, + }, + + { + 'neovim/nvim-lspconfig', + opts = function() + return { + servers_to_not_setup = {}, + servers = { + lua_ls = { + settings = { + Lua = { + hint = { + enable = true, + arrayIndex = 'Disable', + }, + runtime = { + pathStrict = true, + }, + workspace = { + checkThirdParty = false, + }, + }, + }, + }, + csharp_ls = {}, + pyright = { + pyright = { + autoImportCompletion = true, + }, + }, + efm = { + init_options = { documentFormatting = true }, + settings = { + rootMarkers = { '.git/' }, + languages = { + lua = { + { + formatCommand = 'stylua -s --verify --color Never -', + formatStdin = true, + }, + }, + }, + }, + }, + texlab = {}, + cssls = {}, + }, + setup = {}, + } + end, + init = function() + require('core.utils.lazy')('nvim-lspconfig') + end, + config = function(_, opts) + require('plugins.configs.lsp.config').setup(opts) + + require('plugins.configs.lsp.native') + end, + dependencies = { + 'mason-lspconfig.nvim', + 'neodev.nvim', + }, + }, + + { + 'folke/neodev.nvim', + opts = { + enabled = true, + plugins = true, + runtime = true, + types = true, + pathStrict = true, + }, + config = function(_, opts) + require('plugins.configs.lsp.neodev')(opts) + end, + }, + + { + 'nvimdev/lspsaga.nvim', + event = 'LspAttach', + config = function() + require('lspsaga').setup { + code_action = { + num_shortcut = true, + show_server_name = true, + extend_gitsigns = true, + }, + lightbulb = { + enable = true, + enable_in_insert = false, + sign = true, + virtual_text = false, + }, + hover = { + open_browser = '!$BROWSER', + }, + symbol_in_winbar = { + in_custom = false, + enable = true, + seperator = '>', + show_file = true, + respect_root = true, + }, + } + end, + keys = { + { 'ld', 'Lspsaga hover_doc', desc = '[lspsaga hoverdoc]' }, + }, + dependencies = { + 'nvim-lspconfig', + 'nvim-treesitter', + }, + }, +} diff --git a/lua/plugins/specs/UI.lua b/lua/plugins/specs/UI.lua new file mode 100644 index 0000000..4116702 --- /dev/null +++ b/lua/plugins/specs/UI.lua @@ -0,0 +1,123 @@ +-- UI + +-- These plugins make up a large portion of the UI that I use to interact with nvim +return { + + { -- Colorscheme + 'ellisonleao/gruvbox.nvim', + name = 'gruvbox', + priority = 1000, + }, + + { -- lualine is real light and looks real good + 'nvim-lualine/lualine.nvim', + opts = function() + return require('plugins.configs.UI.lualine') + end, + config = true, + event = 'VeryLazy', + dependencies = { + 'nvim-web-devicons', + 'sherlock5512/lualine-spell-status', -- custom lualine module + }, + }, + + { -- neo-tree the superior filetree + 'nvim-neo-tree/neo-tree.nvim', + version = '^3', + init = function() + vim.g.neo_tree_remove_legacy_commands = 1 + end, + opts = function() + return require('plugins.configs.UI.neo-tree') + end, + config = true, + -- can't lazy load as the netrw replacement functionality + -- requires hooking to be done early in the startup process + lazy = false, + dependencies = { + 'plenary.nvim', + 'nvim-web-devicons', + 'nui.nvim', + }, + keys = { + { + 'n', + 'Neotree action=focus source=filesystem position=left toggle=true', + desc = 'toggle neotree', + }, + }, + }, + + { -- Since I commonly use a lot of buffers it is good to be able to see them. + 'akinsho/bufferline.nvim', + config = true, + event = 'VeryLazy', + dependencies = { + 'nvim-web-devicons', + }, + }, + + { -- Alternative configurable UI for a lot of things + 'folke/noice.nvim', + opts = function() + return require('plugins.configs.UI.noice') + end, + event = 'VeryLazy', + config = true, + dependencies = { + 'nui.nvim', + 'nvim-notify', + }, + }, + + { + 'folke/which-key.nvim', + opts = function() + return require('plugins.configs.UI.whichkey') + end, + config = function(_, opts) + require('which-key').setup(opts.config) + require('which-key').register(opts.default_bindings) + end, + event = 'VeryLazy', + }, + + { + 'lukas-reineke/indent-blankline.nvim', + opts = { + filetype_exclude = { + 'help', + 'alpha', + 'dashboard', + 'neo-tree', + 'Trouble', + 'lazy', + 'mason', + 'notify', + 'oil_preview', + 'vim', + }, + }, + event = 'BufReadPost', + }, + + { + 'folke/zen-mode.nvim', + opts = function() + return require('plugins.configs.UI.zen') + end, + config = true, + cmd = { 'ZenMode' }, + keys = { + { + 'z', + function() + require('zen-mode').toggle() + end, + desc = 'zen-mode', + }, + }, + dependencies = 'folke/twilight.nvim', + }, +} diff --git a/lua/plugins/specs/core.lua b/lua/plugins/specs/core.lua new file mode 100644 index 0000000..3ff6db0 --- /dev/null +++ b/lua/plugins/specs/core.lua @@ -0,0 +1,12 @@ +-- Core components, + +-- In general "core" components are dependencies of other plugins +-- If it requires more than just installing it probably shouldn't go here. + +return { + { 'munifTanjim/nui.nvim' }, + { 'nvim-lua/plenary.nvim' }, + { 'nvim-lua/popup.nvim' }, + { 'nvim-tree/nvim-web-devicons' }, + { 'rcarriga/nvim-notify' }, +} diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua new file mode 100644 index 0000000..c172216 --- /dev/null +++ b/lua/plugins/specs/editor.lua @@ -0,0 +1,54 @@ +return { + + { + 'nvim-treesitter/nvim-treesitter', + opts = function() + return require('plugins.configs.treesitter') + end, + config = function(_, opts) + -- to ensure the configuration can happen we need to do this here + -- otherwise the configuration of treesitter can't find it + require('lazy').load { plugins = { 'ts-rainbow' } } + + require('nvim-treesitter.configs').setup(opts) + end, + init = function() + require('core.utils.lazy')('nvim-treesitter') + end, + build = ':TSUpdate', + dependencies = { + { 'HiPhish/nvim-ts-rainbow2', name = 'ts-rainbow' }, + { 'nvim-treesitter/nvim-treesitter-textobjects' }, + }, + }, + + { + 'preservim/nerdcommenter', + event = 'VeryLazy', + init = function() + vim.g.NERDSpaceDelims = 1 + vim.g.NERDCompaceSexyComs = 1 + end, + keys = { + { 'cc', nil, desc = 'Comment line' }, + { 'cn', nil, desc = 'Comment line force nesting' }, + { 'c', nil, desc = 'Toggle comment selection' }, + { 'cm', nil, desc = 'Comment Minimal' }, + { 'ci', nil, desc = 'Toggle comment line' }, + { 'cs', nil, desc = 'Comment Sexy' }, + { 'cy', nil, desc = 'Comment and yank' }, + { 'c$', nil, desc = 'Comment to EOL' }, + { 'cA', nil, desc = 'Append comment' }, + { 'ca', nil, desc = 'Switch comment delimiters' }, + { 'cl', nil, desc = 'Comment align left' }, + { 'cb', nil, desc = 'Comment alight both' }, + { 'cu', nil, desc = 'Uncomment lines' }, + }, + }, + + { + 'mcauley-penney/tidy.nvim', + config = true, + event = 'BufWritePre', + }, +} diff --git a/lua/plugins/specs/previewers.lua b/lua/plugins/specs/previewers.lua new file mode 100644 index 0000000..b30df75 --- /dev/null +++ b/lua/plugins/specs/previewers.lua @@ -0,0 +1,13 @@ +return { + { + 'frabjous/knap', + init = function() + local gknapsettings = { + htmltohtmlviewerlaunch = 'microsoft-edge-stable %outputfile%', + markdowntohtmlviewerlaunch = 'microsoft-edge-stable %outputfile%', + mdtohtmlviewerlaunch = 'microsoft-edge-stable %outputfile%', + } + vim.g.knap_settings = gknapsettings + end, + }, +} diff --git a/lua/plugins/specs/telescope.lua b/lua/plugins/specs/telescope.lua new file mode 100644 index 0000000..61b03ed --- /dev/null +++ b/lua/plugins/specs/telescope.lua @@ -0,0 +1,99 @@ +--[[ + [ WARNING: This is potential spaghetti code written late at night to solve a problem that has yet to occur... + [ I strongly suggest to anyone reading this (and that means me) to double check what you think it does before + { making any attempt to edit it + ]] + +local telescope = {} +telescope.opts = {} + +-- default dependencies +telescope.dependencies = { ---@string[] + 'nvim-treesitter', + 'nvim-web-devicons', + 'plenary.nvim', + 'popup.nvim', +} + +telescope.keys = { ---@LazyKeys[] + -- Keys defined for finding files + { + 'fg', + 'Telescope live_grep', + desc = 'Find grep', + }, + { + 'fG', + 'Telescope git_files', + desc = 'Find git files', + }, + + -- Misc telescope functions + { + 'tc', + 'Telescope commands theme=dropdown', + desc = 'Command Pallet', + }, + { + 'ts', + 'Telescope current_buffer_fuzzy_find', + desc = 'Fuzzy find in buffer', + }, + { + 'tm', + 'Telescope man_pages sections=1,2,3,4,5,6,7,8,9', + desc = 'Man', + }, + { 'tt', 'Telescope builtin', desc = 'All pickers' }, +} + +-- This must exist even if we keep it empty for later configuration to work +telescope.opts.opts = { + defaults = {}, + pickers = {}, + extensions = {}, +} + +-- TESTS for telescope-media-files +if vim.fn.executable('chafa') then + -- if chafa is installed then we set a flag and add the dependency to telescope + telescope.opts.has_chafa = true + table.insert(telescope.dependencies, 'nvim-telescope/telescope-media-files.nvim') + telescope.opts.opts.extensions.media_files = { + filetypes = { 'png', 'jpg', 'jpeg', 'webp', 'svg' }, + } +end + +-- TESTS for telescope-fzf-native +-- If not windows then attempt to build and use it. +-- We also check a global flag here that we can set if we can't build fzf-native +if vim.fn.has('win32') == 0 and not vim.g.no_fzf then + -- NOTE: has returns 0 when we don't have a feature + telescope.opts.do_fzf = true + table.insert(telescope.dependencies, 'telescope-fzf-native.nvim') +end + +-- TESTS for fzf-native +telescope.config = function(_, opts) + require('telescope').setup() + if opts.has_chafa then require('telescope').load_extension('media_files') end + if opts.do_fzf then require('telescope').load_extension('fzf') end +end + +return { + { + 'nvim-telescope/telescope.nvim', + cmd = 'Telescope', + opts = telescope.opts, + config = telescope.config, + keys = telescope.keys, + dependencies = telescope.dependencies, + }, + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + cond = function() + return vim.fn.has('win32') == 0 and not vim.g.no_fzf + end, + }, +} diff --git a/lua/plugins/specs/vimwiki.lua b/lua/plugins/specs/vimwiki.lua new file mode 100644 index 0000000..ad6e0fb --- /dev/null +++ b/lua/plugins/specs/vimwiki.lua @@ -0,0 +1,53 @@ +return { + 'vimwiki/vimwiki', + init = function() + -- Get the XDG_DOCUMENTS_DIR if it exists + -- Otherwise use `$HOME/Documents` as default + local docdir = vim.env.HOME .. '/Documents' + if vim.env.XDG_DOCUMENTS_DIR then docdir = vim.env.XDG_DOCUMENTS_DIR end + + -- Logical layout for vimwiki, also stores it in Documents + -- keeping my home directory clean + local wikiroot = docdir .. '/vimwiki' + local mainWiki = { + path = wikiroot .. '/src', + path_html = wikiroot .. '/html', + template_path = wikiroot .. '/templates', + template_default = 'default', + auto_tags = 1, -- regenerate tag file on save + auto_diary_index = 1, -- update diary index on open + auto_export = 1, -- generate HTML on save + cycle_bullets = 1, + auto_toc = 1, + } + + vim.g.vimwiki_list = { mainWiki } + vim.g.vimwiki_global_ext = 0 + vim.g.vimwiki_dir_link = 'index' + end, + + -- Perfect Lazy-loading of everything. + ft = 'vimwiki', + cmd = { + 'VimwikiIndex', + 'VimwikiTabIndex', + 'VimwikiUISelect', + 'VimwikiVar', + 'VimwikiDiaryIndex', + 'VimwikiMakeDiaryNote', + 'VimwikiTabMakeDiaryNote', + 'VimwikiMakeYesterdayDiaryNote', + 'VimwikiMakeTomorrowDiaryNote', + }, + keys = { + { 'ww', nil, desc = '[vimwiki] index' }, + { 'wt', nil, desc = '[vimwiki] index ﱚ' }, + { 'ws', nil, desc = '[vimwiki] select' }, + { 'wi', nil, desc = '[vimwiki] diary index' }, + { 'ww', nil, desc = '[vimwiki] diary today' }, + { 'wt', nil, desc = '[vimwiki] diary today ﱚ' }, + { 'wy', nil, desc = '[vimwiki] diary yesterday' }, + { 'wm', nil, desc = '[vimwiki] diary tomorrow' }, + { 't', 'VimwikiTOC', desc = '[vimwiki] TOC' }, + }, +} diff --git a/lua/sherlock5512/colourSwitch.lua b/lua/sherlock5512/colourSwitch.lua new file mode 100644 index 0000000..9e05e2b --- /dev/null +++ b/lua/sherlock5512/colourSwitch.lua @@ -0,0 +1,23 @@ +-- A very dumb but functional way to switch between light and dark colourschemes. +-- Also with build in theme.sh integration. + +local function invertTheme() + if vim.o.background == 'dark' then + vim.o.background = 'light' + else + vim.o.background = 'dark' + end +end + +vim.keymap.set('n', 'i', invertTheme, { desc = 'Invert colourscheme' }) + +if vim.fn.executable('theme.sh') and vim.fn.exists('~/.config/.theme_history') then + local currentTheme = vim.fn.system('theme.sh -l | tail -n1', 'silent'):gsub('\n', '') + local lightThemes = vim.fn.systemlist('theme.sh --light -l') + + if vim.tbl_contains(lightThemes, currentTheme) then + vim.o.background = 'light' + else + vim.o.background = 'dark' + end +end diff --git a/luasnip/lua.lua b/luasnip/lua.lua new file mode 100644 index 0000000..c629c15 --- /dev/null +++ b/luasnip/lua.lua @@ -0,0 +1,18 @@ +-- Snippets to make editing my config a bit easier + +local ls = require('luasnip') +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node + +return { + -- This snippet is useful for adding in keybinds for lazy specs + s( + { trig = 'lkt', dscr = 'Lazy key table' }, + { t("{ '"), i(1), t("',"), i(2), t(", desc = '"), i(3), t("' },") } + ), +} diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add new file mode 100644 index 0000000..d8ef3de --- /dev/null +++ b/spell/en.utf-8.add @@ -0,0 +1 @@ +neovim diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl new file mode 100644 index 0000000000000000000000000000000000000000..2de8b99f700938842d3383029b8f83592e632404 GIT binary patch literal 37 kcmWIZ^erw(&B-zP&%nUI$C$^M%9zhs#+b>N%g6u+0JJ3r;Q#;t literal 0 HcmV?d00001 diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..558b000 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,5 @@ +column_width = 100 +indent_type = "Tabs" +quote_style = "AutoPreferSingle" +call_parentheses = "NoSingleTable" +collapse_simple_statement = "ConditionalOnly"