Skip to content

Commit

Permalink
Add include directorie action added
Browse files Browse the repository at this point in the history
  • Loading branch information
suzizecat committed Aug 14, 2024
1 parent 6534069 commit 49086d9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Added

- Add support for `include` folders and directives.
- Add support for `include` folders in config files.
- Add support to add user include folder through `diplomat-server.add-incdir`

## Dependencies
- Updated fmtlib from 10.2.1 to 11.0.2
Expand Down
1 change: 1 addition & 0 deletions lsp-server/diplomat/include/diplomat_lsp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class DiplomatLSP : public slsp::BaseLSP
json _h_get_module_bbox(json params);
void _h_set_module_top(json params);
void _h_ignore(json params);
void _h_add_to_include(json params);
void _h_force_clear_index(json params);

json _h_resolve_hier_path(json params);
Expand Down
1 change: 1 addition & 0 deletions lsp-server/diplomat/src/diplomat_lsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ void DiplomatLSP::_bind_methods()
bind_request("diplomat-server.get-module-bbox", LSP_MEMBER_BIND(DiplomatLSP,_h_get_module_bbox));
bind_notification("diplomat-server.full-index", LSP_MEMBER_BIND(DiplomatLSP,_h_force_clear_index));
bind_notification("diplomat-server.ignore", LSP_MEMBER_BIND(DiplomatLSP,_h_ignore));
bind_notification("diplomat-server.add-incdir", LSP_MEMBER_BIND(DiplomatLSP,_h_add_to_include));
//bind_notification("diplomat-server.save-config", LSP_MEMBER_BIND(DiplomatLSP,_h_save_config));
bind_notification("diplomat-server.push-config", LSP_MEMBER_BIND(DiplomatLSP,_h_push_config));
bind_request("diplomat-server.pull-config", LSP_MEMBER_BIND(DiplomatLSP,_h_pull_config));
Expand Down
17 changes: 17 additions & 0 deletions lsp-server/diplomat/src/diplomat_lsp_binds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,23 @@ void DiplomatLSP::_h_ignore(json params)
}
}

/**
* @brief Handle to add an include directory.
* This is intended to be used as a command in VSCode for right click action in the
* filesystem view.
*
* @param params
*/
void DiplomatLSP::_h_add_to_include(json params)
{
for (const json& record : params.at(1))
{
fs::path p = fs::canonical(record["path"].template get<std::string>());
spdlog::info("Add user include path {}", p.generic_string());
_settings.includes.user.push_back(p.generic_string());
}
}

void DiplomatLSP::_h_force_clear_index(json _)
{
_project_file_tree_valid = false;
Expand Down

0 comments on commit 49086d9

Please sign in to comment.