nvim_conf 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +63 -7
- data/lib/nvim_conf/commenter.rb +23 -0
- data/lib/nvim_conf/configuration_builder.rb +2 -2
- data/lib/nvim_conf/core.rb +37 -18
- data/lib/nvim_conf/generators/code/commands/lua.rb +37 -0
- data/lib/nvim_conf/generators/code/globals/lua.rb +47 -0
- data/lib/nvim_conf/generators/code/mappings/lua.rb +43 -11
- data/lib/nvim_conf/generators/code/plugins/packer.rb +4 -16
- data/lib/nvim_conf/generators/code/plugins/paq.rb +57 -0
- data/lib/nvim_conf/generators/code/requires/lua.rb +23 -0
- data/lib/nvim_conf/generators/code/settings/lua.rb +34 -12
- data/lib/nvim_conf/managers/commands.rb +38 -0
- data/lib/nvim_conf/{compiler_configurations/manager.rb → managers/compiler_configurations.rb} +4 -4
- data/lib/nvim_conf/managers/globals.rb +46 -0
- data/lib/nvim_conf/{mappings/manager.rb → managers/mappings.rb} +23 -8
- data/lib/nvim_conf/{plugins/manager.rb → managers/plugins.rb} +13 -6
- data/lib/nvim_conf/managers/requires.rb +34 -0
- data/lib/nvim_conf/{settings/manager.rb → managers/settings.rb} +22 -6
- data/lib/nvim_conf/models/command.rb +15 -0
- data/lib/nvim_conf/{compiler_configurations → models}/compiler_configuration.rb +1 -1
- data/lib/nvim_conf/models/global.rb +12 -0
- data/lib/nvim_conf/{mappings → models}/mapping.rb +2 -1
- data/lib/nvim_conf/{plugins → models}/plugin.rb +6 -1
- data/lib/nvim_conf/models/require.rb +11 -0
- data/lib/nvim_conf/{settings → models}/setting.rb +1 -1
- data/lib/nvim_conf/utils/io_operator.rb +21 -0
- data/lib/nvim_conf/utils/markdown_formatter.rb +35 -0
- data/lib/nvim_conf/version.rb +1 -1
- data/lib/nvim_conf/writer.rb +1 -1
- data/lib/nvim_conf/writers/code/commands.rb +36 -0
- data/lib/nvim_conf/writers/code/globals.rb +36 -0
- data/lib/nvim_conf/writers/code/mappings.rb +0 -1
- data/lib/nvim_conf/writers/code/orchestrator.rb +31 -6
- data/lib/nvim_conf/writers/code/plugins/configuration.rb +25 -0
- data/lib/nvim_conf/writers/code/plugins/handler.rb +25 -0
- data/lib/nvim_conf/writers/code/plugins/packer.rb +94 -0
- data/lib/nvim_conf/writers/code/plugins/paq.rb +49 -0
- data/lib/nvim_conf/writers/code/requires.rb +36 -0
- data/lib/nvim_conf/writers/documentation/globals.rb +45 -0
- data/lib/nvim_conf/writers/documentation/mappings.rb +5 -18
- data/lib/nvim_conf/writers/documentation/orchestrator.rb +26 -7
- data/lib/nvim_conf/writers/documentation/plugins.rb +54 -0
- data/lib/nvim_conf/writers/documentation/settings.rb +11 -18
- data/lib/nvim_conf.rb +11 -6
- metadata +32 -13
- data/lib/nvim_conf/generators/generator.rb +0 -6
- data/lib/nvim_conf/manager.rb +0 -6
- data/lib/nvim_conf/writers/code/plugins.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a309afbd9486b05dd70d891277a099b3acfa2e9bd28a9cd6c0c77faeb566d74b
|
4
|
+
data.tar.gz: 348b65e86219ea24189b394c91a5add233ab4f6256fcda8c0791f4c92238a352
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bec3cd5f112df5020609ac5c278726e4dcd80ec98a1feab0f1877d9f7beef12456c78956172116e77368aa6fb7ee03d74e3900c1000a326dafcbbfa1a25a4e09
|
7
|
+
data.tar.gz: b8d55f413d375fe6931251189ccf2cb9e25335c90edfd1b496ab6460c476939fa205ab16d193bcc7aab1b3854b58ef02950fff2ebe8a9ef18a209b757267373d
|
data/README.md
CHANGED
@@ -1,8 +1,17 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/nvim_conf.svg)](https://badge.fury.io/rb/nvim_conf)
|
2
|
+
|
1
3
|
# NvimConf
|
2
4
|
|
3
5
|
A configuration manager for neovim that functions as an abstraction between your intentions and your configuration.
|
4
6
|
Functions in a way that prevents having to rewrite everything in order to change your plugin manager.
|
5
7
|
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
```markdown
|
11
|
+
gem install nvim_conf
|
12
|
+
nvim_conf path_to_configuration_file
|
13
|
+
```
|
14
|
+
|
6
15
|
## Usage
|
7
16
|
|
8
17
|
```ruby
|
@@ -12,6 +21,11 @@ NvimConf::Core.define do
|
|
12
21
|
plug("tpope/vim-surround")
|
13
22
|
end
|
14
23
|
|
24
|
+
requires do
|
25
|
+
setup "nvim_lint"
|
26
|
+
setup "tester"
|
27
|
+
end
|
28
|
+
|
15
29
|
configuration do # configurate the generation of code and documentation
|
16
30
|
output_folder '$HOME/.config/nvim'
|
17
31
|
code_output :lua # you want lua? you want vim? NO PROBLEM!
|
@@ -37,6 +51,9 @@ return require('packer').startup(function()
|
|
37
51
|
use "tpope/vim-surround"
|
38
52
|
end)
|
39
53
|
|
54
|
+
require "nvim_lint".setup{}
|
55
|
+
require "tester".setup{}
|
56
|
+
|
40
57
|
vim.o.tabstop = true
|
41
58
|
vim.o.tabstop = false
|
42
59
|
```
|
@@ -55,14 +72,54 @@ File: $HOME/.config/nvim/Init.md
|
|
55
72
|
```
|
56
73
|
## Why use NvimConf?
|
57
74
|
|
58
|
-
|
75
|
+
### Abstraction
|
76
|
+
|
77
|
+
You no longer have to know about the exact syntax that vim and lua are handling calls to the api. One interface to configure them all.
|
78
|
+
|
79
|
+
This allows you to change your configuration without having to worry about a future language to configure vim... because we can just add the needed generators for the new langauge and your old configuration is good to go.
|
80
|
+
|
81
|
+
### Ruby
|
82
|
+
|
83
|
+
Because the abstraction is written in ruby and the configuration is also just a ruby file you are able to execute
|
84
|
+
any valid ruby code directly in your configuration. This allows you to introduce complex build tasks.
|
59
85
|
|
60
|
-
|
86
|
+
An example:
|
87
|
+
|
88
|
+
Input:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
[
|
92
|
+
:gzip,
|
93
|
+
:zip,
|
94
|
+
:zipPlugin,
|
95
|
+
:tar,
|
96
|
+
:tarPlugin,
|
97
|
+
:getscript
|
98
|
+
].each do | setting|
|
99
|
+
set "loaded_#{setting}", true
|
100
|
+
end
|
101
|
+
```
|
102
|
+
|
103
|
+
Output:
|
104
|
+
|
105
|
+
```lua
|
106
|
+
vim.g.loaded_gzip = true
|
107
|
+
vim.g.loaded_zip = true
|
108
|
+
vim.g.loaded_zipPlugin = true
|
109
|
+
vim.g.loaded_tar = true
|
110
|
+
vim.g.loaded_tarPlugin = true
|
111
|
+
vim.g.loaded_getscript = true
|
112
|
+
```
|
113
|
+
|
114
|
+
Use environment variables, ruby helpers, modules and all the good that ruby has to offer.
|
115
|
+
|
116
|
+
Why repeat yourself when you can script it?
|
61
117
|
|
62
118
|
### **The goals of NvimConf are**
|
63
|
-
|
64
|
-
-
|
65
|
-
-
|
119
|
+
|
120
|
+
- Automatic documentation to your configuration
|
121
|
+
- Decoupling the configuration from the actual code needed to arrive at the configuration state
|
122
|
+
- Version control of generation schema rather than actual configuration
|
66
123
|
- No more file changes due to a change in package manager... just change the one line in your configuration generator
|
67
124
|
- Provide reproducible configuration
|
68
125
|
- Sharable and copiable configuration that allows everyone to configure their neovim
|
@@ -80,18 +137,17 @@ There is always a better version of your autocomplete plugin.
|
|
80
137
|
- Param Checker
|
81
138
|
- Validate the settings parameters
|
82
139
|
- Check generated settings for functionality
|
83
|
-
- Custom embeeded Functions
|
84
140
|
- Split Configuraton into multiple files
|
85
141
|
- Render optimization by reducing the generation set
|
86
142
|
- Comment your configuration automatically
|
87
143
|
- Extend documentation generation
|
88
|
-
- Add plugin documentation
|
89
144
|
- Options for styling / spacing
|
90
145
|
- Meta information for your configuration
|
91
146
|
- Version
|
92
147
|
- Author-Name
|
93
148
|
- Generation Date
|
94
149
|
- Generation Architecture (Macos / Linux)
|
150
|
+
- Utility to share and donwload configurations
|
95
151
|
|
96
152
|
## Examples
|
97
153
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module NvimConf
|
2
|
+
class Commenter
|
3
|
+
class << self
|
4
|
+
def comment_block(configuration, section, spacer: false)
|
5
|
+
return if skip?(configuration)
|
6
|
+
|
7
|
+
padded_title = section.center(20)
|
8
|
+
border = "#" * (padded_title.length + 4)
|
9
|
+
|
10
|
+
<<~FORMAT
|
11
|
+
#{spacer ? "\n\n" : ""}
|
12
|
+
-- #{border}
|
13
|
+
-- # #{padded_title} #
|
14
|
+
-- #{border}
|
15
|
+
FORMAT
|
16
|
+
end
|
17
|
+
|
18
|
+
def skip?(configuration)
|
19
|
+
configuration[:format] != :lua || !configuration[:commented]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require "nvim_conf/compiler_configurations
|
1
|
+
require "nvim_conf/managers/compiler_configurations"
|
2
2
|
|
3
3
|
module NvimConf
|
4
4
|
class ConfigurationBuilder
|
5
|
-
CONFIGURATION_MANAGER = NvimConf::CompilerConfigurations
|
5
|
+
CONFIGURATION_MANAGER = NvimConf::Managers::CompilerConfigurations
|
6
6
|
|
7
7
|
def initialize(managers)
|
8
8
|
@managers = managers
|
data/lib/nvim_conf/core.rb
CHANGED
@@ -8,45 +8,64 @@ module NvimConf
|
|
8
8
|
).write
|
9
9
|
end
|
10
10
|
|
11
|
-
def plugins(name, bootstraped: false, &block)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def plugins(name, title: nil, bootstraped: false, &block)
|
12
|
+
evaluate_for_manager(
|
13
|
+
Managers::Plugins.new(name, title, bootstraped: bootstraped),
|
14
|
+
&block
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def commands(&block)
|
19
|
+
evaluate_for_manager(
|
20
|
+
Managers::Commands.new,
|
21
|
+
&block
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def requires(&block)
|
26
|
+
evaluate_for_manager(
|
27
|
+
Managers::Requires.new,
|
28
|
+
&block
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def globals(&block)
|
33
|
+
evaluate_for_manager(
|
34
|
+
Managers::Globals.new,
|
35
|
+
&block
|
17
36
|
)
|
18
37
|
end
|
19
38
|
|
20
|
-
def settings(&block)
|
21
|
-
|
22
|
-
Settings
|
39
|
+
def settings(title = nil, &block)
|
40
|
+
evaluate_for_manager(
|
41
|
+
Managers::Settings.new(title),
|
23
42
|
&block
|
24
|
-
)
|
43
|
+
)
|
25
44
|
end
|
26
45
|
|
27
46
|
def mappings(namespace = nil, &block)
|
28
|
-
|
29
|
-
Mappings
|
47
|
+
evaluate_for_manager(
|
48
|
+
Managers::Mappings.new(namespace),
|
30
49
|
&block
|
31
|
-
)
|
50
|
+
)
|
32
51
|
end
|
33
52
|
|
34
53
|
def configuration(&block)
|
35
|
-
|
36
|
-
CompilerConfigurations
|
54
|
+
evaluate_for_manager(
|
55
|
+
Managers::CompilerConfigurations.new,
|
37
56
|
&block
|
38
|
-
)
|
57
|
+
)
|
39
58
|
end
|
40
59
|
|
41
60
|
private
|
42
61
|
|
43
62
|
def evaluate_for_manager(manager, &block)
|
44
63
|
manager.instance_eval(&block)
|
45
|
-
manager
|
64
|
+
store_manager(manager)
|
46
65
|
end
|
47
66
|
|
48
67
|
def store_manager(manager)
|
49
|
-
return unless manager.store?
|
68
|
+
return unless manager.send(:store?)
|
50
69
|
|
51
70
|
NvimConf.managers.push(
|
52
71
|
manager
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module NvimConf
|
2
|
+
module Generators
|
3
|
+
module Commands
|
4
|
+
module Code
|
5
|
+
class Lua
|
6
|
+
def initialize(command)
|
7
|
+
@command = command
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate
|
11
|
+
send("#{@command.vim_exec ? "vim" : "lua"}_exec")
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def lua_exec
|
17
|
+
@command.body
|
18
|
+
end
|
19
|
+
|
20
|
+
def vim_exec
|
21
|
+
<<~FORMAT
|
22
|
+
vim.cmd([[
|
23
|
+
#{align_line_start(@command.body)}
|
24
|
+
]])
|
25
|
+
FORMAT
|
26
|
+
end
|
27
|
+
|
28
|
+
def align_line_start(body)
|
29
|
+
body.split("\n").map do |line|
|
30
|
+
" #{line}"
|
31
|
+
end.join("\n")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module NvimConf
|
2
|
+
module Generators
|
3
|
+
module Globals
|
4
|
+
module Code
|
5
|
+
class Lua
|
6
|
+
def initialize(global)
|
7
|
+
@global = global
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate
|
11
|
+
[
|
12
|
+
"vim.g.#{@global.name}",
|
13
|
+
format_value(@global.value)
|
14
|
+
].join(" = ")
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def format_value(value)
|
20
|
+
case value
|
21
|
+
when String
|
22
|
+
[
|
23
|
+
'"',
|
24
|
+
value,
|
25
|
+
'"'
|
26
|
+
].join
|
27
|
+
when Array
|
28
|
+
[
|
29
|
+
"{",
|
30
|
+
value.map { |inner_value| format_value(inner_value) }.join(", "),
|
31
|
+
"}"
|
32
|
+
].join
|
33
|
+
else
|
34
|
+
fallback_to_truthy_on_nil(value)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def fallback_to_truthy_on_nil(value)
|
39
|
+
return value unless value.nil?
|
40
|
+
|
41
|
+
@setting.operation == :set
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -17,35 +17,67 @@ module NvimConf
|
|
17
17
|
"tmap" => "t"
|
18
18
|
}
|
19
19
|
|
20
|
-
|
20
|
+
BASE_SET_METHOD = "vim.api.nvim_set_keymap"
|
21
|
+
BASE_UNSET_METHOD = "vim.api.nvim_del_keymap"
|
21
22
|
|
22
23
|
def initialize(mapping)
|
23
24
|
@mapping = mapping
|
24
25
|
end
|
25
26
|
|
26
27
|
def generate
|
28
|
+
if @mapping.remove
|
29
|
+
generate_unset
|
30
|
+
else
|
31
|
+
generate_set
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def generate_set
|
27
38
|
[
|
28
|
-
|
39
|
+
BASE_SET_METHOD,
|
29
40
|
"(",
|
30
41
|
argument_list,
|
31
42
|
")"
|
32
43
|
].join
|
33
44
|
end
|
34
45
|
|
35
|
-
|
46
|
+
def generate_unset
|
47
|
+
[
|
48
|
+
BASE_UNSET_METHOD,
|
49
|
+
"(",
|
50
|
+
[
|
51
|
+
MODE_MAPPING[@mapping.operator.to_s],
|
52
|
+
@mapping.binding
|
53
|
+
].map { |value| escape_value(value) }.join(", "),
|
54
|
+
")"
|
55
|
+
].join
|
56
|
+
end
|
36
57
|
|
37
58
|
def argument_list
|
38
|
-
[
|
59
|
+
([
|
39
60
|
MODE_MAPPING[@mapping.operator.to_s],
|
40
61
|
@mapping.binding,
|
41
62
|
@mapping.action
|
42
|
-
].map
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
63
|
+
].map { |value| escape_value(value) } + options).join(", ")
|
64
|
+
end
|
65
|
+
|
66
|
+
def escape_value(value)
|
67
|
+
escape_character = surround_symbol(value)
|
68
|
+
[
|
69
|
+
escape_character,
|
70
|
+
value,
|
71
|
+
escape_character
|
72
|
+
].join
|
73
|
+
end
|
74
|
+
|
75
|
+
def surround_symbol(value)
|
76
|
+
value.include?("'") ? '"' : "'"
|
77
|
+
end
|
78
|
+
|
79
|
+
def options
|
80
|
+
["{}"]
|
49
81
|
end
|
50
82
|
end
|
51
83
|
end
|
@@ -36,14 +36,7 @@ module NvimConf
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def command_arguments
|
39
|
-
|
40
|
-
:as,
|
41
|
-
:opt,
|
42
|
-
:file_types,
|
43
|
-
:branch,
|
44
|
-
:run,
|
45
|
-
:cmd
|
46
|
-
].map do |argument|
|
39
|
+
@plugin.class.optional_arguments.map do |argument|
|
47
40
|
next if @plugin.send(argument).nil?
|
48
41
|
|
49
42
|
[
|
@@ -60,14 +53,9 @@ module NvimConf
|
|
60
53
|
end
|
61
54
|
|
62
55
|
def args?
|
63
|
-
|
64
|
-
@plugin.
|
65
|
-
|
66
|
-
@plugin.branch,
|
67
|
-
@plugin.file_types,
|
68
|
-
@plugin.cmd,
|
69
|
-
@plugin.run
|
70
|
-
].any? { |argument| !argument.nil? }
|
56
|
+
@plugin.class.optional_arguments.map do |argument|
|
57
|
+
@plugin.send(argument)
|
58
|
+
end.any? { |argument| !argument.nil? }
|
71
59
|
end
|
72
60
|
end
|
73
61
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module NvimConf
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Code
|
5
|
+
class Paq
|
6
|
+
COMMAND_ALIAS = {
|
7
|
+
file_types: :ft
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize(plugin)
|
11
|
+
@plugin = plugin
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate
|
15
|
+
(args? ? "{#{command_call}}" : command_call) + ";"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def command_call
|
21
|
+
[
|
22
|
+
plugin_name,
|
23
|
+
*command_arguments
|
24
|
+
].compact.join(", ")
|
25
|
+
end
|
26
|
+
|
27
|
+
def plugin_name
|
28
|
+
"'#{@plugin.name}'"
|
29
|
+
end
|
30
|
+
|
31
|
+
def command_arguments
|
32
|
+
@plugin.class.optional_arguments.map do |argument|
|
33
|
+
next if @plugin.send(argument).nil?
|
34
|
+
|
35
|
+
[
|
36
|
+
COMMAND_ALIAS[argument] || argument,
|
37
|
+
escape_value(@plugin.send(argument))
|
38
|
+
].join(" = ")
|
39
|
+
end.compact
|
40
|
+
end
|
41
|
+
|
42
|
+
def escape_value(value)
|
43
|
+
return value unless value.is_a?(String)
|
44
|
+
|
45
|
+
"'#{value}'"
|
46
|
+
end
|
47
|
+
|
48
|
+
def args?
|
49
|
+
@plugin.class.optional_arguments.map do |argument|
|
50
|
+
@plugin.send(argument)
|
51
|
+
end.any? { |argument| !argument.nil? }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module NvimConf
|
2
|
+
module Generators
|
3
|
+
module Requires
|
4
|
+
module Code
|
5
|
+
class Lua
|
6
|
+
def initialize(require)
|
7
|
+
@require = require
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate
|
11
|
+
build_statement
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def build_statement
|
17
|
+
"require '#{@require.file}'.setup{}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -7,7 +7,8 @@ module NvimConf
|
|
7
7
|
|
8
8
|
SETTING_NAMESPACES = {
|
9
9
|
global: "o",
|
10
|
-
buffer: "bo"
|
10
|
+
buffer: "bo",
|
11
|
+
opt: "opt"
|
11
12
|
}
|
12
13
|
|
13
14
|
def initialize(setting)
|
@@ -15,14 +16,26 @@ module NvimConf
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def generate
|
19
|
+
if %i[set unset].include?(@setting.operation)
|
20
|
+
generate_set
|
21
|
+
else
|
22
|
+
generate_addition
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def generate_addition
|
29
|
+
"#{call_signature}:append(#{format_value(@setting.value)})"
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_set
|
18
33
|
[
|
19
34
|
call_signature,
|
20
|
-
|
35
|
+
format_value(@setting.value)
|
21
36
|
].join(" = ")
|
22
37
|
end
|
23
38
|
|
24
|
-
private
|
25
|
-
|
26
39
|
def call_signature
|
27
40
|
[
|
28
41
|
VIM_PREFIX,
|
@@ -31,14 +44,23 @@ module NvimConf
|
|
31
44
|
].join(".")
|
32
45
|
end
|
33
46
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
47
|
+
def format_value(value)
|
48
|
+
case value
|
49
|
+
when String
|
50
|
+
[
|
51
|
+
'"',
|
52
|
+
value,
|
53
|
+
'"'
|
54
|
+
].join
|
55
|
+
when Array
|
56
|
+
[
|
57
|
+
"{",
|
58
|
+
value.map { |inner_value| format_value(inner_value) }.join(", "),
|
59
|
+
"}"
|
60
|
+
].join
|
61
|
+
else
|
62
|
+
fallback_to_truthy_on_nil(value)
|
63
|
+
end
|
42
64
|
end
|
43
65
|
|
44
66
|
def fallback_to_truthy_on_nil(value)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "nvim_conf/models/command"
|
2
|
+
|
3
|
+
module NvimConf
|
4
|
+
module Managers
|
5
|
+
class Commands
|
6
|
+
attr_reader :commands
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@commands = []
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def section_name
|
14
|
+
"Commands"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def command(name, description: "", body: "", vim_exec: false)
|
19
|
+
store_command(name, description, body, vim_exec)
|
20
|
+
end
|
21
|
+
|
22
|
+
alias_method :new, :command
|
23
|
+
alias_method :c, :command
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def store_command(name, description, body, vim_exec)
|
28
|
+
@commands << Models::Command.new(
|
29
|
+
name, description, body, vim_exec: vim_exec
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def store?
|
34
|
+
@commands.any?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/nvim_conf/{compiler_configurations/manager.rb → managers/compiler_configurations.rb}
RENAMED
@@ -1,8 +1,8 @@
|
|
1
|
-
require "nvim_conf/
|
1
|
+
require "nvim_conf/models/compiler_configuration"
|
2
2
|
|
3
3
|
module NvimConf
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Managers
|
5
|
+
class CompilerConfigurations
|
6
6
|
attr_reader :configurations
|
7
7
|
|
8
8
|
def initialize
|
@@ -64,7 +64,7 @@ module NvimConf
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def build_configuration(name, value)
|
67
|
-
CompilerConfiguration.new(
|
67
|
+
Models::CompilerConfiguration.new(
|
68
68
|
name,
|
69
69
|
value
|
70
70
|
)
|