This commit is contained in:
parent
7e5d880156
commit
d93f63cf82
40 changed files with 448 additions and 649 deletions
36
.config/nvim/lua/config/filetypes.lua
Normal file
36
.config/nvim/lua/config/filetypes.lua
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
local function has_ansible_root(path, recursive)
|
||||
if not recursive then
|
||||
return vim.uv.fs_stat(
|
||||
vim.fs.joinpath(vim.fs.dirname(path), 'ansible.cfg')
|
||||
)
|
||||
end
|
||||
|
||||
return vim.fs.find('ansible.cfg', {
|
||||
path = vim.fs.dirname(path),
|
||||
upward = true,
|
||||
limit = 1
|
||||
})[1]
|
||||
end
|
||||
|
||||
local function yaml_filetype(recursive, p2)
|
||||
return function (path)
|
||||
print(p2)
|
||||
if has_ansible_root(path, recursive) then
|
||||
return "yaml.ansible"
|
||||
else
|
||||
return "yaml"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
['yaml'] = yaml_filetype(false),
|
||||
['yml'] = yaml_filetype(false),
|
||||
},
|
||||
pattern = {
|
||||
[".*/roles/.*/tasks/.*%.ya?ml"] = yaml_filetype(true),
|
||||
[".*/roles/.*/handlers/.*%.ya?ml"] = yaml_filetype(true),
|
||||
[".*/playbooks/.*%.ya?ml"] = yaml_filetype(true),
|
||||
},
|
||||
})
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
require("config.mappings")
|
||||
require("config.options")
|
||||
require("config.mappings")
|
||||
require("config.autocmd")
|
||||
require("config.filetypes")
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ map({ 'n', 'v' }, 'j', 'v:count == 0 ? "gj" : "j"', { expr = true, silent = true
|
|||
|
||||
-- Copy and paste from clipboard
|
||||
map({ 'n', 'v' }, '<leader>y', '"+y')
|
||||
map({ 'n', 'v' }, '<leader>Y', '"+Y')
|
||||
map({ 'n', 'v' }, '<leader>Y', '"+y$')
|
||||
map({ 'n', 'v' }, '<leader>p', '"+p<ESC>')
|
||||
map({ 'n', 'v' }, '<leader>P', '"+P<ESC>')
|
||||
|
||||
|
|
@ -49,3 +49,8 @@ map('i', '<M-BS>', '<C-w>')
|
|||
-- Move lines quickly
|
||||
map('n', '<C-M-k>', ':m-2<CR>', { silent = true })
|
||||
map('n', '<C-M-j>', ':m+1<CR>', { silent = true })
|
||||
|
||||
map('n', '<Leader>dt', ':diffthis<CR>', { silent = true })
|
||||
map('n', '<Leader>do', ':diffoff<CR>', { silent = true })
|
||||
|
||||
map('n', '<Leader>lr', ':LspR<CR>')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue