major overhaul, draft 1

This commit is contained in:
2026-07-25 20:52:59 -05:00
parent 5c791bc2d4
commit b49309d6c3
4 changed files with 117 additions and 55 deletions

View File

@@ -1,32 +1,51 @@
# neovim config
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
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
# install neovim 0.11+
sudo add-apt-repository ppa:neovim-ppa/unstable -y
sudo apt update
sudo apt install neovim -y
# install neovim 0.12+
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz
sudo rm -rf /opt/nvim-linux-x86_64
sudo tar -C /opt -xzf nvim-linux-x86_64.tar.gz
rm nvim-linux-x86_64.tar.gz
# install dependencies
sudo apt install git ripgrep build-essential nodejs npm xclip -y
sudo npm install -g pyright
# add /opt/nvim-linux-x86_64/bin/ to your $PATH
# (put this in your shell's .rc file)
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
# set up clipboard integrations
sudo mkdir -p /usr/local/bin
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
- Lazy.nvim plugin manager
- treesitter syntax highlighting (with auto-install)
- treesitter syntax highlighting and autoindent
- nvim-lspconfig
- pyright language server
- mason.nvim & mason-lspconfig language server manager
- blink.cmp autocompletions
- keybindings (mostly LSP-related)

108
init.lua
View File

@@ -1,10 +1,14 @@
vim.cmd("set ww=<,>,[,],h,l")
vim.g.mapleader = "\\"
vim.cmd("colorscheme slate")
vim.cmd("set linebreak")
vim.cmd("set number")
vim.cmd("set ruler")
vim.cmd("set expandtab")
vim.cmd("set shiftwidth=4 smarttab")
vim.opt.ww = "<,>,[,],h,l"
vim.opt.linebreak = true
vim.opt.number = true
vim.opt.ruler = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.smarttab = true
-- writing mode for markdown files
vim.api.nvim_create_autocmd("FileType", {
@@ -16,47 +20,83 @@ vim.api.nvim_create_autocmd("FileType", {
end,
})
vim.deprecate = function() end
-- Bootstrap lazy.nvim
-- Bootstrap lazy.nvim (from https://lazy.folke.io/installation)
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
-- Better syntax highlighting
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
},
-- Better syntax highlighting
{
"nvim-treesitter/nvim-treesitter",
lazy = false,
build = ":TSUpdate",
},
-- Easy LSP config (works with pyright)
{
"neovim/nvim-lspconfig",
},
-- temporarily disable b/c it wasn't working
-- { "arborist-ts/arborist.nvim" }, -- replacement for treesitter w/ auto-install on opening files
-- 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")
lspconfig.pyright.setup({})
-- require("arborist").setup({
-- install_popular = false,
-- prefer_wasm = false,
-- })
require("nvim-treesitter.configs").setup({
auto_install = true,
highlight = {
enable = true,
},
-- turn on treesitter highlighting
vim.api.nvim_create_autocmd('FileType', {
pattern = { '*' },
callback = function()
pcall(vim.treesitter.start)
end,
})
-- LSP stuff
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.references, {})
vim.keymap.set('n', 'cd', vim.lsp.buf.rename, {})
vim.keymap.set('n', 'g.', vim.lsp.buf.code_action, {})
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" },
"nvim-lspconfig": { "branch": "master", "commit": "e0fae251f8459940331960106d4bd9457cec23de" },
"nvim-treesitter": { "branch": "main", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }
"mason-lspconfig.nvim": { "branch": "main", "commit": "7adc933dabcc7c86ae6b07aff7ee68eac398491f" },
"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