aboutsummaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/lua/dyamon/util/abbrev.lua
blob: 4e102c7c603e4b08decfde4f20fed552f6d00af7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--- Personal lua config files for NeoVim.
--  Last Changed: 2023-01-10
--  Author: Federico Igne <git@federicoigne.com>
--  License: This file is placed in the public domain.

--- A collection of helper functions to manipulate mappings
local m = { custom = { } }

function m.i(from, to, buffer, expr)
    local command = 'iabbrev '
    if buffer then
        command = command .. '<buffer> '
    end
    if expr then
        command = command .. '<expr> '
    end
    vim.cmd(command .. from .. ' ' .. to)
end

function m.capitalize(word, buffer)
    m.i(word, word:upper(), buffer)
end

function m.custom.docker_cmd(w)
    if vim.api.nvim_win_get_cursor(0)[2] > w:len() then
        return w 
    end
    return w:upper()
end

return m