neovim udpates

This commit is contained in:
Daylin Morgan 2025-01-06 14:51:50 -06:00
parent f60e119747
commit 671eda39b8
Signed by: daylin
GPG key ID: 950D13E9719334AD
13 changed files with 183 additions and 59 deletions

View file

@ -16,3 +16,27 @@ vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.roc" },
command = "set filetype=roc",
})
-- if cspell config found then disable buitlin spell check
vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
pattern = "*",
callback = function()
-- this isn't exhuastive and won't work if config is contained in a package.json
local cspell_files = {
"cspell.json",
".cspell.json",
"cSpell.json",
".cSpell.json",
".cspell.config.json",
"cpsell.config.yaml",
".cpsell.config.yaml"
}
for _, file in ipairs(cspell_files) do
if vim.fn.findfile(file, ".;") ~= "" then
vim.opt_local.spell = false
break
end
end
end
})

View file

@ -1,3 +1,4 @@
local import_if_exe = require("util").import_if_exe
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
@ -25,22 +26,22 @@ require("lazy").setup({
{ import = "plugins.disabled" },
{ import = "plugins.host" },
{ import = "plugins.ui" },
-- { import = "plugins.language" },
{ import = "plugins.language.go" },
{ import = "plugins.language.misc" },
{ import = "plugins.language.lua" },
{ import = "plugins.language.markdown" },
{ import = "plugins.language.misc" },
{ import = "plugins.language.nim" },
{ import = "plugins.language.nix" },
require("util").if_exe("nu", { { import = "plugins.language.nu" } }),
{ import = "plugins.language.python" },
-- { import = "plugins.language.roc" },
{ import = "plugins.language.rust" },
{ import = "plugins.language.shell" },
{ import = "plugins.language.python" },
{ import = "plugins.language.tex" },
{ import = "plugins.language.typst" },
-- { import = "plugins.language.zig" },
import_if_exe("go", "plugins.language.go" ),
import_if_exe("nim", "plugins.language.nim"),
import_if_exe("nix" , "plugins.language.nix" ),
import_if_exe("nu", "plugins.language.nu" ),
import_if_exe("rust", "plugins.language.rust" ),
import_if_exe("typst", "plugins.language.typst" ),
-- import_if_exe("zig", "plugins.language.zig" ),
-- import_if_exe("roc", "plugins.language.roc" ),
--
},
rocks = {

View file

@ -35,4 +35,34 @@ return {
keymap = { preset = "default" },
},
},
{
"mfussenegger/nvim-lint",
opts = {
-- cspell probably isn't installed globally? though could be with pnpm...
-- linters_by_ft = {
-- markdown = { "cspell" },
-- },
-- LazyVim extension to easily override linter options
-- or add custom linters.
---@type table<string,table>
linters = {
-- -- Example of using selene only when a selene.toml file is present
-- selene = {
-- -- `condition` is another LazyVim extension that allows you to
-- -- dynamically enable/disable linters based on the context.
-- condition = function(ctx)
-- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1]
-- end,
-- },
cspell = {
-- only works for one file type?
-- see lua/config/autocmds for a possible solution that includes more files
condition = function(ctx)
return vim.fs.find({".cspell.config.yaml"}, {path = ctx.filename, upward = true})[1]
end
}
},
},
},
}

View file

@ -7,7 +7,7 @@ local function disable(plugins)
end
return disable({
"mfussenegger/nvim-lint",
-- "mfussenegger/nvim-lint",
"folke/tokyonight.nvim",
-- snippets are wildly really annoying
"L3MON4D3/LuaSnip",

View file

@ -1,5 +1,5 @@
-- adapted from https://www.lazyvim.org/extras/lang/go
return require("util").if_exe("go", {
return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
@ -97,4 +97,4 @@ return require("util").if_exe("go", {
},
},
},
})
}

View file

@ -0,0 +1,3 @@
return {
require("util").setup_lang({ treesitter = { "janet_simple" } }),
}

View file

@ -1,16 +1,14 @@
local util = require("util")
return util.if_exe("nim", {
util.setup_lang({ treesitter = { "nim", "nim_format_string" } }),
return {
require("util").setup_lang({ treesitter = { "nim", "nim_format_string" }, lsp = { "nim_langserver" } }),
{ "alaviss/nim.nvim" },
{
"neovim/nvim-lspconfig",
opts = {
servers = {
nim_langserver = {
mason = false,
},
},
},
},
})
-- {
-- "neovim/nvim-lspconfig",
-- opts = {
-- servers = {
-- nim_langserver = {
-- mason = false,
-- },
-- },
-- },
-- },
}

View file

@ -1,6 +1,5 @@
local util = require("util")
return util.if_exe("nix", {
util.setup_lang({ treesitter = { "nix" } }),
return {
require("util").setup_lang({ treesitter = { "nix" } }),
{
"neovim/nvim-lspconfig",
opts = {
@ -14,4 +13,4 @@ return util.if_exe("nix", {
},
},
},
})
}

View file

@ -1,4 +1,4 @@
return require("util").if_exe("roc", {
return {
{ "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = { "roc" } } },
{
"neovim/nvim-lspconfig",
@ -10,4 +10,4 @@ return require("util").if_exe("roc", {
},
},
},
})
}

View file

@ -1,5 +1,5 @@
-- adapted from https://www.lazyvim.org/extras/lang/rust
return require("util").if_exe("rust", {
return {
{
"hrsh7th/nvim-cmp",
opts = function(_, opts)
@ -96,4 +96,4 @@ return require("util").if_exe("rust", {
},
},
},
})
}

View file

@ -1,16 +1,15 @@
return require("util").if_exe("typst", {
{
"neovim/nvim-lspconfig",
opts = {
servers = {
typst_lsp = {
mason = false,
settings = {
exportPdf = "never", -- Choose onType, onSave or never.
-- serverPath = "" -- Normally, there is no need to uncomment it.
},
},
},
},
},
})
-- todo: treesitter?
-- return {
-- {
-- "neovim/nvim-lspconfig",
-- opts = {
-- servers = {
-- tinymist = {
-- mason = false
-- }
-- },
-- },
-- },
-- }
--
return require("util").setup_lang({lsp = {"tinymist"}})

View file

@ -1,5 +1,5 @@
-- adapted from https://www.lazyvim.org/extras/lang/rust
return require("util").if_exe("zig", {
return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
@ -17,4 +17,4 @@ return require("util").if_exe("zig", {
},
},
},
})
}

View file

@ -7,23 +7,88 @@ local function setDefault(t, d)
setmetatable(t, mt)
end
-- local function setup_lsp(name)
-- return {
-- "neovim/nvim-lspconfig",
-- opts = {
-- servers = {
-- [name] = { mason = false },
-- },
-- },
-- }
-- end
-- local function setup_lang(defs)
-- setDefault(defs, {})
-- return {
-- {
-- "nvim-treesitter/nvim-treesitter",
-- opts = function(_, opts)
-- opts.ensure_installed = vim.list_extend(opts.ensure_installed or {}, defs.treesitter)
-- end,
-- },
-- {
-- "williamboman/mason.nvim",
-- opts = function(_, opts)
-- opts.ensure_installed = vim.list_extend(opts.ensure_installed or {}, defs.mason)
-- end,
-- },
-- }
-- end
local function lsp_no_mason(server_name)
return {
[server_name] = {
mason = false,
},
}
end
--- generated with the help of claude
local function setup_lang(defs)
setDefault(defs, {})
return {
local result = {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
opts.ensure_installed = vim.list_extend(opts.ensure_installed or {}, defs.treesitter)
opts.ensure_installed = vim.list_extend(opts.ensure_installed or {}, defs.treesitter or {})
end,
},
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = vim.list_extend(opts.ensure_installed or {}, defs.mason)
opts.ensure_installed = vim.list_extend(opts.ensure_installed or {}, defs.mason or {})
end,
},
}
-- Handle LSP configuration
if defs.lsp then
table.insert(result, {
"neovim/nvim-lspconfig",
opts = {
servers = {},
},
})
-- i think the result[#result] syntax is taking the "last" index of result
for _, lsp in ipairs(defs.lsp) do
if type(lsp) == "string" then
-- Regular LSP server
result[#result].opts.servers[lsp] = {mason = false}
elseif type(lsp) == "table" and lsp[1] then
-- LSP server with no Mason
result[#result].opts.servers = vim.tbl_deep_extend("force", result[#result].opts.servers, lsp_no_mason(lsp[1]))
end
end
end
return result
end
local function if_exe(exe, deps)
if vim.fn.executable(exe) == 0 then
@ -32,7 +97,12 @@ local function if_exe(exe, deps)
return deps
end
local function import_if_exe(exe, mod)
return if_exe(exe, { { import = mod } })
end
return {
setup_lang = setup_lang,
if_exe = if_exe,
import_if_exe = import_if_exe,
}