settings.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 = 2, -- more space in the neovim command line for displaying messages
  13. colorcolumn = "99999", -- fixes indentline for now
  14. completeopt = { "menuone", "noselect" },
  15. conceallevel = 0, -- so that `` is visible in markdown files
  16. fileencoding = "utf-8", -- the encoding written to a file
  17. foldmethod = "manual", -- folding, set to "expr" for treesitter based folding
  18. foldexpr = "", -- set to "nvim_treesitter#foldexpr()" for treesitter based folding
  19. guifont = "monospace:h17", -- the font used in graphical neovim applications
  20. hidden = true, -- required to keep multiple buffers and open multiple buffers
  21. hlsearch = true, -- highlight all matches on previous search pattern
  22. ignorecase = true, -- ignore case in search patterns
  23. mouse = "a", -- allow the mouse to be used in neovim
  24. pumheight = 10, -- pop up menu height
  25. showmode = false, -- we don't need to see things like -- INSERT -- anymore
  26. showtabline = 2, -- always show tabs
  27. smartcase = true, -- smart case
  28. smartindent = true, -- make indenting smarter again
  29. splitbelow = true, -- force all horizontal splits to go below current window
  30. splitright = true, -- force all vertical splits to go to the right of current window
  31. swapfile = false, -- creates a swapfile
  32. termguicolors = true, -- set term gui colors (most terminals support this)
  33. timeoutlen = 250, -- time to wait for a mapped sequence to complete (in milliseconds)
  34. title = true, -- set the title of window to the value of the titlestring
  35. -- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to
  36. undodir = undodir, -- set an undo directory
  37. undofile = true, -- enable persistent undo
  38. updatetime = 300, -- faster completion
  39. 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
  40. expandtab = true, -- convert tabs to spaces
  41. shiftwidth = 2, -- the number of spaces inserted for each indentation
  42. tabstop = 2, -- insert 2 spaces for a tab
  43. cursorline = true, -- highlight the current line
  44. number = true, -- set numbered lines
  45. relativenumber = false, -- set relative numbered lines
  46. numberwidth = 4, -- set number column width to 2 {default 4}
  47. signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
  48. wrap = false, -- display lines as one long line
  49. shadafile = join_paths(get_cache_dir(), "lvim.shada"),
  50. scrolloff = 8, -- minimal number of screen lines to keep above and below the cursor.
  51. sidescrolloff = 8, -- minimal number of screen lines to keep left and right of the cursor.
  52. }
  53. --- SETTINGS ---
  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. end
  61. M.load_headless_options = function()
  62. vim.opt.shortmess = "" -- try to prevent echom from cutting messages off or prompting
  63. vim.opt.more = false -- don't pause listing when screen is filled
  64. vim.opt.cmdheight = 9999 -- helps avoiding |hit-enter| prompts.
  65. vim.opt.columns = 9999 -- set the widest screen possible
  66. vim.opt.swapfile = false -- don't use a swap file
  67. end
  68. M.load_defaults = function()
  69. if #vim.api.nvim_list_uis() == 0 then
  70. M.load_headless_options()
  71. return
  72. end
  73. M.load_default_options()
  74. end
  75. return M