settings.lua 4.7 KB

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