settings.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. local M = {}
  2. local join_paths = require("lvim.utils").join_paths
  3. M.load_default_options = function()
  4. local default_options = {
  5. backup = false, -- creates a backup file
  6. clipboard = "unnamedplus", -- allows neovim to access the system clipboard
  7. cmdheight = 2, -- more space in the neovim command line for displaying messages
  8. colorcolumn = "99999", -- fixes indentline for now
  9. completeopt = { "menuone", "noselect" },
  10. conceallevel = 0, -- so that `` is visible in markdown files
  11. fileencoding = "utf-8", -- the encoding written to a file
  12. foldmethod = "manual", -- folding, set to "expr" for treesitter based folding
  13. foldexpr = "", -- set to "nvim_treesitter#foldexpr()" for treesitter based folding
  14. guifont = "monospace:h17", -- the font used in graphical neovim applications
  15. hidden = true, -- required to keep multiple buffers and open multiple buffers
  16. hlsearch = true, -- highlight all matches on previous search pattern
  17. ignorecase = true, -- ignore case in search patterns
  18. mouse = "a", -- allow the mouse to be used in neovim
  19. pumheight = 10, -- pop up menu height
  20. showmode = false, -- we don't need to see things like -- INSERT -- anymore
  21. showtabline = 2, -- always show tabs
  22. smartcase = true, -- smart case
  23. smartindent = true, -- make indenting smarter again
  24. splitbelow = true, -- force all horizontal splits to go below current window
  25. splitright = true, -- force all vertical splits to go to the right of current window
  26. swapfile = false, -- creates a swapfile
  27. termguicolors = true, -- set term gui colors (most terminals support this)
  28. timeoutlen = 250, -- time to wait for a mapped sequence to complete (in milliseconds)
  29. title = true, -- set the title of window to the value of the titlestring
  30. -- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to
  31. undodir = join_paths(get_cache_dir(), "undo"), -- set an undo directory
  32. undofile = true, -- enable persistent undo
  33. updatetime = 300, -- faster completion
  34. 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
  35. expandtab = true, -- convert tabs to spaces
  36. shiftwidth = 2, -- the number of spaces inserted for each indentation
  37. tabstop = 2, -- insert 2 spaces for a tab
  38. cursorline = true, -- highlight the current line
  39. number = true, -- set numbered lines
  40. relativenumber = false, -- set relative 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. spell = false,
  45. spelllang = "en",
  46. spellfile = join_paths(get_config_dir(), "spell", "en.utf-8.add"),
  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. }
  51. --- SETTINGS ---
  52. vim.opt.shortmess:append "c"
  53. vim.opt.whichwrap:append "<,>,[,],h,l"
  54. for k, v in pairs(default_options) do
  55. vim.opt[k] = v
  56. end
  57. end
  58. M.load_headless_options = function()
  59. vim.opt.shortmess = "" -- try to prevent echom from cutting messages off or prompting
  60. vim.opt.more = false -- don't pause listing when screen is filled
  61. vim.opt.cmdheight = 9999 -- helps avoiding |hit-enter| prompts.
  62. vim.opt.columns = 9999 -- set the widest screen possible
  63. vim.opt.swapfile = false -- don't use a swap file
  64. end
  65. M.load_options = function()
  66. if #vim.api.nvim_list_uis() == 0 then
  67. M.load_headless_options()
  68. return
  69. end
  70. M.load_default_options()
  71. end
  72. return M