diff --git a/README.md b/README.md index db93bd8..e264112 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,48 @@ +
+ + Buy Me A Coffee + +
+ # Introduction -`minimal.nvim` comes in two flavors: `bare-minimum` and `featureful`. Whereas -the first contains only the bare minimum for having completions + lsp + fuzzy -finding in neovim, the featureful version also contains some quality of -life/appearance plugins +`minimal.nvim` is a neovim 0.12 configuration written in lua. this is not meant +to be a distribution, but rather a template for you to build upon and/or a +reference for how to configure neovim using lua in the latest version. -## Screenshots +it comes in three flavors: `featureful`, `light` and `minimal`. -bare-minimum version: -![bare-minimum](screenshots/bare-minimum.png) +- `featureful`: sane default options, highlighting, lsp diagnostics, + completions, fuzzy finding and some quality-of-life/appearance plugins. + heavily documented. +- `light`: sane default options, highlighting, lsp diagnostics, completions and + fuzzy finding. heavily documented +- `minimal`: the absolute bare minimal for sane default options, highlighting, + lsp diagnostics and completions. no documentation in code -featureful version: +## Screenshots + +featureful: ![featureful](screenshots/featureful.png) +light: +![light](screenshots/light.png) + +minimal: +![minimal](screenshots/minimal.png) + # Installation Requires neovim version `0.12` or greater ## Dependencies - `git` - for vim builtin package manager. (see `:h vim.pack`) -- `unzip` - for [mason](https://github.com/mason-org/mason.nvim), specifically for `clangd`, which the config installs by default - `ripgrep` - for fuzzy finding - clipboard tool: xclip/xsel/win32yank - for clipboard sharing between OS and neovim (see `h: clipboard-tool`) - a [nerd font](https://www.nerdfonts.com/) (ensure the terminal running neovim is using it) +> [!NOTE] +> for the minimal version, only `git` is required. + --- to install run: @@ -29,36 +50,69 @@ to install run:
Linux/MacOS/WSL -for `bare-minimum`: +--- +
featureful version + +```bash +mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim && wget https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/featureful/init.lua -O "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim/init.lua && nvim -c ':e $MYVIMRC' ``` -mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim && wget https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/bare-minimum/init.lua -O "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim/init.lua && nvim -c ':e $MYVIMRC' -``` -for `featureful`: +
+ +
light version +```bash +mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim && wget https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/light/init.lua -O "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim/init.lua && nvim -c ':e $MYVIMRC' ``` -mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim && wget https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/featureful/init.lua -O "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim/init.lua && nvim -c ':e $MYVIMRC' + +
+ +
minimal version + +```bash +mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim && wget https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/minimal/init.lua -O "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim/init.lua && nvim -c ':e $MYVIMRC' ``` + +
+ +--- +
Windows (Powershell) -for `bare-minimum`: +--- + +
featureful version ```powershell -mkdir -Force $env:LOCALAPPDATA\nvim\ && curl https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/bare-minimum/init.lua -o $env:LOCALAPPDATA\nvim\init.lua && nvim -c ':e $MYVIMRC' +mkdir -Force $env:LOCALAPPDATA\nvim\ && curl https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/featureful/init.lua -o $env:LOCALAPPDATA\nvim\init.lua && nvim -c ':e $MYVIMRC' +``` + +
+ +
light version +```powershell +mkdir -Force $env:LOCALAPPDATA\nvim\ && curl https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/light/init.lua -o $env:LOCALAPPDATA\nvim\init.lua && nvim -c ':e $MYVIMRC' ``` -for `featureful`: + +
+ +
minimal version ```powershell -mkdir -Force $env:LOCALAPPDATA\nvim\ && curl https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/featureful/init.lua -o $env:LOCALAPPDATA\nvim\init.lua && nvim -c ':e $MYVIMRC' +mkdir -Force $env:LOCALAPPDATA\nvim\ && curl https://raw.githubusercontent.com/Hashino/minimal.nvim/refs/heads/minimal/init.lua -o $env:LOCALAPPDATA\nvim\init.lua && nvim -c ':e $MYVIMRC' ``` + +
+ +---
-or download [init.lua](init.lua) via the browser to the neovim config directory: +or download [init.lua](init.lua) via the browser from the respective branch to the neovim config directory: ### Location Neovim's configurations are located under the following paths, depending on your OS: diff --git a/init.lua b/init.lua index 5526df8..b20a2fc 100644 --- a/init.lua +++ b/init.lua @@ -1,301 +1,57 @@ --- INFO: introduction --- this is a minimal neovim configuration written in lua. this is not meant to --- be a distribution, but rather a template for you to build upon and/or a --- reference for how to configure neovim using lua in the latest version. --- --- TUTOR: --- if you're completely new to neovim and/or vim, consider going through --- `:Tutor` inside neovim to get a basic idea of how it works. --- if you don't know what this means, type the following: --- - --- - : --- - Tutor --- - --- --- LUA: --- some level of familiarity with lua/programming languages are also expected. --- if you're new to lua, consider going through the official reference: --- https://www.lua.org/manual --- or a more friendly tutorial like: --- https://learnxinyminutes.com/docs/lua/ --- you can also check out `:h lua-guide` inside neovim for a neovim-specific --- lua guide. --- --- DEPENDENCIES: --- this configuration assumes you have the following tools installed on your --- system: --- `git` - for vim builtin package manager. (see `:h vim.pack`) --- `unzip` - for mason, specifically for `clangd`, which the config installs by default --- `ripgrep` - for fuzzy finding --- clipboard tool: xclip/xsel/win32yank - for clipboard sharing between OS and neovim (see `h: clipboard-tool`) --- a nerdfont (ensure the terminal running neovim is using it) --- run `:checkhealth` inside neovim to see if your system is missing anything. --- --- MINIMAL: --- to say that something is 'minimal' you have to define what variable you're --- minimizing. this configuration minimizes for lines of code and concepts. --- to some, this configuration may have too many plugins. for example, using --- mason.nvim to manage lsp servers will be an unnecessary dependency if the --- user is already familiar with lsps and is comfortable managing them through --- their OS package manager. but to someone that isn't familiar with lsp servers --- this approach wouldn't cover everything needed to have the 'minimum' necessary --- for lsp + completion + fuzzy finding. to some, fuzzy finding is also a bloated --- dependency. --- this configuration is only a starting point/reference. it is expected that --- the user will change the configuration to suit their needs. - - --- INFO: options --- these change the default neovim behaviours using the 'vim.opt' API. --- see `:h vim.opt` for more details. --- run `:h '{option_name}'` to see what they do and what values they can take. --- for example, `:h 'number'` for `vim.opt.number`. - --- set as the leader key --- must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = " " -vim.g.maplocalleader = " " - --- enable true color support -vim.opt.termguicolors = true - --- make line numbers default vim.opt.number = true vim.opt.relativenumber = true --- enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = "a" - --- sync clipboard between OS and Neovim. --- remove this option if you want your OS clipboard to remain independent. --- see `:help 'clipboard'` -vim.opt.clipboard = "unnamedplus" - --- enable break indent -vim.opt.breakindent = true - --- save undo history -vim.opt.undofile = true - --- case-insensitive searching UNLESS \C or one or more capital letters in the search term -vim.opt.ignorecase = true -vim.opt.smartcase = true - --- keep signcolumn on by default vim.opt.signcolumn = "yes" --- decrease update time -vim.opt.updatetime = 250 - --- decrease mapped sequence wait time --- displays which-key popup sooner -vim.opt.timeoutlen = 300 - --- configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = true - --- sets how neovim will display certain whitespace characters in the editor. --- See `:help 'list'` --- and `:help 'listchars'` -vim.opt.list = true -vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣", } - --- preview substitutions live, as you type! -vim.opt.inccommand = "split" - --- show which line your cursor is on -vim.opt.cursorline = true - --- set highlight on search, but clear on pressing in normal mode -vim.opt.hlsearch = true - --- enable line wrapping -vim.opt.wrap = true - --- formatting vim.opt.tabstop = 2 vim.opt.shiftwidth = 2 vim.opt.expandtab = true vim.opt.textwidth = 80 -vim.diagnostic.config({ - signs = { - text = { - [vim.diagnostic.severity.ERROR] = " ", - [vim.diagnostic.severity.WARN] = " ", - [vim.diagnostic.severity.INFO] = " ", - [vim.diagnostic.severity.HINT] = " ", - }, - }, - virtual_text = true, -- show inline diagnostics -}) - --- clear search highlights with -vim.keymap.set("n", "", "nohlsearch") +vim.diagnostic.config({ virtual_text = true }) --- INFO: plugins --- we install plugins with neovim's builtin package manager: vim.pack --- and then enable/configure them by calling their setup functions. --- --- (see `:h vim.pack` for more details on how it works) --- you can press `gx` on any of the plugin urls below to open them in your --- browser and check out their documentation and functionality. --- alternatively, you can run `:h {plugin-name}` to read their documentation. --- --- plugins are then loaded and configured with a call to `setup` functions --- provided by each plugin. this is not a rule of neovim but rather a convention --- followed by the community. --- these setup calls take a table as an agument and their expected contents can --- vary wildly. refer to each plugin's documentation for details. +vim.cmd.colorscheme("catppuccin") --- INFO: formatting and syntax highlighting -vim.pack.add({ "https://github.com/nvim-treesitter/nvim-treesitter" }, { confirm = false }) - --- equivalent to :TSUpdate -require("nvim-treesitter.install").update("all") +vim.pack.add({ + "https://github.com/nvim-treesitter/nvim-treesitter", + "https://github.com/saghen/blink.cmp", + "https://github.com/neovim/nvim-lspconfig", + "https://github.com/mason-org/mason.nvim", + "https://github.com/mason-org/mason-lspconfig.nvim", + "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim", +}, { confirm = false }) require("nvim-treesitter.configs").setup({ - sync_install = true, - - modules = {}, - ignore_install = {}, - - ensure_installed = { - "lua", - "c", - "rust", - "go", - }, - - auto_install = true, -- autoinstall languages that are not installed yet - - highlight = { - enable = true, - }, + auto_install = true, }) --- INFO: completion engine -vim.pack.add({ "https://github.com/saghen/blink.cmp" }, { confirm = false }) - -require("blink.cmp").setup({ - completion = { - documentation = { - auto_show = true, - }, - }, - - sources = { - default = { - "lsp", - "path", - }, - }, - - -- default blink keymaps - keymap = { - [''] = { 'select_prev', 'fallback_to_mappings' }, - [''] = { 'select_next', 'fallback_to_mappings' }, - - [''] = { 'select_and_accept', 'fallback' }, - [''] = { 'cancel', 'fallback' }, - [''] = { 'show', 'show_documentation', 'hide_documentation' }, - - [''] = { 'snippet_forward', 'fallback' }, - [''] = { 'snippet_backward', 'fallback' }, - - [''] = { 'scroll_documentation_up', 'fallback' }, - [''] = { 'scroll_documentation_down', 'fallback' }, - - [''] = { 'show_signature', 'hide_signature', 'fallback' }, - }, - - fuzzy = { - implementation = "lua", - }, +vim.api.nvim_create_autocmd("FileType", { + callback = function(args) + local lang = vim.treesitter.language.get_lang(vim.bo[args.buf].filetype) + if lang and vim.treesitter.language.add(lang) then + vim.treesitter.start(args.buf, lang) + end + end, }) --- INFO: lsp server installation and configuration +require("blink.cmp").setup({ fuzzy = { implementation = "lua" } }) --- lsp servers we want to use and their configuration --- see `:h lspconfig-all` for available servers and their settings local lsp_servers = { - lua_ls = { - Lua = { - workspace = { - library = vim.api.nvim_get_runtime_file('', true) - }, - }, - }, - clangd = {}, - rust_analyzer = {}, - gopls = {}, + lua_ls = { Lua = { workspace = { library = vim.api.nvim_get_runtime_file("lua", true) } }, }, } -vim.pack.add({ - "https://github.com/neovim/nvim-lspconfig", -- default configs for lsps - - -- NOTE: if you'd rather install the lsps through your OS package manager you - -- can delete the next three mason-related lines and their setup calls below. - -- see `:h lsp-quickstart` for more details. - "https://github.com/mason-org/mason.nvim", -- package manager - "https://github.com/mason-org/mason-lspconfig.nvim", -- lspconfig bridge - "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" -- auto installer -}, { confirm = false }) - require("mason").setup() require("mason-lspconfig").setup() require("mason-tool-installer").setup({ ensure_installed = vim.tbl_keys(lsp_servers), }) --- configure each lsp server on the table --- to check what clients are attached to the current buffer, use --- `:checkhealth vim.lsp`. to view default lsp keybindings, use `:h lsp-defaults`. for server, config in pairs(lsp_servers) do vim.lsp.config(server, { settings = config, - -- only create the keymaps if the server attaches successfully on_attach = function(_, bufnr) - vim.keymap.set("n", "grd", vim.lsp.buf.definition, - { buffer = bufnr, desc = "vim.lsp.buf.definition()", }) - - vim.keymap.set("n", "f", vim.lsp.buf.format, - { buffer = bufnr, desc = "LSP: [F]ormat Document", }) + vim.keymap.set("n", "grd", vim.lsp.buf.definition, { buffer = bufnr }) end, }) end - --- INFO: fuzzy finder -vim.pack.add({ - "https://github.com/nvim-lua/plenary.nvim", -- library dependency - "https://github.com/nvim-tree/nvim-web-devicons", -- nerdfont icons - "https://github.com/nvim-telescope/telescope.nvim" -}, { confirm = false }) - -require("telescope").setup({}) - -local pickers = require("telescope.builtin") - -vim.keymap.set("n", "sp", pickers.builtin, { desc = "[S]earch Builtin [P]ickers", }) -vim.keymap.set("n", "sb", pickers.buffers, { desc = "[S]earch [B]uffers", }) -vim.keymap.set("n", "sf", pickers.find_files, { desc = "[S]earch [F]iles", }) -vim.keymap.set("n", "sw", pickers.grep_string, { desc = "[S]earch Current [W]ord", }) -vim.keymap.set("n", "sg", pickers.live_grep, { desc = "[S]earch by [G]rep", }) -vim.keymap.set("n", "sr", pickers.resume, { desc = "[S]earch [R]esume", }) - -vim.keymap.set("n", "sh", pickers.help_tags, { desc = "[S]earch [H]elp", }) -vim.keymap.set("n", "sm", pickers.man_pages, { desc = "[S]earch [M]anuals", }) - --- INFO: keybinding helper -vim.pack.add({ "https://github.com/folke/which-key.nvim" }, { confirm = false }) - -require("which-key").setup({ - spec = { - { "s", group = "[S]earch", icon = { icon = "", color = "green", }, }, - } -}) - --- uncomment to enable automatic plugin updates --- vim.pack.update() diff --git a/screenshots/bare-minimum.png b/screenshots/bare-minimum.png deleted file mode 100644 index 06882e4..0000000 Binary files a/screenshots/bare-minimum.png and /dev/null differ diff --git a/screenshots/featureful.png b/screenshots/featureful.png index fea83e7..502bc61 100644 Binary files a/screenshots/featureful.png and b/screenshots/featureful.png differ diff --git a/screenshots/light.png b/screenshots/light.png new file mode 100644 index 0000000..96bf540 Binary files /dev/null and b/screenshots/light.png differ diff --git a/screenshots/minimal.png b/screenshots/minimal.png new file mode 100644 index 0000000..90fa6f0 Binary files /dev/null and b/screenshots/minimal.png differ