Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ clang_format_path = "/usr/bin/clang-format" # clang-format binary to execute in

The `[config]` section contains stable settings that should generally remain unchanged.

- `include_paths`: Directories to search for `.proto` files.
- `include_paths`: Directories to search for `.proto` files. Absolute or relative to git root. If git root is unavailble, LSP's workspace is used.
- `disable_parse_diagnostics`: Set to `true` to disable diagnostics during parsing.

#### Experimental Configuration
Expand Down
6 changes: 4 additions & 2 deletions src/config/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,18 @@ impl WorkspaceProtoConfigs {
}

pub fn get_include_paths(&self, uri: &Url) -> Option<Vec<PathBuf>> {
let c = self.get_config_for_uri(uri)?;
let cfg = self.get_config_for_uri(uri)?;
let w = self.get_workspace_for_uri(uri)?.to_file_path().ok()?;
let mut ipath: Vec<PathBuf> = c

let mut ipath: Vec<PathBuf> = cfg
.config
.include_paths
.iter()
.map(PathBuf::from)
.map(|p| if p.is_relative() { w.join(p) } else { p })
.collect();

tracing::info!(?ipath, "getting include paths");
ipath.push(w.to_path_buf());
ipath.extend_from_slice(&self.protoc_include_prefix);
Some(ipath)
Expand Down
2 changes: 1 addition & 1 deletion src/context/jumpable.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub enum Jumpable {
Import(String),
Identifier(String)
Identifier(String),
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use tower::ServiceBuilder;
use tracing::Level;

mod config;
mod context;
mod formatter;
mod lsp;
mod nodekind;
Expand All @@ -18,7 +19,6 @@ mod server;
mod state;
mod utils;
mod workspace;
mod context;

#[tokio::main(flavor = "current_thread")]
async fn main() {
Expand Down
9 changes: 8 additions & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,19 @@ impl ProtoLanguageState {

// After content is upserted, those imports which couldn't be located
// are flagged as import error
tracing::info!(?ipath, "import path");
self.get_tree(uri)
.map(|t| t.get_import_paths(content.as_ref()))
.unwrap_or_default()
.into_iter()
.map(ToOwned::to_owned)
.filter(|import| !ipath.iter().any(|p| p.join(import.as_str()).exists()))
.filter(|import| {
tracing::info!(
%import,
"trying import",
);
!ipath.iter().any(|p| p.join(import.as_str()).exists())
})
.collect()
}

Expand Down
2 changes: 0 additions & 2 deletions src/workspace/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,6 @@ Included from {}"#,

#[cfg(test)]
mod test {
use std::path::PathBuf;

use insta::assert_yaml_snapshot;

use crate::context::hoverable::Hoverables;
Expand Down