generated from IWANABETHATGUY/tower-lsp-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
186 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-android-arm-eabi", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"android" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-android-arm64", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"android" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-darwin-arm64", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"darwin" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-darwin-universal", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"darwin" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-freebsd-x64", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"freebsd" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-linux-arm64-gnu", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"linux" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-linux-arm64-musl", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"linux" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-linux-riscv64-gnu", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"linux" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-linux-x64-gnu", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"linux" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-linux-x64-musl", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"linux" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-win32-arm64-msvc", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"win32" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-win32-ia32-msvc", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"win32" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@jinja-lsp/functions-win32-x64-msvc", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"os": [ | ||
"win32" | ||
], | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,80 @@ | ||
use std::collections::HashMap; | ||
|
||
use tree_sitter::{Point, Query, QueryCursor, Tree}; | ||
|
||
pub fn _python_identifiers( | ||
pub struct PythonAttributes { | ||
pub attributes: HashMap<Point, Vec<PythonIdentifier>>, | ||
} | ||
|
||
impl PythonAttributes { | ||
pub fn merge(&self, line: u32) -> Vec<PythonIdentifier> { | ||
let mut identifiers = vec![]; | ||
for i in &self.attributes { | ||
let mut start = i.0.to_owned(); | ||
start.row += line as usize; | ||
let mut end = i.0; | ||
let mut name = String::new(); | ||
let len = i.1.len(); | ||
for (index, identifier) in i.1.iter().enumerate() { | ||
name.push_str(&identifier.field); | ||
end = &identifier.end; | ||
if index != len - 1 { | ||
name.push('.'); | ||
} | ||
} | ||
let mut end = end.to_owned(); | ||
end.row += line as usize; | ||
let identifier = PythonIdentifier { | ||
id: 0, | ||
start, | ||
end, | ||
field: name, | ||
}; | ||
identifiers.push(identifier); | ||
} | ||
identifiers | ||
} | ||
} | ||
|
||
#[derive(Default, Debug, Clone, PartialEq, PartialOrd, Ord, Eq)] | ||
pub struct PythonIdentifier { | ||
pub id: usize, | ||
pub start: Point, | ||
pub end: Point, | ||
pub field: String, | ||
} | ||
|
||
pub fn python_identifiers( | ||
query: &Query, | ||
tree: &Tree, | ||
mut _trigger_point: Point, | ||
text: &str, | ||
all: bool, | ||
) { | ||
line: u32, | ||
) -> Vec<PythonIdentifier> { | ||
let closest_node = tree.root_node(); | ||
let mut cursor_qry = QueryCursor::new(); | ||
let _capture_names = query.capture_names(); | ||
let mut attributes = PythonAttributes { | ||
attributes: HashMap::new(), | ||
}; | ||
let matches = cursor_qry.matches(query, closest_node, text.as_bytes()); | ||
let captures = matches.into_iter().flat_map(|m| { | ||
m.captures | ||
.iter() | ||
.filter(|capture| all || capture.node.start_position() <= _trigger_point) | ||
}); | ||
for _capture in captures { | ||
// if check.is_none() { | ||
// break; | ||
// } | ||
for i in matches { | ||
for capture in i.captures { | ||
if let Some(parent) = capture.node.parent() { | ||
let attribute = attributes | ||
.attributes | ||
.entry(parent.start_position()) | ||
.or_default(); | ||
let field = capture.node.utf8_text(text.as_bytes()).unwrap_or_default(); | ||
let identifier = PythonIdentifier { | ||
id: capture.node.id(), | ||
start: capture.node.start_position(), | ||
end: capture.node.end_position(), | ||
field: field.to_string(), | ||
}; | ||
attribute.push(identifier); | ||
} | ||
} | ||
} | ||
attributes.merge(line) | ||
} |
Oops, something went wrong.