settings.lua 3.9 KB

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