mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 02:52:37 +00:00 
			
		
		
		
	fix: re-work formatting code
This commit is contained in:
		
					parent
					
						
							
								d0a2345bfa
							
						
					
				
			
			
				commit
				
					
						2b6580e19c
					
				
			
		
					 1 changed files with 14 additions and 13 deletions
				
			
		|  | @ -36,20 +36,21 @@ in { | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       -- Enable formatting |       -- Enable formatting | ||||||
|  |       local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) | ||||||
|  | 
 | ||||||
|       format_callback = function(client, bufnr) |       format_callback = function(client, bufnr) | ||||||
|  |         if vim.g.formatsave and client.supports_method("textDocument/formatting") then | ||||||
|  |           vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) | ||||||
|           vim.api.nvim_create_autocmd("BufWritePre", { |           vim.api.nvim_create_autocmd("BufWritePre", { | ||||||
|             group = augroup, |             group = augroup, | ||||||
|             buffer = bufnr, |             buffer = bufnr, | ||||||
|             callback = function() |             callback = function() | ||||||
|             if vim.g.formatsave then |               vim.lsp.buf.format({ | ||||||
|               if client.supports_method("textDocument/formatting") then |                 bufnr = bufnr | ||||||
|                 local params = require'vim.lsp.util'.make_formatting_params({}) |  | ||||||
|                 client.request('textDocument/formatting', params, nil, bufnr) |  | ||||||
| 
 |  | ||||||
|               end |  | ||||||
|             end |  | ||||||
|           end |  | ||||||
|               }) |               }) | ||||||
|  |             end, | ||||||
|  |           }) | ||||||
|  |         end | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       default_on_attach = function(client, bufnr) |       default_on_attach = function(client, bufnr) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 n3oney
				n3oney