words, spaces for lua indents, spelling as hints instead of error,

This commit is contained in:
RingOfStorms (Joshua Bell) 2023-11-02 13:19:00 -05:00
parent 55be7d4e97
commit da4232a795
3 changed files with 314 additions and 295 deletions

View file

@ -1 +1 @@
{"language":"en","version":"0.2","flagWords":[],"words":["nvim","builtins","stylua","rustfmt","pendo","tanstack","ripgrep","Typeahead","overscan","autorun","mediatype","BIOINF","Transitioner","pkce","ilike","arrayify","arrayified","komodo","wezterm","gcloud","pbpaste","Hasher","semvers","upserted","dtos","Yeatts","Mahon","Beaubier","Taussing","chakra","langchain","openai","getattr","llms","docstore","kwargs","svgr","healthcheck","venv","virtualenv","ringofstorms","nestjs","oneshot","templating","tiktoken","pydantic","NCCN","clsx","reactflow","Convo","DSAB","pgvector"]} {"version":"0.2","language":"en","words":["nvim","builtins","stylua","rustfmt","pendo","tanstack","ripgrep","Typeahead","overscan","autorun","mediatype","BIOINF","Transitioner","pkce","ilike","arrayify","arrayified","komodo","wezterm","gcloud","pbpaste","Hasher","semvers","upserted","dtos","Yeatts","Mahon","Beaubier","Taussing","chakra","langchain","openai","getattr","llms","docstore","kwargs","svgr","healthcheck","venv","virtualenv","ringofstorms","nestjs","oneshot","templating","tiktoken","pydantic","NCCN","clsx","reactflow","Convo","DSAB","pgvector","postprocess","stylelua","sqlx","genemichaels","williamboman","substr","findfile","Hammerspoon","eventtap"],"flagWords":[]}

View file

@ -1,88 +1,97 @@
local function prereqs() local function prereqs()
local output = vim.fn.system({ local output = vim.fn.system({
"which", "which",
"rust-analyzer", "rust-analyzer",
"&&", "&&",
"rust-analyzer", "rust-analyzer",
"--version", "--version",
}) })
if output == nil or output == "" or string.find(output, "not installed for the toolchain") then if output == nil or output == "" or string.find(output, "not installed for the toolchain") then
print("Installing rust-analyzer globally with rustup") print("Installing rust-analyzer globally with rustup")
vim.fn.system({ vim.fn.system({
"rustup", "rustup",
"component", "component",
"add", "add",
"rust-analyzer", "rust-analyzer",
}) })
end end
end end
local servers = { local servers = {
-- rust_analyzer = USES RUST_TOOLS INSTEAD, SEE BOTTOM OF THIS FILE -- rust_analyzer = USES RUST_TOOLS INSTEAD, SEE BOTTOM OF THIS FILE
tsserver = { tsserver = {
-- typescript/javascript -- typescript/javascript
}, },
pyright = { pyright = {
-- python -- python
}, },
lua_ls = { lua_ls = {
-- lua -- lua
Lua = { Lua = {
runtime = { runtime = {
version = "LuaJIT", version = "LuaJIT",
}, },
workspace = { checkThirdParty = false, library = vim.api.nvim_get_runtime_file("", true) }, workspace = {
telemetry = { enable = false }, checkThirdParty = false,
diagnostics = { library = {
globals = { vim.api.nvim_get_runtime_file("", true),
"vim", vim.fn.expand("$VIMRUNTIME/lua"),
"require", vim.fn.expand("$VIMRUNTIME/lua/vim/lsp"),
}, "/Applications/Hammerspoon.app/Contents/Resources/extensions/hs/",
}, },
}, },
}, telemetry = { enable = false },
bashls = { diagnostics = {
-- bash globals = {
}, "vim",
cssls = { "require",
-- css "hs",
}, },
cssmodules_ls = { },
-- css modules },
}, },
dockerls = { bashls = {
-- docker -- bash
}, },
docker_compose_language_service = { cssls = {
-- docker compose -- css
}, },
jsonls = { cssmodules_ls = {
-- json -- css modules
}, },
marksman = { dockerls = {
-- markdown -- docker
}, },
taplo = { docker_compose_language_service = {
-- toml -- docker compose
}, },
yamlls = { jsonls = {
-- yaml -- json
}, },
lemminx = { marksman = {
-- xml -- markdown
}, },
rnix = { taplo = {
-- Nix -- toml
}, },
ansiblels = { yamlls = {
-- ansible -- yaml
}, },
lemminx = {
-- xml
},
rnix = {
-- Nix
},
ansiblels = {
-- ansible
},
} }
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = true, virtual_text = true,
signs = true, signs = true,
update_in_insert = true, update_in_insert = true,
}) })
-- LSP config -- LSP config
@ -90,239 +99,239 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagn
-- This function gets run when an LSP connects to a particular buffer. -- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
local nmap = function(keys, func, desc) local nmap = function(keys, func, desc)
if desc then if desc then
desc = "LSP: " .. desc desc = "LSP: " .. desc
end end
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end end
local cursor_layout = { local cursor_layout = {
layout_strategy = "cursor", layout_strategy = "cursor",
layout_config = { width = 0.25, height = 0.35 }, layout_config = { width = 0.25, height = 0.35 },
} }
nmap("<leader>lr", vim.lsp.buf.rename, "[R]ename") nmap("<leader>lr", vim.lsp.buf.rename, "[R]ename")
nmap("<leader>la", vim.lsp.buf.code_action, "Code [A]ction") nmap("<leader>la", vim.lsp.buf.code_action, "Code [A]ction")
-- I dont like the default vim quickfix buffer opening for goto defintiion so use telescope -- I dont like the default vim quickfix buffer opening for goto defintiion so use telescope
-- nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") -- nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
nmap("gd", function() nmap("gd", function()
require("telescope.builtin").lsp_definitions(cursor_layout) require("telescope.builtin").lsp_definitions(cursor_layout)
end, "[G]oto [D]efinition") end, "[G]oto [D]efinition")
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
nmap("gI", function() nmap("gI", function()
require("telescope.builtin").lsp_implementations(cursor_layout) require("telescope.builtin").lsp_implementations(cursor_layout)
end, "[G]oto [I]mplementation") end, "[G]oto [I]mplementation")
-- See `:help K` for why this keymap -- See `:help K` for why this keymap
nmap("K", vim.lsp.buf.hover, "Hover Documentation") nmap("K", vim.lsp.buf.hover, "Hover Documentation")
nmap("<leader>sd", vim.lsp.buf.signature_help, "Signature Documentation") nmap("<leader>sd", vim.lsp.buf.signature_help, "Signature Documentation")
-- Lesser used LSP functionality -- Lesser used LSP functionality
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
-- disable tsserver so it does not conflict with prettier -- disable tsserver so it does not conflict with prettier
if client.name == "tsserver" then if client.name == "tsserver" then
client.server_capabilities.document_formatting = false client.server_capabilities.document_formatting = false
end end
end end
local gen_capabilities = function(cmp) local gen_capabilities = function(cmp)
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers -- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = cmp.default_capabilities(capabilities) capabilities = cmp.default_capabilities(capabilities)
end end
return { return {
{ {
"lvimuser/lsp-inlayhints.nvim", "lvimuser/lsp-inlayhints.nvim",
}, },
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
build = "make install_jsregexp", build = "make install_jsregexp",
opts = { opts = {
history = true, history = true,
region_check_events = "InsertEnter", region_check_events = "InsertEnter",
delete_check_events = "TextChanged,InsertLeave", delete_check_events = "TextChanged,InsertLeave",
}, },
}, },
{ {
-- Autocompletion -- Autocompletion
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
dependencies = { dependencies = {
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
--"Saecki/crates.nvim", -- SEE plugins/rust-tools.lua --"Saecki/crates.nvim", -- SEE plugins/rust-tools.lua
"zbirenbaum/copilot-cmp", "zbirenbaum/copilot-cmp",
}, },
}, },
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
cmd = { cmd = {
"Mason", "Mason",
"MasonUpdate", "MasonUpdate",
"MasonInstall", "MasonInstall",
"MasonInstallAll", "MasonInstallAll",
"MasonUninstall", "MasonUninstall",
"MasonUninstallAll", "MasonUninstallAll",
"MasonLog", "MasonLog",
}, },
build = ":MasonUpdate", build = ":MasonUpdate",
opts = {}, opts = {},
}, },
{ "folke/neodev.nvim", opts = {} }, -- lua stuff { "folke/neodev.nvim", opts = {} }, -- lua stuff
{ {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = { "nvim-telescope/telescope.nvim" }, dependencies = { "nvim-telescope/telescope.nvim" },
config = function() config = function()
local config = require("lspconfig") local config = require("lspconfig")
-- local util = require("lspconfig/util") -- local util = require("lspconfig/util")
local mason_lspconfig = require("mason-lspconfig") local mason_lspconfig = require("mason-lspconfig")
local cmp = require("cmp") local cmp = require("cmp")
local luasnip = require("luasnip") local luasnip = require("luasnip")
-- LSP -- LSP
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers -- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = gen_capabilities(require("cmp_nvim_lsp")) local capabilities = gen_capabilities(require("cmp_nvim_lsp"))
-- Install servers used -- Install servers used
mason_lspconfig.setup({ mason_lspconfig.setup({
ensure_installed = vim.tbl_keys(servers), ensure_installed = vim.tbl_keys(servers),
}) })
local flags = { local flags = {
allow_incremental_sync = true, allow_incremental_sync = true,
debounce_text_changes = 200, debounce_text_changes = 200,
} }
mason_lspconfig.setup_handlers({ mason_lspconfig.setup_handlers({
function(server_name) function(server_name)
config[server_name].setup({ config[server_name].setup({
flags = flags, flags = flags,
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
settings = servers[server_name], settings = servers[server_name],
}) })
end, end,
}) })
-- Completion -- Completion
luasnip.config.setup({}) luasnip.config.setup({})
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) luasnip.lsp_expand(args.body)
end, end,
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item(), ["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(), ["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4), ["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete({}), ["<C-Space>"] = cmp.mapping.complete({}),
["<CR>"] = cmp.mapping.confirm({ ["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true,
}), }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
-- elseif luasnip.expand_or_jumpable() then -- elseif luasnip.expand_or_jumpable() then
elseif luasnip.expand_or_locally_jumpable() then elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
}), }),
sources = { sources = {
{ {
name = "copilot", name = "copilot",
priority = 8, priority = 8,
keyword_length = 1, keyword_length = 1,
filter = function(keyword) filter = function(keyword)
-- Check if keyword length is some number and not just whitespace -- Check if keyword length is some number and not just whitespace
if #keyword < 2 or keyword:match("^%s*$") then if #keyword < 2 or keyword:match("^%s*$") then
return false return false
end end
return true return true
end, end,
}, },
{ name = "nvim_lsp", priority = 9 }, { name = "nvim_lsp", priority = 9 },
{ nane = "buffer", priority = 7 }, { nane = "buffer", priority = 7 },
{ name = "luasnip", priority = 6 }, { name = "luasnip", priority = 6 },
{ name = "path" }, { name = "path" },
{ name = "crates" }, { name = "crates" },
}, },
sorting = { sorting = {
priority_weight = 1, priority_weight = 1,
comparators = { comparators = {
cmp.config.compare.locality, cmp.config.compare.locality,
cmp.config.compare.recently_used, cmp.config.compare.recently_used,
cmp.config.compare.score, cmp.config.compare.score,
cmp.config.compare.offset, cmp.config.compare.offset,
cmp.config.compare.order, cmp.config.compare.order,
}, },
}, },
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
}, },
}) })
-- Window borders for visibility -- Window borders for visibility
local _border = "single" local _border = "single"
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = _border, border = _border,
}) })
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = _border, border = _border,
}) })
vim.diagnostic.config({ vim.diagnostic.config({
float = { border = _border }, float = { border = _border },
}) })
require("lspconfig.ui.windows").default_options = { require("lspconfig.ui.windows").default_options = {
border = _border, border = _border,
} }
end, end,
}, },
{ -- Rust tools { -- Rust tools
"simrat39/rust-tools.nvim", "simrat39/rust-tools.nvim",
build = prereqs, build = prereqs,
opts = { opts = {
server = { server = {
on_attach = on_attach, on_attach = on_attach,
}, },
}, },
config = function(_, opts) config = function(_, opts)
opts.server.capabilities = gen_capabilities(require("cmp_nvim_lsp")) opts.server.capabilities = gen_capabilities(require("cmp_nvim_lsp"))
require("rust-tools").setup(opts) require("rust-tools").setup(opts)
end, end,
--config = function(_, opts) --config = function(_, opts)
--require('rust-tools').setup(opts) --require('rust-tools').setup(opts)
--end --end
}, },
{ "Saecki/crates.nvim", tag = "v0.3.0", dependencies = { "nvim-lua/plenary.nvim" }, opts = {} }, { "Saecki/crates.nvim", tag = "v0.3.0", dependencies = { "nvim-lua/plenary.nvim" }, opts = {} },
} }

View file

@ -30,7 +30,7 @@ return {
filetypes = { "rust" }, filetypes = { "rust" },
generator = null_ls.formatter({ generator = null_ls.formatter({
command = "genemichaels", command = "genemichaels",
args = { '-q' }, args = { "-q" },
to_stdin = true, to_stdin = true,
}), }),
} }
@ -41,8 +41,11 @@ return {
filetypes = { "rust" }, filetypes = { "rust" },
generator = null_ls.formatter({ generator = null_ls.formatter({
command = "rustfmt", command = "rustfmt",
args = { '--emit=stdout', "--edition=$(grep edition Cargo.toml | awk '{print substr($3,2,length($3)-2)}')", args = {
'--color=never' }, "--emit=stdout",
"--edition=$(grep edition Cargo.toml | awk '{print substr($3,2,length($3)-2)}')",
"--color=never",
},
to_stdin = true, to_stdin = true,
}), }),
} }
@ -69,9 +72,11 @@ return {
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
config.sources = { config.sources = {
null_ls.builtins.formatting.prettier, -- typescript/javascript null_ls.builtins.formatting.prettier, -- typescript/javascript
null_ls.builtins.formatting.stylua, -- lua null_ls.builtins.formatting.stylua.with({
extra_args = { "--indent-type", "spaces", "--indent-width", "2" },
}), -- lua
--null_ls.builtins.formatting.rustfmt, -- rust --null_ls.builtins.formatting.rustfmt, -- rust
rust_formatter_genemichaels, -- order matters, run genemichaels first then rustfmt rust_formatter_genemichaels, -- order matters, run genemichaels first then rustfmt
rust_formatter_rustfmt, rust_formatter_rustfmt,
-- rust_formatter_sqlx, -- see tools/sqlx-format.lua -- rust_formatter_sqlx, -- see tools/sqlx-format.lua
null_ls.builtins.formatting.black, -- python null_ls.builtins.formatting.black, -- python
@ -85,6 +90,11 @@ return {
}), }),
null_ls.builtins.diagnostics.cspell.with({ null_ls.builtins.diagnostics.cspell.with({
extra_args = { "--config", "~/.config/nvim/cspell.json" }, extra_args = { "--config", "~/.config/nvim/cspell.json" },
diagnostics_postprocess = function(diagnostic)
-- vim.notify(vim.inspect(diagnostic))
diagnostic.message = diagnostic.user_data.misspelled
diagnostic.severity = vim.diagnostic.severity.HINT
end,
}), }),
} }