|
5 | 5 | }: let |
6 | 6 | inherit (lib.options) mkOption mkEnableOption literalMD; |
7 | 7 | inherit (lib.strings) optionalString; |
| 8 | + inherit (lib.attrsets) optionalAttrs; |
8 | 9 | inherit (lib.types) enum bool str int either; |
9 | 10 | inherit (lib.generators) mkLuaInline; |
10 | 11 | inherit (lib.nvim.dag) entryAfter; |
|
58 | 59 | description = "Prevent swapfile and backupfile from being created"; |
59 | 60 | }; |
60 | 61 |
|
61 | | - showSignColumn = mkOption { |
62 | | - type = bool; |
63 | | - default = true; |
64 | | - description = "Show the sign column"; |
65 | | - }; |
66 | | - |
67 | 62 | bell = mkOption { |
68 | 63 | type = enum ["none" "visual" "on"]; |
69 | 64 | default = "none"; |
70 | 65 | description = "Set how bells are handled. Options: on, visual or none"; |
71 | 66 | }; |
72 | 67 |
|
73 | | - enableEditorconfig = mkOption { |
74 | | - type = bool; |
75 | | - default = true; |
76 | | - description = "Follow editorconfig rules in current directory"; |
77 | | - }; |
78 | | - |
79 | 68 | searchCase = mkOption { |
80 | 69 | type = enum ["ignore" "smart" "sensitive"]; |
81 | 70 | default = "sensitive"; |
@@ -106,63 +95,55 @@ in { |
106 | 95 | # Set options that were previously interpolated in 'luaConfigRC.basic' as vim.options (vim.o) |
107 | 96 | # and 'vim.globals' (vim.g). Future options, if possible, should be added here instead of the |
108 | 97 | # luaConfigRC section below. |
109 | | - options = pushDownDefault { |
110 | | - encoding = "utf-8"; |
111 | | - hidden = true; |
112 | | - expandtab = true; |
113 | | - }; |
114 | | - |
115 | | - globals = pushDownDefault { |
116 | | - editorconfig = cfg.enableEditorconfig; |
117 | | - }; |
118 | | - |
119 | | - # Options that are more difficult to set through 'vim.options'. Fear not, though |
120 | | - # as the Lua DAG is still as powerful as it could be. |
| 98 | + options = pushDownDefault (lib.mergeAttrsList [ |
| 99 | + { |
| 100 | + # Options that are always set, with a lower priority |
| 101 | + encoding = "utf-8"; |
| 102 | + hidden = true; |
| 103 | + expandtab = true; |
| 104 | + |
| 105 | + # Junkfile Behaviour |
| 106 | + swapfile = !cfg.preventJunkFiles; |
| 107 | + backup = !cfg.preventJunkFiles; |
| 108 | + writebackup = !cfg.preventJunkFiles; |
| 109 | + } |
| 110 | + |
| 111 | + (optionalAttrs cfg.undoFile.enable { |
| 112 | + undofile = true; |
| 113 | + undodir = cfg.undoFile.path; |
| 114 | + }) |
| 115 | + |
| 116 | + (optionalAttrs (cfg.bell == "none") { |
| 117 | + errorbells = false; |
| 118 | + visualbell = false; |
| 119 | + }) |
| 120 | + |
| 121 | + (optionalAttrs (cfg.bell == "on") { |
| 122 | + visualbell = false; |
| 123 | + }) |
| 124 | + |
| 125 | + (optionalAttrs (cfg.bell == "visual") { |
| 126 | + visualbell = false; |
| 127 | + }) |
| 128 | + |
| 129 | + (optionalAttrs (cfg.lineNumberMode == "relative") { |
| 130 | + relativenumber = true; |
| 131 | + }) |
| 132 | + |
| 133 | + (optionalAttrs (cfg.lineNumberMode == "number") { |
| 134 | + number = true; |
| 135 | + }) |
| 136 | + |
| 137 | + (optionalAttrs (cfg.lineNumberMode == "relNumber") { |
| 138 | + number = true; |
| 139 | + relativenumber = true; |
| 140 | + }) |
| 141 | + ]); |
| 142 | + |
| 143 | + # Options that are more difficult to set through 'vim.options'. Namely, appending values |
| 144 | + # to pre-set Neovim options. Fear not, though as the Lua DAG is still as powerful as it |
| 145 | + # could be. |
121 | 146 | luaConfigRC.basic = entryAfter ["globalsScript"] '' |
122 | | - -- Settings that are set for everything |
123 | | - vim.opt.shortmess:append("c") |
124 | | -
|
125 | | - ${optionalString cfg.undoFile.enable '' |
126 | | - vim.o.undofile = true |
127 | | - vim.o.undodir = ${toLuaObject cfg.undoFile.path} |
128 | | - ''} |
129 | | -
|
130 | | - ${optionalString cfg.showSignColumn '' |
131 | | - vim.o.signcolumn = "yes" |
132 | | - ''} |
133 | | -
|
134 | | - ${optionalString cfg.preventJunkFiles '' |
135 | | - vim.o.swapfile = false |
136 | | - vim.o.backup = false |
137 | | - vim.o.writebackup = false |
138 | | - ''} |
139 | | -
|
140 | | - ${optionalString (cfg.bell == "none") '' |
141 | | - vim.o.errorbells = false |
142 | | - vim.o.visualbell = false |
143 | | - ''} |
144 | | -
|
145 | | - ${optionalString (cfg.bell == "on") '' |
146 | | - vim.o.visualbell = false |
147 | | - ''} |
148 | | -
|
149 | | - ${optionalString (cfg.bell == "visual") '' |
150 | | - vim.o.errorbells = false |
151 | | - ''} |
152 | | -
|
153 | | - ${optionalString (cfg.lineNumberMode == "relative") '' |
154 | | - vim.o.relativenumber = true |
155 | | - ''} |
156 | | -
|
157 | | - ${optionalString (cfg.lineNumberMode == "number") '' |
158 | | - vim.o.number = true |
159 | | - ''} |
160 | | -
|
161 | | - ${optionalString (cfg.lineNumberMode == "relNumber") '' |
162 | | - vim.o.number = true |
163 | | - vim.o.relativenumber = true |
164 | | - ''} |
165 | | -
|
166 | 147 | ${optionalString cfg.useSystemClipboard '' |
167 | 148 | vim.opt.clipboard:append("unnamedplus") |
168 | 149 | ''} |
|
0 commit comments