settings.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. showtabline = 2, -- always show tabs
  26. smartcase = true, -- smart case
  27. splitbelow = true, -- force all horizontal splits to go below current window
  28. splitright = true, -- force all vertical splits to go to the right of current window
  29. swapfile = false, -- creates a swapfile
  30. termguicolors = true, -- set term gui colors (most terminals support this)
  31. timeoutlen = 1000, -- time to wait for a mapped sequence to complete (in milliseconds)
  32. title = true, -- set the title of window to the value of the titlestring
  33. -- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to
  34. undodir = undodir, -- set an undo directory
  35. undofile = true, -- enable persistent undo
  36. updatetime = 100, -- faster completion
  37. 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
  38. expandtab = true, -- convert tabs to spaces
  39. shiftwidth = 2, -- the number of spaces inserted for each indentation
  40. tabstop = 2, -- insert 2 spaces for a tab
  41. cursorline = true, -- highlight the current line
  42. number = true, -- set numbered lines
  43. numberwidth = 4, -- set number column width to 2 {default 4}
  44. signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
  45. wrap = false, -- display lines as one long line
  46. shadafile = join_paths(get_cache_dir(), "lvim.shada"),
  47. scrolloff = 8, -- minimal number of screen lines to keep above and below the cursor.
  48. sidescrolloff = 8, -- minimal number of screen lines to keep left and right of the cursor.
  49. showcmd = false,
  50. ruler = false,
  51. laststatus = 3,
  52. }
  53. --- SETTINGS ---
  54. vim.opt.spelllang:append "cjk" -- disable spellchecking for asian characters (VIM algorithm does not support it)
  55. vim.opt.shortmess:append "c" -- don't show redundant messages from ins-completion-menu
  56. vim.opt.shortmess:append "I" -- don't show the default intro message
  57. vim.opt.whichwrap:append "<,>,[,],h,l"
  58. for k, v in pairs(default_options) do
  59. vim.opt[k] = v
  60. end
  61. vim.filetype.add {
  62. extension = {
  63. tex = "tex",
  64. zir = "zir",
  65. cr = "crystal",
  66. },
  67. pattern = {
  68. ["[jt]sconfig.*.json"] = "jsonc",
  69. },
  70. }
  71. end
  72. M.load_headless_options = function()
  73. vim.opt.shortmess = "" -- try to prevent echom from cutting messages off or prompting
  74. vim.opt.more = false -- don't pause listing when screen is filled
  75. vim.opt.cmdheight = 9999 -- helps avoiding |hit-enter| prompts.
  76. vim.opt.columns = 9999 -- set the widest screen possible
  77. vim.opt.swapfile = false -- don't use a swap file
  78. end
  79. M.load_defaults = function()
  80. if #vim.api.nvim_list_uis() == 0 then
  81. M.load_headless_options()
  82. return
  83. end
  84. M.load_default_options()
  85. end
  86. return M