Compare commits

2 Commits
legacy ... main

Author SHA1 Message Date
139bd8546b add some more leader keymappings 2026-07-25 21:06:35 -05:00
b49309d6c3 major overhaul, draft 1 2026-07-25 20:52:59 -05:00
4 changed files with 127 additions and 54 deletions

View File

@@ -1,32 +1,55 @@
# neovim config # neovim config
I like neovim. I like neovim.
My goal with this repo was a relatively hands-free installation of nvim and everything needed to turn it into a decent everyday editor. It's not as feature-rich as something like VS code, but it should serve as a good lightweight alternative for most things I need to do.
**Note:** I recently gave this repo a major overhaul because I wanted autocomplete, better LSP support, and for nvim to feel like an actual editor. To view the old version of the config, you can view the `legacy` tag in this git repo
## requirements
* Neovim 0.12+
* npm installed globally
* tree-sitter cli (see [here](https://github.com/tree-sitter/tree-sitter/blob/master/crates/cli/README.md))
* Git, a C compiler, `curl`, `tar`, and `unzip` on your `$PATH`
See:
* https://github.com/folke/lazy.nvim#%EF%B8%8F-requirements
* https://github.com/nvim-treesitter/nvim-treesitter#requirements
* https://github.com/mason-org/mason.nvim#requirements
* https://github.com/mason-org/mason-lspconfig.nvim#requirements
* https://cmp.saghen.dev/installation#requirements
## installation ## installation
Everything required here is handled in my [install script](https://gitea.jovan04.com/evan/linux-post-install). If you want to install just this config manually:
```bash ```bash
# install neovim 0.11+ # install neovim 0.12+
sudo add-apt-repository ppa:neovim-ppa/unstable -y curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz
sudo apt update sudo rm -rf /opt/nvim-linux-x86_64
sudo apt install neovim -y sudo tar -C /opt -xzf nvim-linux-x86_64.tar.gz
rm nvim-linux-x86_64.tar.gz
# install dependencies # add /opt/nvim-linux-x86_64/bin/ to your $PATH
sudo apt install git ripgrep build-essential nodejs npm xclip -y # (put this in your shell's .rc file)
sudo npm install -g pyright export PATH="$PATH:/opt/nvim-linux-x86_64/bin"
# clone contents of this repo to ~/.config/nvim/ # install tree-sitter CLI
curl -LO https://github.com/tree-sitter/tree-sitter/releases/latest/download/tree-sitter-cli-linux-x64.zip
sudo unzip ./tree-sitter-cli-linux-x64.zip -d /opt/nvim-linux-x86_64/bin/
rm ./tree-sitter-cli-linux-x64.zip
# clone this repo to your nvim config
git clone https://gitea.jovan04.com/evan/neovim-config ~/.config/nvim git clone https://gitea.jovan04.com/evan/neovim-config ~/.config/nvim
# set up clipboard integrations # it might also be helpful to set up an alias (also in .rc)
sudo mkdir -p /usr/local/bin alias nv="nvim"
sudo printf '#!/bin/bash \nxclip -selection clipboard' | tee /usr/local/bin/pbcopy
sudo chmod a+x /usr/local/bin/pbcopy
sudo printf '#!/bin/bash \nxclip -selection clipboard -o' | tee /usr/local/bin/pbpaste
sudo chmod a+x /usr/local/bin/pbpaste
``` ```
don't forget to set up an `alias nv='nvim'`
## includes ## includes
- Lazy.nvim plugin manager - Lazy.nvim plugin manager
- treesitter syntax highlighting (with auto-install) - treesitter syntax highlighting and autoindent
- nvim-lspconfig - nvim-lspconfig
- pyright language server - mason.nvim & mason-lspconfig language server manager
- blink.cmp autocompletions
- keybindings (mostly LSP-related) - keybindings (mostly LSP-related)

115
init.lua
View File

@@ -1,10 +1,21 @@
vim.cmd("set ww=<,>,[,],h,l") vim.g.mapleader = "\\"
vim.cmd("colorscheme slate") vim.cmd("colorscheme slate")
vim.cmd("set linebreak")
vim.cmd("set number") vim.opt.ww = "<,>,[,],h,l"
vim.cmd("set ruler") vim.opt.linebreak = true
vim.cmd("set expandtab") vim.opt.number = true
vim.cmd("set shiftwidth=4 smarttab") vim.opt.ruler = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.smarttab = true
vim.keymap.set('n', '<leader>q', ':q<CR>', {})
vim.keymap.set('n', '<leader>w', ':w<CR>', {})
vim.keymap.set('v', '<leader>y', '"+y', {})
vim.keymap.set('n', '<leader>y', '"+yy', {})
vim.keymap.set('n', '<leader>p', '"+p', {})
vim.keymap.set('n', '<leader>P', '"+P', {})
-- writing mode for markdown files -- writing mode for markdown files
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
@@ -16,47 +27,83 @@ vim.api.nvim_create_autocmd("FileType", {
end, end,
}) })
-- Bootstrap lazy.nvim (from https://lazy.folke.io/installation)
vim.deprecate = function() end
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({ local lazyrepo = "https://github.com/folke/lazy.nvim.git"
"git", local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
"clone", if vim.v.shell_error ~= 0 then
"--filter=blob:none", vim.api.nvim_echo({
"https://github.com/folke/lazy.nvim.git", { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
lazypath, { out, "WarningMsg" },
}) { "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("lazy").setup({ require("lazy").setup({
-- Better syntax highlighting -- Better syntax highlighting
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate", lazy = false,
}, build = ":TSUpdate",
},
-- Easy LSP config (works with pyright) -- temporarily disable b/c it wasn't working
{ -- { "arborist-ts/arborist.nvim" }, -- replacement for treesitter w/ auto-install on opening files
"neovim/nvim-lspconfig",
}, -- LSP configs
{ "neovim/nvim-lspconfig" },
{ "mason-org/mason.nvim" },
{ "mason-org/mason-lspconfig.nvim",
opts = {
ensure_installed = { "pyright", "ts_ls", "clangd" },
},
dependencies = {
{ "mason-org/mason.nvim", opts = {} },
"neovim/nvim-lspconfig",
},
},
{ "saghen/blink.cmp",
version = "1.*",
dependencies = { 'rafamadriz/friendly-snippets' },
opts = {
keymap = {
preset = "default",
['<CR>'] = { 'select_and_accept', 'fallback' },
['<Tab>'] = { 'snippet_forward', 'select_and_accept', 'fallback' },
},
completion = {
documentation = { auto_show = true },
},
sources = { default = { 'lsp', 'path' } }, -- add 'snippets' for e.g. a pre-formatted `for` loop
},
},
}) })
local lspconfig = require("lspconfig") -- require("arborist").setup({
lspconfig.pyright.setup({}) -- install_popular = false,
-- prefer_wasm = false,
-- })
require("nvim-treesitter.configs").setup({ -- turn on treesitter highlighting
auto_install = true, vim.api.nvim_create_autocmd('FileType', {
highlight = { pattern = { '*' },
enable = true, callback = function()
}, pcall(vim.treesitter.start)
end,
}) })
-- LSP stuff
vim.keymap.set('n', ' ', vim.lsp.buf.hover, {}) vim.keymap.set('n', ' ', vim.lsp.buf.hover, {})
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {})
vim.keymap.set('n', 'gD', vim.lsp.buf.references, {})
vim.keymap.set('n', 'cd', vim.lsp.buf.rename, {}) vim.keymap.set('n', 'cd', vim.lsp.buf.rename, {})
vim.keymap.set('n', 'g.', vim.lsp.buf.code_action, {}) vim.keymap.set('n', 'g.', vim.lsp.buf.code_action, {})
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float) vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float)

View File

@@ -1,5 +1,9 @@
{ {
"blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" },
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"nvim-lspconfig": { "branch": "master", "commit": "e0fae251f8459940331960106d4bd9457cec23de" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "7adc933dabcc7c86ae6b07aff7ee68eac398491f" },
"nvim-treesitter": { "branch": "main", "commit": "42fc28ba918343ebfd5565147a42a26580579482" } "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" },
"nvim-lspconfig": { "branch": "master", "commit": "d592c1e6ad9a0a01b3d5ed3f0345d68407167181" },
"nvim-treesitter": { "branch": "main", "commit": "8b3a191c015dd66a92d51a112ed96af0aac13b63" }
} }

Submodule pack/nvim/start/nvim-lspconfig deleted from 03bc581e05