repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim: fix format command on windows

bf4ba57dd64d8851269b5698fc43467205d2486b

Oliver Krylow <o.krylow@isp-insoft.de> ·

unsigned

Browse filesCompare with HEAD

Changed files (2)

neovim/init.lua

Modified
14 14 vim.notify(
15 15 'This configuration assumes NeoVim version ' ..
16 16 expected.major .. '.' .. expected.minor .. ', but it is ' .. version.major .. '.' .. version.minor .. '!',
17 - vim.log.levels.ERROR)
17 + vim.log.levels.ERROR )
18 18 return
33 33 events = 'VimEnter',
34 34 description = 'Measure startup time of neovim.',
35 35 once = true,
36 - command = function()
36 + command = function ()
37 37 local end_time = vim.uv.hrtime() ---@diagnostic disable-line: undefined-field
38 38 local time_elapsed = end_time - start_time
39 - vim.schedule(function()
40 - vim.notify(string.format('Neovim started in (%d ms).', time_elapsed / 1e6), vim.log.levels.INFO)
41 - end)
39 + vim.schedule( function ()
40 + vim.notify( string.format( 'Neovim started in (%d ms).', time_elapsed / 1e6 ), vim.log.levels.INFO )
41 + end )
42 42 end,

neovim/lua/bugabinga/format.lua

Modified
3 3 local puk = require 'std.puk'
4 4 local dbg = require 'std.dbg'
5 5 local map = require 'std.map'
6 6 local user_command = require 'std.user_command'
8 -local format = function()
9 - require 'conform'.format({ async = false, lsp_fallback = true }, function(err)
8 +local format = function ()
9 + require 'conform'.format( { async = false }, function ( err )
10 10 if err and dbg.get() then
11 - vim.print('Format failed', err)
11 + vim.print( 'Format failed', err )
13 - end)
13 + end )
15 + vim.lsp.buf.format {
16 + filter = function ( client )
17 + local ok = client.supports_method 'textDocument/formatting' ---@diagnostic disable-line: param-type-mismatch, missing-parameter
18 + if ok and dbg.get() then print( 'Using LSP formatter: ' .. client.name ) end
19 + return ok
20 + end,
21 + async = false,
22 + }
16 25 map.N {
18 27 command = format,
21 -user_command.Format 'Format the current buffer' (format)
30 +user_command.Format 'Format the current buffer' ( format )
23 32 vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
25 -puk.defer 'conform' (function(conform)
34 +puk.defer 'conform' ( function ( conform )
26 35 conform.setup {
27 36 formatters_by_ft = {
28 37 toml = { 'taplo' },
44 53 log_level = dbg.get() and vim.log.levels.TRACE or vim.log.levels.INFO,
46 -end)
55 +end )