2 Matching Annotations
  1. Jan 2022
    1. Pyright from what I can tell doesn't support formatting. Coc seems to be using autopep8 which is a formatter and not a language server. That being said, for the langauge servers which do support formatting, I use this inside of the on_attach callback from nvim-lspconfig: vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()]]
  2. Dec 2021
    1. How do I format files on save? See the following snippet: require("null-ls").setup({ -- you can reuse a shared lspconfig on_attach callback here on_attach = function(client) if client.resolved_capabilities.document_formatting then vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()") end end, })

      [[null-lsで保存時に自動フォーマットする]]