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
- Host: GitHub
- URL: https://github.com/patwie/include-guard.nvim
- Owner: PatWie
- Created: 2023-01-27T12:01:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-31T12:54:12.000Z (over 2 years ago)
- Last Synced: 2025-02-10T02:25:04.366Z (8 months ago)
- Language: Lua
- Size: 2.93 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
endreturn {
-- 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),
}),
}
```