Skip to content

Combine multiple included files in the original C file, for clangd to inspect as a whole.

License

Notifications You must be signed in to change notification settings

kesor/clangd-unfurl.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clangd-unfurl.nvim

Unfurl #include directives in C files for enhanced LSP support in Neovim

Introduction

clangd-unfurl.nvim is a Neovim plugin that expands local #include "file.h" directives directly within your C files. This provides the clangd language server with the full context of all included files, improving code analysis and reducing false positives, such as warnings about unused variables.

Features

  • Recursive Unfurling: Recursively expands local includes while preventing circular dependencies.
  • Enhanced LSP Support: Provides clangd with complete code context for better diagnostics.
  • Editable Virtual Buffer: Allows editing included files directly within the unfurled virtual buffer.
  • Change Tracking: Maps changes back to original files, enabling synchronized edits.
  • Visual Boundaries: Highlights the start and end of included files for clarity.

Requirements

  • Neovim 0.5+ with Lua support
  • clangd language server

Installation

Use your preferred Neovim plugin manager.

use {
  'kesor/clangd-unfurl.nvim',
  config = function()
    require('clangd-unfurl').setup()
  end
}

Using vim-plug

Plug 'kesor/clangd-unfurl.nvim'
lua require('clangd-unfurl').setup()

Using lazy.nvim

{
  "kesor/clangd-unfurl.nvim",
  config = function()
    require('clangd-unfurl').setup()
  end
}

Usage

In a C file, run the command:

:UnfurlC

This will open a new split window with the unfurled content.

After editing, save changes back to the original files with:

:UnfurlSave

Navigation

  • Boundary Lines: Boundary lines are highlighted and read-only.
  • Cursor Movement: The cursor will skip over boundary lines automatically.

Limitations

  • External Modifications: Changes to original files after unfurling are not detected.
  • Conditional Includes: Does not handle conditional compilation directives like #ifdef.

Contributing

Contributions are welcome! Please submit issues and pull requests via GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Combine multiple included files in the original C file, for clangd to inspect as a whole.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published