aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Igne <git@federicoigne.com>2023-02-22 10:40:10 +0100
committerFederico Igne <git@federicoigne.com>2023-02-22 10:40:10 +0100
commit5d442d33e1de8a582dfd9645fa0c61b964f4d257 (patch)
tree3e3afddb04ddf189f5fd32279dd722debdafa9a3
parentc6dfb74bb0206a89d4b69311334133541d1d6aa5 (diff)
downloaddotfiles-5d442d33e1de8a582dfd9645fa0c61b964f4d257.tar.gz
dotfiles-5d442d33e1de8a582dfd9645fa0c61b964f4d257.zip
[nvim] add autocapitalization for Dockerfile keywords
-rw-r--r--neovim/.config/nvim/after/ftplugin/dockerfile.lua10
-rw-r--r--neovim/.config/nvim/lua/dyamon/util/abbrev.lua31
2 files changed, 41 insertions, 0 deletions
diff --git a/neovim/.config/nvim/after/ftplugin/dockerfile.lua b/neovim/.config/nvim/after/ftplugin/dockerfile.lua
new file mode 100644
index 0000000..deb3ccf
--- /dev/null
+++ b/neovim/.config/nvim/after/ftplugin/dockerfile.lua
@@ -0,0 +1,10 @@
1--- Personal lua config files for NeoVim.
2-- Last Changed: 2023-01-10
3-- Author: Federico Igne <git@federicoigne.com>
4-- License: This file is placed in the public domain.
5
6local abbrev = require 'dyamon.util.abbrev'
7
8for _,w in ipairs({ "from", "workdir", "copy", "run", "cmd" }) do
9 abbrev.i(w, "luaeval('require\"dyamon.util.abbrev\".custom.docker_cmd(\"" .. w .. "\")')", true, true)
10end
diff --git a/neovim/.config/nvim/lua/dyamon/util/abbrev.lua b/neovim/.config/nvim/lua/dyamon/util/abbrev.lua
new file mode 100644
index 0000000..4e102c7
--- /dev/null
+++ b/neovim/.config/nvim/lua/dyamon/util/abbrev.lua
@@ -0,0 +1,31 @@
1--- Personal lua config files for NeoVim.
2-- Last Changed: 2023-01-10
3-- Author: Federico Igne <git@federicoigne.com>
4-- License: This file is placed in the public domain.
5
6--- A collection of helper functions to manipulate mappings
7local m = { custom = { } }
8
9function m.i(from, to, buffer, expr)
10 local command = 'iabbrev '
11 if buffer then
12 command = command .. '<buffer> '
13 end
14 if expr then
15 command = command .. '<expr> '
16 end
17 vim.cmd(command .. from .. ' ' .. to)
18end
19
20function m.capitalize(word, buffer)
21 m.i(word, word:upper(), buffer)
22end
23
24function m.custom.docker_cmd(w)
25 if vim.api.nvim_win_get_cursor(0)[2] > w:len() then
26 return w
27 end
28 return w:upper()
29end
30
31return m