@@ -23,7 +23,6 @@ local ts_util = require "nvim-lsp-ts-utils"
2323-- require("vim.lsp.log").set_level "trace"
2424
2525local status = require " tj.lsp.status"
26- print (" STATUS" , status )
2726if status then
2827 status .activate ()
2928end
@@ -33,32 +32,49 @@ local custom_init = function(client)
3332 client .config .flags .allow_incremental_sync = true
3433end
3534
35+ local augroup_format = vim .api .nvim_create_augroup (" my_lsp_format" , { clear = true })
36+ local autocmd_format = function (async , filter )
37+ vim .api .nvim_clear_autocmds { buffer = 0 , group = augroup_format }
38+ vim .api .nvim_create_autocmd (" BufWritePre" , {
39+ buffer = 0 ,
40+ callback = function ()
41+ vim .lsp .buf .format { async = async , filter = filter }
42+ end ,
43+ })
44+ end
45+
3646local filetype_attach = setmetatable ({
37- go = function (client )
38- vim .cmd [[
39- augroup lsp_buf_format
40- au! BufWritePre <buffer>
41- autocmd BufWritePre <buffer> :lua vim.lsp.buf.formatting_sync()
42- augroup END
43- ]]
47+ go = function ()
48+ autocmd_format (false )
49+ end ,
50+
51+ scss = function ()
52+ autocmd_format (false )
53+ end ,
54+
55+ css = function ()
56+ autocmd_format (false )
4457 end ,
4558
4659 rust = function ()
60+ -- vim.cmd [[
61+ -- autocmd BufEnter,BufWritePost <buffer> :lua require('lsp_extensions.inlay_hints').request {aligned = true, prefix = " » "}
62+ -- ]]
63+
4764 telescope_mapper (" <space>wf" , " lsp_workspace_symbols" , {
4865 ignore_filename = true ,
4966 query = " #" ,
5067 }, true )
5168
52- -- vim.cmd [[
53- -- autocmd BufEnter,BufWritePost <buffer> :lua require('lsp_extensions.inlay_hints').request {aligned = true, prefix = " » "}
54- -- ]]
69+ autocmd_format (false )
70+ end ,
5571
56- vim . cmd [[
57- augroup lsp_buf_format
58- au! BufWritePre <buffer>
59- autocmd BufWritePre <buffer> :lua vim.lsp.buf.formatting_sync()
60- augroup END
61- ]]
72+ typescript = function ()
73+ autocmd_format ( false , function ( clients )
74+ return vim . tbl_filter ( function ( client )
75+ return client . name ~= " tsserver "
76+ end , clients )
77+ end )
6278 end ,
6379}, {
6480 __index = function ()
@@ -117,6 +133,8 @@ local custom_attach = function(client)
117133
118134 -- Set autocommands conditional on server_capabilities
119135 if client .server_capabilities .documentHighlightProvider then
136+ P (client .server_capabilities .documentHighlightProvider )
137+
120138 vim .cmd [[
121139 augroup lsp_document_highlight
122140 autocmd! * <buffer>
@@ -213,12 +231,9 @@ local servers = {
213231 rust_analyzer = {
214232 cmd = { " rustup" , " run" , " nightly" , " rust-analyzer" },
215233 },
216- -- settings = {
217- -- ["rust-analyzer"] = {
218- -- },
219- -- },
220234
221235 elmls = true ,
236+ cssls = true ,
222237
223238 tsserver = {
224239 init_options = ts_util .init_options ,
@@ -348,14 +363,15 @@ end
348363-- }
349364
350365-- Set up null-ls
351- local use_null = false
366+ local use_null = true
352367if use_null then
353368 require (" null-ls" ).setup {
354369 sources = {
355370 -- require("null-ls").builtins.formatting.stylua,
356371 -- require("null-ls").builtins.diagnostics.eslint,
357372 -- require("null-ls").builtins.completion.spell,
358- require (" null-ls" ).builtins .diagnostics .selene ,
373+ -- require("null-ls").builtins.diagnostics.selene,
374+ require (" null-ls" ).builtins .formatting .prettierd ,
359375 },
360376 }
361377end
0 commit comments