Compare commits

..

3 commits

Author SHA1 Message Date
87e396ff15
deleted markdownlint settings (don't use it) and format readme 2025-03-08 07:00:09 -05:00
7827e7db11
re-add per-lsp format on save config 2025-03-08 06:59:21 -05:00
b8ab53fa2a
oops 2025-03-08 05:35:43 -05:00
9 changed files with 52 additions and 27 deletions

View file

@ -1,8 +0,0 @@
MD033:
# Allowed elements
allowed_elements: [p, details, summary, a, img, h1]
# MD013/line-length - Line length
MD013:
# Number of characters
line_length: 120

View file

@ -1,9 +1,15 @@
return {
'rust_analyzer',
'erlangls',
'lua_ls',
'cssls',
'eslint',
'ts_ls',
'svelte',
rust_analyzer = true,
erlangls = true,
lua_ls = {
format_on_save = false,
},
cssls = {
format_on_save = false,
},
eslint = true,
ts_ls = {
format_on_save = false,
},
svelte = true,
}

View file

@ -2,6 +2,7 @@ local M = {}
local augroup_name = 'CosmicNvimLspFormat'
local config = require('config')
local u = require('utils')
local lsp_utils = require('utils.lsp')
local lsp_mappings = require('lsp.mappings')
M.augroup = vim.api.nvim_create_augroup(augroup_name, { clear = true })
@ -31,10 +32,15 @@ function M.on_attach(client, bufnr)
})
vim.api.nvim_create_autocmd('BufWritePre', {
callback = function()
if lsp_utils.format_on_save_enabled then
vim.lsp.buf.format({
timeout_ms = config.lsp.format_timeout,
bufnr = bufnr,
filter = function(cl)
return lsp_utils.can_client_format_on_save(cl)
end,
})
end
end,
buffer = bufnr,
group = M.augroup,

View file

@ -38,4 +38,4 @@ map('n', '<C-Right>', ':vertical resize +2<CR>', { desc = 'Vertical Resize +2' }
-- easy insertion of trailing ; and , from insert mode.
map('i', ';;', '<Esc>A;<Esc>')
map('i', ',,', '<Esc>A;<Esc>')
map('i', ',,', '<Esc>A,<Esc>')

View file

@ -1,8 +1,8 @@
local config = {
auto_restore = true,
auto_session = true,
enabled = true,
pre_save_cmds = { 'cclose', 'lua vim.notify.dismiss()' },
auto_session_enabled = true,
auto_restore_enabled = true,
auto_save_enabled = true,
}
return {

View file

@ -13,7 +13,6 @@ return {
local config_opts = {
sources = {
null_ls.builtins.code_actions.gitsigns,
null_ls.builtins.diagnostics.markdownlint,
null_ls.builtins.formatting.prettierd.with({
env = {
PRETTIERD_LOCAL_PRETTIER_ONLY = 1,
@ -21,7 +20,7 @@ return {
extra_filetypes = { 'astro' },
}),
null_ls.builtins.formatting.stylua,
}
},
}
null_ls.setup(u.merge(defaults, config_opts))

View file

@ -18,7 +18,7 @@ return {
lspconfig[server].setup(server_config)
end
for _, server in pairs(require('lsp.servers')) do
for server, _ in pairs(require('lsp.servers')) do
start_server(server)
end
end,

View file

@ -1,4 +1,5 @@
local config = require('config')
local servers = require('lsp.servers')
local M = {}
M.format_on_save_enabled = true
@ -8,6 +9,24 @@ function M.toggle_format_on_save()
vim.notify(string.format('Format on save: %s', M.format_on_save_enabled))
end
function M.can_client_format_on_save(client)
local server_config = servers[client.name]
if server_config == true then
return true
end
if server_config then
if server_config.format_on_save == nil then
return true
end
return server_config.format_on_save == true
end
return true
end
function M.buf_format(bufnr, timeout)
if timeout == '' or timeout == nil then
timeout = config.lsp.format_timeout

View file

@ -1,3 +1,6 @@
# wires nvim
this is my current neovim config, based on [CosmicNvim](https://github.com/CosmicNvim/CosmicNvim), but with a substantial amount of reorganization and functionality I don't use stripped out.
this is my current neovim config, based on [CosmicNvim][1] but with a
substantial amount of reorganization and functionality I don't use stripped out.
[1]: https://github.com/CosmicNvim/CosmicNvim