feat: initial commit
- basic config according to spec
This commit is contained in:
commit
9b0446c5f6
36 files changed
+1114
No files matched your search
@@ -0,0 +1,13 @@
|
||||
local group = vim.api.nvim_create_augroup("core.autocmds", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
group = group,
|
||||
callback = function()
|
||||
vim.hl.on_yank()
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("VimResized", {
|
||||
group = group,
|
||||
command = "tabdo wincmd =",
|
||||
})
|
||||
@@ -0,0 +1,36 @@
|
||||
-- Files above the limit get vim.b.bigfile = true. Treesitter, LSP, linting and
|
||||
-- AI completion check that flag; syntax and folding are switched off here.
|
||||
local M = {}
|
||||
|
||||
M.limit = 1024 * 1024
|
||||
|
||||
local group = vim.api.nvim_create_augroup("core.bigfile", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("BufReadPre", {
|
||||
group = group,
|
||||
callback = function(ev)
|
||||
local stat = vim.uv.fs_stat(ev.match)
|
||||
if stat and stat.size > M.limit then
|
||||
vim.b[ev.buf].bigfile = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = group,
|
||||
callback = function(ev)
|
||||
if not vim.b[ev.buf].bigfile then
|
||||
return
|
||||
end
|
||||
vim.schedule(function()
|
||||
if vim.api.nvim_buf_is_valid(ev.buf) then
|
||||
vim.bo[ev.buf].syntax = ""
|
||||
vim.api.nvim_buf_call(ev.buf, function()
|
||||
vim.wo.foldmethod = "manual"
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,16 @@
|
||||
-- Plugin-independent maps. Plugin maps live in their spec's `keys`.
|
||||
local map = vim.keymap.set
|
||||
|
||||
map({ "n", "x" }, "<leader>y", '"+y', { desc = "Yank to system clipboard" })
|
||||
map({ "n", "x" }, "<leader>p", '"+p', { desc = "Paste from system clipboard" })
|
||||
|
||||
map("n", "<leader>bd", "<cmd>bdelete<cr>", { desc = "Delete buffer" })
|
||||
map("n", "<leader>bo", "<cmd>%bdelete|edit#|bdelete#<cr>", { desc = "Delete other buffers" })
|
||||
|
||||
map("n", "<leader>tw", function()
|
||||
vim.wo.wrap = not vim.wo.wrap
|
||||
end, { desc = "Toggle wrap" })
|
||||
|
||||
map("n", "<leader>tD", function()
|
||||
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||
end, { desc = "Toggle diagnostics" })
|
||||
@@ -0,0 +1,54 @@
|
||||
-- Servers start through native vim.lsp.enable. nvim-lspconfig only supplies
|
||||
-- defaults; overrides live in lsp/<server>.lua. Called from plugins/lsp.lua.
|
||||
local M = {}
|
||||
|
||||
M.servers = {
|
||||
"nixd",
|
||||
"lua_ls",
|
||||
"bashls",
|
||||
"yamlls",
|
||||
"jsonls",
|
||||
"marksman",
|
||||
"rust_analyzer",
|
||||
"gopls",
|
||||
"vtsls",
|
||||
"eslint",
|
||||
"basedpyright",
|
||||
"ruff",
|
||||
"intelephense",
|
||||
}
|
||||
|
||||
local function restart()
|
||||
vim.cmd(vim.fn.exists(":lsp") == 2 and "lsp restart" or "LspRestart")
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("core.lsp", { clear = true }),
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
if vim.b[ev.buf].bigfile then
|
||||
vim.schedule(function()
|
||||
vim.lsp.buf_detach_client(ev.buf, client.id)
|
||||
end)
|
||||
return
|
||||
end
|
||||
if client.name == "ruff" then
|
||||
client.server_capabilities.hoverProvider = false -- basedpyright owns hover
|
||||
end
|
||||
|
||||
local function map(lhs, rhs, desc)
|
||||
vim.keymap.set("n", lhs, rhs, { buffer = ev.buf, desc = desc })
|
||||
end
|
||||
map("<leader>li", "<cmd>checkhealth vim.lsp<cr>", "LSP info")
|
||||
map("<leader>lr", restart, "Restart LSP servers")
|
||||
end,
|
||||
})
|
||||
|
||||
vim.lsp.enable(M.servers)
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,29 @@
|
||||
local o = vim.opt
|
||||
|
||||
o.number = true
|
||||
o.relativenumber = true
|
||||
o.signcolumn = "yes"
|
||||
o.termguicolors = true
|
||||
o.showmode = false -- mini.statusline shows it
|
||||
|
||||
o.expandtab = true
|
||||
o.shiftwidth = 2
|
||||
o.tabstop = 2
|
||||
o.softtabstop = 2
|
||||
|
||||
o.undofile = true -- undodir defaults to stdpath("state")/undo
|
||||
o.swapfile = false
|
||||
|
||||
o.scrolloff = 8
|
||||
o.splitright = true
|
||||
o.splitbelow = true
|
||||
o.ignorecase = true
|
||||
o.smartcase = true
|
||||
|
||||
o.foldlevel = 99 -- treesitter sets foldexpr per buffer
|
||||
o.updatetime = 250
|
||||
|
||||
-- Clipboard is not synced. Over SSH, "+ goes through OSC 52.
|
||||
if vim.env.SSH_TTY then
|
||||
vim.g.clipboard = "osc52"
|
||||
end
|
||||
Reference in new issue
Block a user