Compare commits
3 commits
3633ac6565
...
87e396ff15
Author | SHA1 | Date | |
---|---|---|---|
87e396ff15 | |||
7827e7db11 | |||
b8ab53fa2a |
9 changed files with 52 additions and 27 deletions
|
@ -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
|
|
|
@ -1,9 +1,15 @@
|
||||||
return {
|
return {
|
||||||
'rust_analyzer',
|
rust_analyzer = true,
|
||||||
'erlangls',
|
erlangls = true,
|
||||||
'lua_ls',
|
lua_ls = {
|
||||||
'cssls',
|
format_on_save = false,
|
||||||
'eslint',
|
},
|
||||||
'ts_ls',
|
cssls = {
|
||||||
'svelte',
|
format_on_save = false,
|
||||||
|
},
|
||||||
|
eslint = true,
|
||||||
|
ts_ls = {
|
||||||
|
format_on_save = false,
|
||||||
|
},
|
||||||
|
svelte = true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ local M = {}
|
||||||
local augroup_name = 'CosmicNvimLspFormat'
|
local augroup_name = 'CosmicNvimLspFormat'
|
||||||
local config = require('config')
|
local config = require('config')
|
||||||
local u = require('utils')
|
local u = require('utils')
|
||||||
|
local lsp_utils = require('utils.lsp')
|
||||||
local lsp_mappings = require('lsp.mappings')
|
local lsp_mappings = require('lsp.mappings')
|
||||||
|
|
||||||
M.augroup = vim.api.nvim_create_augroup(augroup_name, { clear = true })
|
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', {
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.lsp.buf.format({
|
if lsp_utils.format_on_save_enabled then
|
||||||
timeout_ms = config.lsp.format_timeout,
|
vim.lsp.buf.format({
|
||||||
bufnr = bufnr,
|
timeout_ms = config.lsp.format_timeout,
|
||||||
})
|
bufnr = bufnr,
|
||||||
|
filter = function(cl)
|
||||||
|
return lsp_utils.can_client_format_on_save(cl)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
group = M.augroup,
|
group = M.augroup,
|
||||||
|
|
|
@ -38,4 +38,4 @@ map('n', '<C-Right>', ':vertical resize +2<CR>', { desc = 'Vertical Resize +2' }
|
||||||
|
|
||||||
-- easy insertion of trailing ; and , from insert mode.
|
-- easy insertion of trailing ; and , from insert mode.
|
||||||
map('i', ';;', '<Esc>A;<Esc>')
|
map('i', ';;', '<Esc>A;<Esc>')
|
||||||
map('i', ',,', '<Esc>A;<Esc>')
|
map('i', ',,', '<Esc>A,<Esc>')
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
local config = {
|
local config = {
|
||||||
|
auto_restore = true,
|
||||||
|
auto_session = true,
|
||||||
|
enabled = true,
|
||||||
pre_save_cmds = { 'cclose', 'lua vim.notify.dismiss()' },
|
pre_save_cmds = { 'cclose', 'lua vim.notify.dismiss()' },
|
||||||
auto_session_enabled = true,
|
|
||||||
auto_restore_enabled = true,
|
|
||||||
auto_save_enabled = true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -13,7 +13,6 @@ return {
|
||||||
local config_opts = {
|
local config_opts = {
|
||||||
sources = {
|
sources = {
|
||||||
null_ls.builtins.code_actions.gitsigns,
|
null_ls.builtins.code_actions.gitsigns,
|
||||||
null_ls.builtins.diagnostics.markdownlint,
|
|
||||||
null_ls.builtins.formatting.prettierd.with({
|
null_ls.builtins.formatting.prettierd.with({
|
||||||
env = {
|
env = {
|
||||||
PRETTIERD_LOCAL_PRETTIER_ONLY = 1,
|
PRETTIERD_LOCAL_PRETTIER_ONLY = 1,
|
||||||
|
@ -21,7 +20,7 @@ return {
|
||||||
extra_filetypes = { 'astro' },
|
extra_filetypes = { 'astro' },
|
||||||
}),
|
}),
|
||||||
null_ls.builtins.formatting.stylua,
|
null_ls.builtins.formatting.stylua,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
null_ls.setup(u.merge(defaults, config_opts))
|
null_ls.setup(u.merge(defaults, config_opts))
|
||||||
|
|
|
@ -18,7 +18,7 @@ return {
|
||||||
lspconfig[server].setup(server_config)
|
lspconfig[server].setup(server_config)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, server in pairs(require('lsp.servers')) do
|
for server, _ in pairs(require('lsp.servers')) do
|
||||||
start_server(server)
|
start_server(server)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
local config = require('config')
|
local config = require('config')
|
||||||
|
local servers = require('lsp.servers')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.format_on_save_enabled = true
|
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))
|
vim.notify(string.format('Format on save: %s', M.format_on_save_enabled))
|
||||||
end
|
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)
|
function M.buf_format(bufnr, timeout)
|
||||||
if timeout == '' or timeout == nil then
|
if timeout == '' or timeout == nil then
|
||||||
timeout = config.lsp.format_timeout
|
timeout = config.lsp.format_timeout
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
# wires nvim
|
# 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
|
||||||
|
|
Loading…
Add table
Reference in a new issue