fix(config): wire Vue TS backend and remove stale wrapping module
This commit is contained in:
parent
1c56f4cdc0
commit
7748db4117
18
init.lua
18
init.lua
|
|
@ -117,8 +117,6 @@ vim.schedule(function()
|
|||
vim.o.clipboard = 'unnamedplus'
|
||||
end)
|
||||
|
||||
require('custom.wrapping').setup()
|
||||
|
||||
-- Default to 4-space indentation unless overridden by filetype/plugins
|
||||
vim.o.tabstop = 4
|
||||
vim.o.shiftwidth = 4
|
||||
|
|
@ -723,6 +721,14 @@ require('lazy').setup({
|
|||
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
|
||||
-- - settings (table): Override the default settings passed when initializing the server.
|
||||
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
|
||||
local vue_language_server_path = vim.fn.stdpath 'data' .. '/mason/packages/vue-language-server/node_modules/@vue/language-server'
|
||||
local vue_typescript_plugin = {
|
||||
name = '@vue/typescript-plugin',
|
||||
location = vue_language_server_path,
|
||||
languages = { 'vue' },
|
||||
configNamespace = 'typescript',
|
||||
}
|
||||
|
||||
local servers = {
|
||||
-- Languages
|
||||
clangd = {},
|
||||
|
|
@ -778,6 +784,13 @@ require('lazy').setup({
|
|||
-- Tools
|
||||
eslint = {},
|
||||
astro = {},
|
||||
vue_ls = {},
|
||||
ts_ls = {
|
||||
filetypes = { 'vue' },
|
||||
init_options = {
|
||||
plugins = { vue_typescript_plugin },
|
||||
},
|
||||
},
|
||||
tailwindcss = {},
|
||||
docker_language_server = {},
|
||||
docker_compose_language_service = {},
|
||||
|
|
@ -792,7 +805,6 @@ require('lazy').setup({
|
|||
-- https://github.com/pmizio/typescript-tools.nvim
|
||||
--
|
||||
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
||||
-- ts_ls = {},
|
||||
--
|
||||
}
|
||||
---@type MasonLspconfigSettings
|
||||
|
|
|
|||
|
|
@ -1,98 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
local defaults = {
|
||||
width = 100,
|
||||
patterns = { '*.md', '*.markdown' },
|
||||
max_lines = 5000,
|
||||
max_bytes = 1024 * 1024,
|
||||
}
|
||||
|
||||
local function apply_wrap_options(local_opts, width)
|
||||
local_opts.wrap = true
|
||||
local_opts.linebreak = true
|
||||
local_opts.breakindent = true
|
||||
local_opts.textwidth = width
|
||||
local_opts.colorcolumn = ''
|
||||
local_opts.formatoptions:append 't'
|
||||
local_opts.formatoptions:append 'a'
|
||||
local_opts.formatoptions:remove 'l'
|
||||
end
|
||||
|
||||
local function can_reflow(bufnr, opts)
|
||||
if not vim.api.nvim_buf_is_valid(bufnr) or not vim.bo[bufnr].modifiable or vim.bo[bufnr].buftype ~= '' then
|
||||
return false
|
||||
end
|
||||
|
||||
if opts.max_lines and vim.api.nvim_buf_line_count(bufnr) > opts.max_lines then
|
||||
return false
|
||||
end
|
||||
|
||||
local name = vim.api.nvim_buf_get_name(bufnr)
|
||||
if name ~= '' and opts.max_bytes then
|
||||
local stat = (vim.uv or vim.loop).fs_stat(name)
|
||||
if stat and stat.size and stat.size > opts.max_bytes then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local function reflow_whole_buffer(bufnr, preserve_view, opts)
|
||||
if not can_reflow(bufnr, opts) then
|
||||
return
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_call(bufnr, function()
|
||||
local view = preserve_view and vim.fn.winsaveview() or nil
|
||||
vim.cmd 'silent keepjumps normal! gggqG'
|
||||
if view then
|
||||
vim.fn.winrestview(view)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
opts = vim.tbl_deep_extend('force', defaults, opts or {})
|
||||
|
||||
local group = vim.api.nvim_create_augroup('custom_wrapping_rules', { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
group = group,
|
||||
pattern = 'markdown',
|
||||
callback = function()
|
||||
-- Apply after ftplugins so local overrides don't drop wrap options.
|
||||
vim.schedule(function()
|
||||
apply_wrap_options(vim.opt_local, opts.width)
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('BufReadPost', {
|
||||
group = group,
|
||||
pattern = opts.patterns,
|
||||
callback = function(args)
|
||||
-- Reflow existing prose on open so the hard wrap rule is applied immediately.
|
||||
if vim.b[args.buf].did_initial_wrap then
|
||||
return
|
||||
end
|
||||
vim.b[args.buf].did_initial_wrap = true
|
||||
vim.schedule(function()
|
||||
reflow_whole_buffer(args.buf, false, opts)
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
group = group,
|
||||
pattern = opts.patterns,
|
||||
callback = function(args)
|
||||
if not vim.bo[args.buf].modified then
|
||||
return
|
||||
end
|
||||
reflow_whole_buffer(args.buf, true, opts)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Reference in New Issue