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" }, pattern = { "*.roc" },
command = "set filetype=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" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git" local lazyrepo = "https://github.com/folke/lazy.nvim.git"
@ -25,22 +26,22 @@ require("lazy").setup({
{ import = "plugins.disabled" }, { import = "plugins.disabled" },
{ import = "plugins.host" }, { import = "plugins.host" },
{ import = "plugins.ui" }, { import = "plugins.ui" },
-- { import = "plugins.language" },
{ import = "plugins.language.go" }, { import = "plugins.language.misc" },
{ import = "plugins.language.lua" }, { import = "plugins.language.lua" },
{ import = "plugins.language.markdown" }, { 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.shell" },
{ import = "plugins.language.python" },
{ import = "plugins.language.tex" }, { 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 = { rocks = {

View file

@ -35,4 +35,34 @@ return {
keymap = { preset = "default" }, 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 end
return disable({ return disable({
"mfussenegger/nvim-lint", -- "mfussenegger/nvim-lint",
"folke/tokyonight.nvim", "folke/tokyonight.nvim",
-- snippets are wildly really annoying -- snippets are wildly really annoying
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",

View file

@ -1,5 +1,5 @@
-- adapted from https://www.lazyvim.org/extras/lang/go -- adapted from https://www.lazyvim.org/extras/lang/go
return require("util").if_exe("go", { return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) 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 {
require("util").setup_lang({ treesitter = { "nim", "nim_format_string" }, lsp = { "nim_langserver" } }),
return util.if_exe("nim", {
util.setup_lang({ treesitter = { "nim", "nim_format_string" } }),
{ "alaviss/nim.nvim" }, { "alaviss/nim.nvim" },
{ -- {
"neovim/nvim-lspconfig", -- "neovim/nvim-lspconfig",
opts = { -- opts = {
servers = { -- servers = {
nim_langserver = { -- nim_langserver = {
mason = false, -- mason = false,
}, -- },
}, -- },
}, -- },
}, -- },
}) }

View file

@ -1,6 +1,5 @@
local util = require("util") return {
return util.if_exe("nix", { require("util").setup_lang({ treesitter = { "nix" } }),
util.setup_lang({ treesitter = { "nix" } }),
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
opts = { 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" } } }, { "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = { "roc" } } },
{ {
"neovim/nvim-lspconfig", "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 -- adapted from https://www.lazyvim.org/extras/lang/rust
return require("util").if_exe("rust", { return {
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
opts = function(_, opts) 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", { -- todo: treesitter?
{ -- return {
"neovim/nvim-lspconfig", -- {
opts = { -- "neovim/nvim-lspconfig",
servers = { -- opts = {
typst_lsp = { -- servers = {
mason = false, -- tinymist = {
settings = { -- mason = false
exportPdf = "never", -- Choose onType, onSave or never. -- }
-- serverPath = "" -- Normally, there is no need to uncomment it. -- },
}, -- },
}, -- },
}, -- }
}, --
}, return require("util").setup_lang({lsp = {"tinymist"}})
})

View file

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

View file

@ -7,24 +7,89 @@ local function setDefault(t, d)
setmetatable(t, mt) setmetatable(t, mt)
end 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) local function setup_lang(defs)
setDefault(defs, {}) setDefault(defs, {})
return {
local result = {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) 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, end,
}, },
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) 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, 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 end
local function if_exe(exe, deps) local function if_exe(exe, deps)
if vim.fn.executable(exe) == 0 then if vim.fn.executable(exe) == 0 then
return {} return {}
@ -32,7 +97,12 @@ local function if_exe(exe, deps)
return deps return deps
end end
local function import_if_exe(exe, mod)
return if_exe(exe, { { import = mod } })
end
return { return {
setup_lang = setup_lang, setup_lang = setup_lang,
if_exe = if_exe, if_exe = if_exe,
import_if_exe = import_if_exe,
} }