settings.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. local M = {}
  2. M.load_default_options = function()
  3. local utils = require "lvim.utils"
  4. local join_paths = utils.join_paths
  5. local undodir = join_paths(get_cache_dir(), "undo")
  6. if not utils.is_directory(undodir) then
  7. vim.fn.mkdir(undodir, "p")
  8. end
  9. local default_options = {
  10. backup = false, -- creates a backup file
  11. clipboard = "unnamedplus", -- allows neovim to access the system clipboard
  12. cmdheight = 1, -- more space in the neovim command line for displaying messages
  13. completeopt = { "menuone", "noselect" },
  14. conceallevel = 0, -- so that `` is visible in markdown files
  15. fileencoding = "utf-8", -- the encoding written to a file
  16. foldmethod = "manual", -- folding, set to "expr" for treesitter based folding
  17. foldexpr = "", -- set to "nvim_treesitter#foldexpr()" for treesitter based folding
  18. guifont = "monospace:h17", -- the font used in graphical neovim applications
  19. hidden = true, -- required to keep multiple buffers and open multiple buffers
  20. hlsearch = true, -- highlight all matches on previous search pattern
  21. ignorecase = true, -- ignore case in search patterns
  22. mouse = "a", -- allow the mouse to be used in neovim
  23. pumheight = 10, -- pop up menu height
  24. showmode = false, -- we don't need to see things like -- INSERT -- anymore
  25. smartcase = true, -- smart case
  26. splitbelow = true, -- force all horizontal splits to go below current window
  27. splitright = true, -- force all vertical splits to go to the right of current window
  28. swapfile = false, -- creates a swapfile
  29. termguicolors = true, -- set term gui colors (most terminals support this)
  30. timeoutlen = 1000, -- time to wait for a mapped sequence to complete (in milliseconds)
  31. title = true, -- set the title of window to the value of the titlestring
  32. -- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to
  33. undodir = undodir, -- set an undo directory
  34. undofile = true, -- enable persistent undo
  35. updatetime = 100, -- faster completion
  36. writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
  37. expandtab = true, -- convert tabs to spaces
  38. shiftwidth = 2, -- the number of spaces inserted for each indentation
  39. tabstop = 2, -- insert 2 spaces for a tab
  40. cursorline = true, -- highlight the current line
  41. number = true, -- set numbered lines
  42. numberwidth = 4, -- set number column width to 2 {default 4}
  43. signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
  44. wrap = false, -- display lines as one long line
  45. shadafile = join_paths(get_cache_dir(), "lvim.shada"),
  46. scrolloff = 8, -- minimal number of screen lines to keep above and below the cursor.
  47. sidescrolloff = 8, -- minimal number of screen lines to keep left and right of the cursor.
  48. showcmd = false,
  49. ruler = false,
  50. laststatus = 3,
  51. }
  52. --- SETTINGS ---
  53. vim.opt.spelllang:append "cjk" -- disable spellchecking for asian characters (VIM algorithm does not support it)
  54. vim.opt.shortmess:append "c" -- don't show redundant messages from ins-completion-menu
  55. vim.opt.shortmess:append "I" -- don't show the default intro message
  56. vim.opt.whichwrap:append "<,>,[,],h,l"
  57. for k, v in pairs(default_options) do
  58. vim.opt[k] = v
  59. end
  60. vim.filetype.add {
  61. extension = {
  62. tex = "tex",
  63. zir = "zir",
  64. cr = "crystal",
  65. },
  66. pattern = {
  67. ["[jt]sconfig.*.json"] = "jsonc",
  68. },
  69. }
  70. local default_diagnostic_config = {
  71. signs = {
  72. active = true,
  73. values = {
  74. { name = "DiagnosticSignError", text = lvim.icons.diagnostics.Error },
  75. { name = "DiagnosticSignWarn", text = lvim.icons.diagnostics.Warning },
  76. { name = "DiagnosticSignHint", text = lvim.icons.diagnostics.Hint },
  77. { name = "DiagnosticSignInfo", text = lvim.icons.diagnostics.Information },
  78. },
  79. },
  80. virtual_text = true,
  81. update_in_insert = false,
  82. underline = true,
  83. severity_sort = true,
  84. float = {
  85. focusable = true,
  86. style = "minimal",
  87. border = "rounded",
  88. source = "always",
  89. header = "",
  90. prefix = "",
  91. },
  92. }
  93. vim.diagnostic.config(default_diagnostic_config)
  94. end
  95. M.load_headless_options = function()
  96. vim.opt.shortmess = "" -- try to prevent echom from cutting messages off or prompting
  97. vim.opt.more = false -- don't pause listing when screen is filled
  98. vim.opt.cmdheight = 9999 -- helps avoiding |hit-enter| prompts.
  99. vim.opt.columns = 9999 -- set the widest screen possible
  100. vim.opt.swapfile = false -- don't use a swap file
  101. end
  102. M.load_defaults = function()
  103. if #vim.api.nvim_list_uis() == 0 then
  104. M.load_headless_options()
  105. return
  106. end
  107. M.load_default_options()
  108. end
  109. return M