Got cfn working nicely
This commit is contained in:
parent
bbc67edf62
commit
6cbbc7bce7
|
@ -0,0 +1,18 @@
|
||||||
|
vim.filetype.add {
|
||||||
|
pattern = {
|
||||||
|
['.*'] = {
|
||||||
|
priority = math.huge,
|
||||||
|
function(path, bufnr)
|
||||||
|
local line1 = vim.filetype.getlines(bufnr, 1)
|
||||||
|
local line2 = vim.filetype.getlines(bufnr, 2)
|
||||||
|
if vim.filetype.matchregex(line1, [[^AWSTemplateFormatVersion]] ) or
|
||||||
|
vim.filetype.matchregex(line2, [[^AWSTemplateFormatVersion]] ) then
|
||||||
|
return 'yaml.cloudformation'
|
||||||
|
elseif vim.filetype.matchregex(line1, [[["']AWSTemplateFormatVersion]] ) or
|
||||||
|
vim.filetype.matchregex(line2, [[["']AWSTemplateFormatVersion]] ) then
|
||||||
|
return 'json.cloudformation'
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
85
init.lua
85
init.lua
|
@ -172,6 +172,9 @@ require('lazy').setup({
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'b0o/schemastore',
|
||||||
|
'mfussenegger/nvim-lint',
|
||||||
|
|
||||||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
||||||
-- These are some example plugins that I've included in the kickstart repository.
|
-- These are some example plugins that I've included in the kickstart repository.
|
||||||
-- Uncomment any of the lines below to enable them.
|
-- Uncomment any of the lines below to enable them.
|
||||||
|
@ -288,7 +291,7 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
|
||||||
-- See `:help nvim-treesitter`
|
-- See `:help nvim-treesitter`
|
||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim' },
|
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' },
|
||||||
|
|
||||||
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
||||||
auto_install = false,
|
auto_install = false,
|
||||||
|
@ -416,6 +419,7 @@ local servers = {
|
||||||
tflint = {},
|
tflint = {},
|
||||||
terraformls = {},
|
terraformls = {},
|
||||||
eslint = {},
|
eslint = {},
|
||||||
|
--yamlls = {},
|
||||||
|
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
Lua = {
|
Lua = {
|
||||||
|
@ -452,6 +456,59 @@ mason_lspconfig.setup_handlers {
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require'lspconfig'.yamlls.setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
filetypes = { "yaml", "yaml.cloudformation" },
|
||||||
|
flags = { debounce_test_changes = 150 },
|
||||||
|
capabilities = capabilities,
|
||||||
|
settings = {
|
||||||
|
yaml = {
|
||||||
|
format = {
|
||||||
|
enable = true,
|
||||||
|
singleQuote = true,
|
||||||
|
printWidth = 120,
|
||||||
|
},
|
||||||
|
hover = true,
|
||||||
|
completion = true,
|
||||||
|
customTags = {
|
||||||
|
"!fn",
|
||||||
|
"!And",
|
||||||
|
"!If",
|
||||||
|
"!Not",
|
||||||
|
"!Equals",
|
||||||
|
"!Or",
|
||||||
|
"!FindInMap sequence",
|
||||||
|
"!Base64",
|
||||||
|
"!Cidr",
|
||||||
|
"!Ref",
|
||||||
|
"!Ref scalar",
|
||||||
|
"!Sub",
|
||||||
|
"!GetAtt",
|
||||||
|
"!GetAZs",
|
||||||
|
"!ImportValue",
|
||||||
|
"!Select",
|
||||||
|
"!Split",
|
||||||
|
"!Join sequence"
|
||||||
|
},
|
||||||
|
validate = true,
|
||||||
|
schemas = {
|
||||||
|
["https://raw.githubusercontent.com/awslabs/goformation/v6.10.0/schema/cloudformation.schema.json"] = {
|
||||||
|
"/cloudformation.yml",
|
||||||
|
"/cloudformation.yaml",
|
||||||
|
"/cloudformation.template.yml",
|
||||||
|
"/cloudformation.template.yaml",
|
||||||
|
"/*.cf.yml",
|
||||||
|
"/cf.yaml",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
schemaStore = {
|
||||||
|
enable = true,
|
||||||
|
url = "https://www.schemastore.org/json",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
-- nvim-cmp setup
|
-- nvim-cmp setup
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
|
@ -497,6 +554,32 @@ cmp.setup {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupLinter = function (name)
|
||||||
|
--require('lint').try_lint(name)
|
||||||
|
local lintcmd = "lua require('lint').try_lint('" .. name .. "')"
|
||||||
|
vim.cmd(lintcmd)
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||||
|
--command = "silent! lua require('lint').try_lint(" .. name .. ")",
|
||||||
|
command = lintcmd,
|
||||||
|
desc = "Adding linter " .. name
|
||||||
|
})
|
||||||
|
end
|
||||||
|
-- setup linting for Cloudformation cfn_lint
|
||||||
|
vim.api.nvim_create_autocmd({'BufReadPost'}, {
|
||||||
|
pattern = {
|
||||||
|
'*.cf.json',
|
||||||
|
'*.cf.yml',
|
||||||
|
'*.cf.yaml',
|
||||||
|
'cloudformation.template.yml',
|
||||||
|
'cloudformation.template.yaml',
|
||||||
|
'cloudformation.json',
|
||||||
|
'cloudformation.yaml',
|
||||||
|
'cloudformation.yml'
|
||||||
|
},
|
||||||
|
command = "lua setupLinter('cfn_lint')",
|
||||||
|
desc = 'Adding linting command for Cloudformation files with cfn_lint'
|
||||||
|
})
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue