i love aurora (nixcats over nvf)

This commit is contained in:
Dea 2026-02-19 13:46:23 -05:00
parent 552d136a48
commit 286a6a938e
20 changed files with 772 additions and 145 deletions

View file

@ -0,0 +1,59 @@
local M = {}
function M.on_attach(_, bufnr)
-- we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
-- NOTE: why are these functions that call the telescope builtin?
-- because otherwise they would load telescope eagerly when this is defined.
-- due to us using the on_require handler to make sure it is available.
if nixCats('general.telescope') then
nmap('gr', function() require('telescope.builtin').lsp_references() end, '[G]oto [R]eferences')
nmap('gI', function() require('telescope.builtin').lsp_implementations() end, '[G]oto [I]mplementation')
nmap('<leader>ds', function() require('telescope.builtin').lsp_document_symbols() end, '[D]ocument [S]ymbols')
nmap('<leader>ws', function() require('telescope.builtin').lsp_dynamic_workspace_symbols() end, '[W]orkspace [S]ymbols')
nmap('<leader>dd', "<cmd>Telescope diagnostics bufnr=0<CR>", '[D]ocument [D]iagnostics')
nmap('<leader>wd', "<cmd>Telescope diagnostics<CR>", '[W]orkspace [D]iagnostics')
end -- TODO: someone who knows the builtin versions of these to do instead help me out please.
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
nmap('<leader>e', vim.diagnostic.open_float, 'Show [E]rror')
-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
end
function M.get(server_name)
local capabilities = require('blink.cmp').get_lsp_capabilities()
return capabilities
end
return M

View file

@ -0,0 +1,88 @@
return {
{
"friendly-snippets",
dep_of = { "blink.cmp" },
},
{
"blink.cmp",
event = { "InsertEnter", "CmdlineEnter" },
on_require = "blink",
load = function (name)
vim.cmd.packadd(name)
end,
after = function(plugin)
local blink = require('blink.cmp')
blink.setup({
keymap = {
preset = 'default',
},
appearance = {
nerd_font_variant = 'mono',
},
sources = {
default = { 'lsp', 'path', 'snippets', 'buffer' },
providers = {
lsp = {
name = 'LSP',
module = 'blink.cmp.sources.lsp',
enabled = true,
},
path = {
name = 'Path',
module = 'blink.cmp.sources.path',
enabled = true,
},
snippets = {
name = 'Snippets',
module = 'blink.cmp.sources.snippets',
enabled = true,
},
buffer = {
name = 'Buffer',
module = 'blink.cmp.sources.buffer',
enabled = true,
},
},
},
completion = {
accept = {
auto_brackets = {
enabled = true,
},
},
menu = {
border = 'rounded',
max_height = 12,
scrolloff = 2,
draw = {
columns = {
{ "kind_icon", gap = 1, },
{ "label", "label_description", gap = 1, },
},
},
},
documentation = {
auto_show = false,
window = {
border = 'rounded',
},
},
},
signature = {
enabled = true,
window = {
border = 'rounded',
},
},
})
end
},
}

View file

@ -0,0 +1,17 @@
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
callback = function()
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
vim.opt_local.expandtab = true
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "nix",
callback = function()
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
vim.opt_local.expandtab = true
end,
})

View file

@ -0,0 +1,5 @@
require("lze").load {
{ import = "lsp.completion", },
}
require("lsp.lsp")

View file

@ -0,0 +1,97 @@
local servers = {}
servers.lua_ls = {
settings = {
Lua = {
formatters = {
ignoreComments = false,
},
signatureHelp = { enable = true },
diagnostics = {
globals = { 'nixCats', 'vim' },
-- disable = { 'missing-fields' },
},
workspace = {
-- make the server aware of the neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
},
telemetry = { enabled = false },
},
}
servers.nil_ls = {
settings = {},
}
local rust_analyzer_cmd = os.getenv("RUST_ANALYZER_CMD")
servers.rust_analyzer = {
cmd = { rust_analyzer_cmd },
settings = {
server = {
-- For debugging rust-analyzer, to see log location do :LspInfo in neovim
-- extraEnv = { {["RA_LOG"]="project_model=debug"} },
},
cargo = {
allFeatures = false,
allTargets = false,
buildScripts = { enable = true },
target = "x86_64-unknown-linux-gnu",
},
diagnostics = {
enable = true,
},
},
}
servers.hls = {
settings = {},
}
-- Taken from nixCats example:
-- If you were to comment out this autocommand
-- and instead pass the on attach function directly to
-- nvim-lspconfig, it would do the same thing.
-- come to think of it, it might be better because then lspconfig doesnt have to be called before lsp attach?
-- but you would still end up triggering on a FileType event anyway, so, it makes little difference.
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('nixCats-lsp-attach', { clear = true }),
callback = function(event)
require('lsp.capabilities').on_attach(vim.lsp.get_client_by_id(event.data.client_id), event.buf)
end
})
require("lze").load {
{
"nvim-lspconfig",
event = "FileType",
after = function(plugin)
-- Just register configs, don't enable yet
for server_name, cfg in pairs(servers) do
vim.lsp.config(server_name, {
capabilities = require('lsp.capabilities').get(server_name),
settings = (cfg or {}).settings,
filetypes = (cfg or {}).filetypes,
cmd = (cfg or {}).cmd,
root_pattern = (cfg or {}).root_pattern,
})
end
-- Enable on-demand per filetype
for server_name, cfg in pairs(servers) do
local filetypes = cfg.filetypes or vim.lsp.config[server_name].filetypes
if filetypes then
vim.api.nvim_create_autocmd('FileType', {
pattern = filetypes,
callback = function()
vim.lsp.enable(server_name)
end,
})
end
end
end,
},
}