strip down

master
george 2 weeks ago
parent 9d817cb25a
commit bb35f98a3e

@ -1,191 +0,0 @@
# Neovim Config
This is a vim-plug based Neovim config with:
- LSP via `nvim-lspconfig`
- Completion via `nvim-cmp` and LuaSnip
- Search via Telescope
- File browsing via Oil
- LaTeX workflow via VimTeX and TexLab
- Formatting via LSP, `latexindent`, and `neoformat` fallback
## Main Files
- `init.vim`: plugin list and Vimscript globals
- `lua/init.lua`: Lua setup, keymaps, completion, LSP, and plugin config
## Plugin Manager
This config uses `vim-plug`.
Common commands:
- `:PlugInstall`
- `:PlugUpdate`
- `:PlugClean`
## Required External Software
### LSP Servers
These are the language servers configured in `lua/init.lua` and the binaries they expect to find on `PATH`.
| LSP config | Expected binary or package |
| --- | --- |
| `ts_ls` | `typescript-language-server` and `typescript` |
| `clangd` | `clangd` |
| `gopls` | `gopls` |
| `pyright` | `pyright` |
| `texlab` | `texlab` |
| `rust_analyzer` | `rust-analyzer` |
| `kotlin-language-server` | `kotlin-language-server` |
| `cmake` | `cmake-language-server` |
| `html` | `vscode-html-language-server` from `vscode-langservers-extracted` |
| `glsl_analyzer` | `glsl_analyzer` |
| `lua_ls` | `lua-language-server` |
| `zls` | `zls` |
### LaTeX Toolchain
These are used by the current LaTeX setup.
| Tool | Purpose |
| --- | --- |
| `pdflatex` | TeX engine |
| `latexmk` | Project-aware TeX build runner |
| `latexindent` | TeX formatter |
| `texlab` | LaTeX LSP |
| `zathura` | Optional PDF viewer with SyncTeX support |
| `xdg-open` | Generic PDF opener fallback |
### Other Useful Runtime Tools
| Tool | Purpose |
| --- | --- |
| `cargo` | Used here to install `texlab` |
| `git` | Required by vim-plug and Telescope git search |
## Leaders
- `Leader` = `<Space>`
- `LocalLeader` = `,`
## Key Shortcuts
## Search And Buffers
| Mode | Shortcut | Action |
| --- | --- | --- |
| Normal | `<C-p>` | Search tracked git files |
| Normal | `<C-f>` | Search all files |
| Normal | `<leader>f` | Grep the project |
| Normal | `<leader>/` | Fuzzy search the current buffer |
| Normal | `<leader>fh` | Search help tags |
| Normal | `<leader>fr` | Open recent files |
| Normal | `<leader>fu` | Open undo history in Telescope |
| Normal | `<leader><Tab>` | Switch buffers |
## File Browsing
| Mode | Shortcut | Action |
| --- | --- | --- |
| Normal | `-` | Open parent directory in Oil |
| Normal | `<leader>e` | Open Oil file explorer |
| Normal | `<leader>E` | Open the current file's directory in Oil |
## LSP And Diagnostics
| Mode | Shortcut | Action |
| --- | --- | --- |
| Normal | `gd` | Go to definition |
| Normal | `gr` | List references |
| Normal | `gi` | List implementations |
| Normal | `K` | Show hover documentation |
| Normal | `L` | Show diagnostics in a float |
| Normal, Visual | `<leader>ca` | Run a code action |
| Normal | `<leader>rn` | Rename symbol |
| Normal | `[d` | Jump to previous diagnostic |
| Normal | `]d` | Jump to next diagnostic |
| Normal | `<leader>q` | Send diagnostics to the location list |
| Normal | `<leader>fm` | Format the current buffer |
## LaTeX Workflow
| Mode | Shortcut | Action |
| --- | --- | --- |
| Normal | `<leader>tc` | Compile TeX document |
| Normal | `<leader>tk` | Stop TeX compilation |
| Normal | `<leader>tv` | Open or refresh TeX PDF viewer |
| Normal | `<leader>to` | Show TeX compiler output |
| Normal | `<leader>tt` | Toggle TeX table of contents |
| Normal | `<leader>te` | Show TeX errors |
| Normal | `<leader>tl` | Clean TeX build files |
## Editing And Movement
| Mode | Shortcut | Action |
| --- | --- | --- |
| Normal, Visual | `<leader>y` | Yank to system clipboard |
| Normal | `<leader>u` | Toggle Undotree |
| Normal, Visual, Operator-pending | `s` | Jump with Flash |
| Normal, Visual, Operator-pending | `S` | Jump to Tree-sitter targets with Flash |
## Completion
### Insert Mode
| Shortcut | Action |
| --- | --- |
| `<C-b>` | Scroll completion documentation up |
| `<C-f>` | Scroll completion documentation down |
| `<C-Space>` | Open completion menu |
| `<C-e>` | Abort completion |
| `<Tab>` | Confirm selected completion item |
### Command Line And Search
| Mode | Shortcut | Action |
| --- | --- | --- |
| `/` command line | `<Tab>` and completion menu | Complete from current buffer |
| `:` command line | `<Tab>` and completion menu | Complete paths and commands |
## Plugin Defaults Still Enabled
### Comment.nvim
| Mode | Shortcut | Action |
| --- | --- | --- |
| Normal | `gcc` | Toggle comment on current line |
| Visual | `gc` | Toggle comment on selection |
| Operator-pending | `gc{motion}` | Toggle comment over a motion |
### vim-surround
| Mode | Shortcut | Action |
| --- | --- | --- |
| Normal | `ys{motion}{char}` | Add surrounding characters |
| Normal | `yss{char}` | Surround current line |
| Normal | `cs{old}{new}` | Change surrounding characters |
| Normal | `ds{char}` | Delete surrounding characters |
| Visual | `S{char}` | Surround the selection |
### VimTeX Common Defaults
| Mode | Shortcut | Action |
| --- | --- | --- |
| Normal | `<localleader>ll` | Start or toggle VimTeX compilation |
| Normal | `<localleader>lk` | Stop VimTeX compilation |
| Normal | `<localleader>lc` | Clean auxiliary files |
| Normal | `<localleader>lv` | Open or forward-search the PDF |
| Normal | `<localleader>lo` | Open compiler output |
| Normal | `<localleader>lt` | Open VimTeX table of contents |
| Normal | `[[` / `]]` | Move between section boundaries |
| Normal | `[m` / `]m` | Move between environment boundaries |
| Visual, Operator-pending | `ie` / `ae` | Select inside or around a LaTeX environment |
| Visual, Operator-pending | `i$` / `a$` | Select inside or around math |
## Notes
- TeX formatting uses `latexindent` when editing `*.tex` files.
- The generic format key is still `<leader>fm`; it switches to `latexindent` automatically for TeX buffers.
- `vimtex` provides many more text objects, motions, and local mappings than listed here. Use `:help vimtex-default-mappings` and `:help vimtex` for the full set.

@ -26,55 +26,33 @@ set list
call plug#begin("~/.nvim/plugged")
Plug 'rust-lang/rust.vim' " Rust filetype support
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Tree-sitter highlighting
Plug 'neovim/nvim-lspconfig' " LSP client configs
Plug 'mbbill/undotree' " Undo history browser
Plug 'sbdchd/neoformat' " Formatter fallback
Plug 'folke/tokyonight.nvim', { 'branch': 'main' } " Active colour scheme
Plug 'nvim-lua/plenary.nvim' " Lua utility library
Plug 'nvim-telescope/telescope.nvim' " Fuzzy finder UI
Plug 'nvim-telescope/telescope-fzy-native.nvim' " Telescope sorter
Plug 'nvim-telescope/telescope-ui-select.nvim' " Telescope vim.ui.select bridge
Plug 'debugloop/telescope-undo.nvim' " Undo history picker
Plug 'psliwka/vim-smoothie' " Smooth scrolling
Plug 'darrikonn/vim-gofmt', { 'do': ':GoUpdateBinaries' } " Go formatting helpers
Plug 'stevearc/oil.nvim' " Primary file explorer
Plug 'nvim-tree/nvim-web-devicons' " Filetype icons
Plug 'udalov/kotlin-vim' " Kotlin syntax support
Plug 'hrsh7th/cmp-nvim-lsp' " LSP completion source
Plug 'hrsh7th/cmp-buffer' " Buffer completion source
Plug 'hrsh7th/cmp-path' " Path completion source
Plug 'hrsh7th/cmp-cmdline' " Command-line completion source
Plug 'hrsh7th/nvim-cmp' " Completion engine
Plug 'L3MON4D3/LuaSnip' " Snippet engine
Plug 'rafamadriz/friendly-snippets' " Community snippet pack
Plug 'lervag/vimtex' " LaTeX workflow plugin
Plug 'windwp/nvim-autopairs' " Auto-close brackets and quotes
Plug 'numToStr/Comment.nvim' " Comment toggles
Plug 'tpope/vim-surround' " Surround text objects
Plug 'itchyny/lightline.vim' " Statusline
Plug 'tpope/vim-fugitive' " Git commands
Plug 'simrat39/rust-tools.nvim' " Extra Rust tooling
let maplocalleader = ","
let g:tex_flavor = 'latex'
let g:vimtex_compiler_method = 'latexmk'
let g:vimtex_quickfix_method = 'latexlog'
if executable('zathura')
let g:vimtex_view_method = 'zathura'
elseif executable('xdg-open')
let g:vimtex_view_method = 'general'
let g:vimtex_view_general_viewer = 'xdg-open'
let g:vimtex_view_general_options = '@pdf'
endif
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Treesitter highlighting
Plug 'folke/tokyonight.nvim', {'branch': 'main' } " Active colour scheme
Plug 'stevearc/oil.nvim'
Plug 'akinsho/toggleterm.nvim'
Plug 'ibhagwan/fzf-lua'
call plug#end()
colorscheme tokyonight
syntax off
packadd matchit
let mapleader = " "
lua require("init")
lua require('treesitter')
lua require('man-config')
lua require('fzf-config')
lua require('oil-config')
lua require('toggleterm').setup({ direction = "horizontal", size = 15 })
command! Cheats edit ~/.config/nvim/cheats.md
nnoremap <leader>h :nohlsearch<CR>
nnoremap <C-t> <cmd>lua require('toggleterm').toggle(1, 15, vim.fn.expand('%:p:h'), 'horizontal')<CR>
tnoremap <C-t> <cmd>lua require('toggleterm').toggle(1, 15, vim.fn.expand('%:p:h'), 'horizontal')<CR>
nnoremap <leader>y "+y
vnoremap <leader>y "+y
nnoremap <leader>p "+p
colorscheme tokyonight-night

@ -1,276 +0,0 @@
local cmp = require("cmp")
local luasnip = require("luasnip")
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local telescope = require("telescope")
local builtin = require("telescope.builtin")
local themes = require("telescope.themes")
local map = vim.keymap.set
local ok_autopairs, autopairs = pcall(require, "nvim-autopairs")
local ok_cmp_autopairs, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp")
local ok_comment, comment = pcall(require, "Comment")
local ok_flash, flash = pcall(require, "flash")
local ok_oil, oil = pcall(require, "oil")
vim.opt.completeopt = { "menu", "menuone", "noselect" }
vim.filetype.add({
extension = {
jai = "jai",
},
})
local function format_tex_buffer()
local result = vim.system({ "latexindent" }, {
stdin = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n") .. "\n",
text = true,
}):wait()
if result.code ~= 0 then
vim.notify(result.stderr ~= "" and result.stderr or "latexindent failed", vim.log.levels.ERROR)
return
end
local formatted = vim.split(result.stdout or "", "\n", { plain = true, trimempty = false })
if formatted[#formatted] == "" then
table.remove(formatted, #formatted)
end
local view = vim.fn.winsaveview()
vim.api.nvim_buf_set_lines(0, 0, -1, false, formatted)
vim.fn.winrestview(view)
end
local function format_buffer()
if vim.bo.filetype == "tex" and vim.fn.executable("latexindent") == 1 then
format_tex_buffer()
return
end
vim.lsp.buf.format({ async = true })
end
luasnip.config.setup({})
require("luasnip.loaders.from_vscode").lazy_load()
if ok_autopairs then
autopairs.setup({})
end
if ok_comment then
comment.setup()
end
if ok_flash then
flash.setup()
end
if ok_oil then
oil.setup({
default_file_explorer = true,
skip_confirm_for_simple_edits = true,
view_options = {
show_hidden = true,
},
})
end
telescope.setup({
extensions = {
["ui-select"] = themes.get_dropdown({}),
undo = {
layout_strategy = "vertical",
layout_config = {
preview_height = 0.6,
},
side_by_side = true,
},
},
})
pcall(telescope.load_extension, "ui-select")
pcall(telescope.load_extension, "undo")
-- Completion shortcuts.
local cmp_insert_mappings = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<Tab>"] = cmp.mapping.confirm({ select = true }), -- Accept the selected completion.
})
local cmp_cmdline_mappings = cmp.mapping.preset.cmdline()
-- Search and buffers.
map("n", "<C-p>", builtin.git_files, { desc = "Search tracked files", silent = true })
map("n", "<C-f>", builtin.find_files, { desc = "Search all files", silent = true })
map("n", "<leader>f", builtin.live_grep, { desc = "Grep project", silent = true })
map("n", "<leader>/", function()
builtin.current_buffer_fuzzy_find(themes.get_dropdown({ previewer = false, winblend = 10 }))
end, { desc = "Search current buffer", silent = true })
map("n", "<leader>fh", builtin.help_tags, { desc = "Search help", silent = true })
map("n", "<leader>fr", builtin.oldfiles, { desc = "Recent files", silent = true })
map("n", "<leader>fu", "<CMD>Telescope undo<CR>", { desc = "Undo history", silent = true })
map("n", "<leader><tab>", builtin.buffers, { desc = "Switch buffers", silent = true })
-- File browsing.
map("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory", silent = true })
map("n", "<leader>e", "<CMD>Oil<CR>", { desc = "Open file explorer", silent = true })
map("n", "<leader>E", function()
require("oil").open(vim.fn.expand("%:p:h"))
end, { desc = "Open current file directory", silent = true })
-- LSP and diagnostics.
map("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition", silent = true })
map("n", "gr", builtin.lsp_references, { desc = "List references", silent = true })
map("n", "gi", builtin.lsp_implementations, { desc = "List implementations", silent = true })
map("n", "K", vim.lsp.buf.hover, { desc = "Hover docs", silent = true })
map("n", "L", vim.diagnostic.open_float, { desc = "Show diagnostics", silent = true })
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, { desc = "Code action", silent = true })
map("n", "<leader>rn", vim.lsp.buf.rename, { desc = "Rename symbol", silent = true })
map("n", "[d", function()
vim.diagnostic.jump({ count = -1, float = true })
end, { desc = "Previous diagnostic", silent = true })
map("n", "]d", function()
vim.diagnostic.jump({ count = 1, float = true })
end, { desc = "Next diagnostic", silent = true })
map("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Diagnostics list", silent = true })
map("n", "<leader>fm", format_buffer, { desc = "Format buffer", silent = true })
-- LaTeX workflow.
map("n", "<leader>tc", "<CMD>VimtexCompile<CR>", { desc = "Compile TeX", silent = true })
map("n", "<leader>tk", "<CMD>VimtexStop<CR>", { desc = "Stop TeX compile", silent = true })
map("n", "<leader>tv", "<CMD>VimtexView<CR>", { desc = "Open TeX PDF", silent = true })
map("n", "<leader>to", "<CMD>VimtexCompileOutput<CR>", { desc = "TeX compiler output", silent = true })
map("n", "<leader>tt", "<CMD>VimtexTocToggle<CR>", { desc = "TeX table of contents", silent = true })
map("n", "<leader>te", "<CMD>VimtexErrors<CR>", { desc = "TeX errors", silent = true })
map("n", "<leader>tl", "<CMD>VimtexClean<CR>", { desc = "Clean TeX build files", silent = true })
-- Editing and utility shortcuts.
map({ "n", "v" }, "<leader>y", '"+y', { desc = "Yank to clipboard", silent = true })
map("n", "<leader>u", "<CMD>UndotreeToggle<CR>", { desc = "Toggle undo tree", silent = true })
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp_insert_mappings,
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
}, {
{ name = "buffer" },
}),
})
cmp.setup.cmdline("/", {
mapping = cmp_cmdline_mappings,
sources = {
{ name = "buffer" },
},
})
cmp.setup.cmdline(":", {
mapping = cmp_cmdline_mappings,
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
})
if ok_cmp_autopairs then
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end
vim.diagnostic.config({
virtual_text = true,
signs = true,
underline = true,
update_in_insert = true,
})
local capabilities = cmp_nvim_lsp.default_capabilities()
local servers = {
ts_ls = {},
clangd = {},
gopls = {
cmd = { "gopls", "serve" },
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
},
},
},
pyright = {},
texlab = {
settings = {
texlab = {
build = {
executable = "latexmk",
args = {
"-pdf",
"-interaction=nonstopmode",
"-synctex=1",
"-file-line-error",
"%f",
},
onSave = true,
forwardSearchAfter = false,
},
chktex = {
onOpenAndSave = false,
onEdit = false,
},
},
},
},
rust_analyzer = {
cmd = { "rust-analyzer" },
settings = {
["rust-analyzer"] = {
checkOnSave = {
allFeatures = true,
overrideCommand = {
"cargo",
"clippy",
"--workspace",
"--message-format=json",
"--all-targets",
"--all-features",
},
},
},
},
},
["kotlin-language-server"] = {
cmd = { "kotlin-language-server" },
filetypes = { "kotlin" },
},
cmake = {},
html = {},
glsl_analyzer = {},
lua_ls = {},
zls = {},
}
for server, config in pairs(servers) do
config.capabilities = capabilities
vim.lsp.config(server, config)
vim.lsp.enable(server)
end
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("UserTreesitterHighlight", { clear = true }),
callback = function(args)
pcall(vim.treesitter.start, args.buf)
end,
desc = "Start Tree-sitter highlighting when a parser is available",
})
Loading…
Cancel
Save