An open API service indexing awesome lists of open source software.

https://github.com/patwie/include-guard.nvim

Add cpplint include guard to header files in neovim
https://github.com/patwie/include-guard.nvim

Last synced: 6 months ago
JSON representation

Add cpplint include guard to header files in neovim

Awesome Lists containing this project

README

          

# Neovim Include Guard (cpplint)

Adds header guard for the current file using the include header guard generated by cpplint.

With packer

```lua
use("patwie/include-guard.nvim")
```

Setup is

```lua
include_guard = require("include-guard")
include_guard.setup({ copyright_holder = "your_name", add_copyright = true })

-- Example short cut ("w" as wrap)
r.nnoremap("ww", require("include-guard").AddIncludeGuardAndCopyright)
r.nnoremap("wg", require("include-guard").AddIncludeGuard)
r.nnoremap("wc", require("include-guard").UpdateCopyright)

```

## LuaSnip suppport

The functions can be used in LuaSnip as well:

```lua
local present, include_guard = pcall(require, "include-guard")

if not present then
return
end

return {
-- Inserts the copyright string without leading comment.
s("cori", { f(function()
return include_guard.GetCopyrightString()
end) }),
-- Inserts the include guard for C++ header files.
s("inclg", {
f(function()
local s = include_guard.GetIncludeGuardString()
return { "#ifndef " .. s, "#define " .. s, "", "" }
end),
i(1, ""),
t("", ""),
f(function()
local s = include_guard.GetIncludeGuardString()
return { "", "", "#endif // " .. s }
end),
}),
}
```