editorconfig.txt 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. *editorconfig.txt* Nvim
  2. NVIM REFERENCE MANUAL
  3. Type |gO| to see the table of contents.
  4. ==============================================================================
  5. EditorConfig integration *editorconfig*
  6. Nvim supports EditorConfig. When a file is opened, after running |ftplugin|s
  7. and |FileType| autocommands, Nvim searches all parent directories of that file
  8. for ".editorconfig" files, parses them, and applies any properties that match
  9. the opened file. Think of it like 'modeline' for an entire (recursive)
  10. directory. For more information see https://editorconfig.org/.
  11. *g:editorconfig* *b:editorconfig*
  12. EditorConfig is enabled by default. To disable it, add to your config: >lua
  13. vim.g.editorconfig = false
  14. <
  15. (Vimscript: `let g:editorconfig = v:false`). It can also be disabled
  16. per-buffer by setting the |b:editorconfig| buffer-local variable to `false`.
  17. Nvim stores the applied properties in |b:editorconfig| if it is not `false`.
  18. *editorconfig-custom-properties*
  19. New properties can be added by adding a new entry to the "properties" table.
  20. The table key is a property name and the value is a callback function which
  21. accepts the number of the buffer to be modified, the value of the property in
  22. the `.editorconfig` file, and (optionally) a table containing all of the other
  23. properties and their values (useful for properties which depend on other
  24. properties). The value is always a string and must be coerced if necessary.
  25. Example: >lua
  26. require('editorconfig').properties.foo = function(bufnr, val, opts)
  27. if opts.charset and opts.charset ~= "utf-8" then
  28. error("foo can only be set when charset is utf-8", 0)
  29. end
  30. vim.b[bufnr].foo = val
  31. end
  32. <
  33. *editorconfig-properties*
  34. The following properties are supported by default:
  35. charset *editorconfig.charset*
  36. One of `"utf-8"`, `"utf-8-bom"`, `"latin1"`, `"utf-16be"`, or
  37. `"utf-16le"`. Sets the 'fileencoding' and 'bomb' options.
  38. end_of_line *editorconfig.end_of_line*
  39. One of `"lf"`, `"crlf"`, or `"cr"`. These correspond to setting
  40. 'fileformat' to "unix", "dos", or "mac", respectively.
  41. indent_size *editorconfig.indent_size*
  42. A number indicating the size of a single indent. Alternatively, use the
  43. value "tab" to use the value of the tab_width property. Sets the
  44. 'shiftwidth' and 'softtabstop' options. If this value is not "tab" and the
  45. tab_width property is not set, 'tabstop' is also set to this value.
  46. indent_style *editorconfig.indent_style*
  47. One of `"tab"` or `"space"`. Sets the 'expandtab' option.
  48. insert_final_newline *editorconfig.insert_final_newline*
  49. `"true"` or `"false"` to ensure the file always has a trailing newline as
  50. its last byte. Sets the 'fixendofline' and 'endofline' options.
  51. max_line_length *editorconfig.max_line_length*
  52. A number indicating the maximum length of a single line. Sets the
  53. 'textwidth' option.
  54. root *editorconfig.root*
  55. If "true", then stop searching for `.editorconfig` files in parent
  56. directories. This property must be at the top-level of the `.editorconfig`
  57. file (i.e. it must not be within a glob section).
  58. spelling_language *editorconfig.spelling_language*
  59. A code of the format ss or ss-TT, where ss is an ISO 639 language code and
  60. TT is an ISO 3166 territory identifier. Sets the 'spelllang' option.
  61. tab_width *editorconfig.tab_width*
  62. The display size of a single tab character. Sets the 'tabstop' option.
  63. trim_trailing_whitespace *editorconfig.trim_trailing_whitespace*
  64. When `"true"`, trailing whitespace is automatically removed when the
  65. buffer is written.
  66. vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: