Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package neocmakelsp for openSUSE:Factory 
checked in at 2025-06-20 16:49:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/neocmakelsp (Old)
 and      /work/SRC/openSUSE:Factory/.neocmakelsp.new.31170 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "neocmakelsp"

Fri Jun 20 16:49:32 2025 rev:2 rq:1286867 version:0.8.18

Changes:
--------
--- /work/SRC/openSUSE:Factory/neocmakelsp/neocmakelsp.changes  2025-06-10 
09:08:09.366555295 +0200
+++ /work/SRC/openSUSE:Factory/.neocmakelsp.new.31170/neocmakelsp.changes       
2025-06-20 16:51:07.412513899 +0200
@@ -1,0 +2,15 @@
+Thu Jun 19 08:35:55 UTC 2025 - Soc Virnyl Estela 
<uncomfyhaloma...@opensuse.org>
+
+- Update to version 0.8.18:
+  * chore: bump version
+  * chore: update README
+  * fix: unit test
+  * feat: internal lint support
+  * chore: tidy up
+  * chore: update README
+  * fix: quick_fix not work
+  * feat: add quick_fix (#143)
+  * chore(deps): bump crate-ci/typos from 1.29.4 to 1.29.5 (#144)
+  * chore: remove the async in path_in_project
+
+-------------------------------------------------------------------
@@ -37,0 +53 @@
+

Old:
----
  neocmakelsp-0.8.17.tar.zst

New:
----
  neocmakelsp-0.8.18.tar.zst

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ neocmakelsp.spec ++++++
--- /var/tmp/diff_new_pack.p59s9D/_old  2025-06-20 16:51:10.480640786 +0200
+++ /var/tmp/diff_new_pack.p59s9D/_new  2025-06-20 16:51:10.484640952 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           neocmakelsp
-Version:        0.8.17
+Version:        0.8.18
 Release:        0
 Summary:        CMake LSP implementation based on Tower and Tree-sitter
 URL:            https://github.com/neocmakelsp/neocmakelsp

++++++ _service ++++++
--- /var/tmp/diff_new_pack.p59s9D/_old  2025-06-20 16:51:10.520642441 +0200
+++ /var/tmp/diff_new_pack.p59s9D/_new  2025-06-20 16:51:10.524642606 +0200
@@ -3,7 +3,7 @@
     <param name="src">https://github.com/neocmakelsp/neocmakelsp</param>
     <param name="update">false</param>
     <param name="respect-lockfile">true</param>
-    <param name="revision">v0.8.17</param>
+    <param name="revision">v0.8.18</param>
     <param name="versionrewriteregex">^v?(.*)</param>
     <param name="versionrewritepattern">$1</param>
     <param name="changesgenerate">true</param>

++++++ neocmakelsp-0.8.17.tar.zst -> neocmakelsp-0.8.18.tar.zst ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/.neocmakelint.toml 
new/neocmakelsp-0.8.18/.neocmakelint.toml
--- old/neocmakelsp-0.8.17/.neocmakelint.toml   1970-01-01 01:00:00.000000000 
+0100
+++ new/neocmakelsp-0.8.18/.neocmakelint.toml   1970-01-01 01:00:00.000000000 
+0100
@@ -1,2 +1,3 @@
 command_upcase = "ignore" # "lowcase", "upcase"
-enable_external_cmake_lint = true # true to use external cmake-lint
+enable_external_cmake_lint = false # true to use external cmake-lint
+line_max_words = 80 # internal lint just supports longest check
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/Cargo.lock 
new/neocmakelsp-0.8.18/Cargo.lock
--- old/neocmakelsp-0.8.17/Cargo.lock   1970-01-01 01:00:00.000000000 +0100
+++ new/neocmakelsp-0.8.18/Cargo.lock   1970-01-01 01:00:00.000000000 +0100
@@ -790,7 +790,7 @@
 
 [[package]]
 name = "neocmakelsp"
-version = "0.8.17"
+version = "0.8.18"
 dependencies = [
  "anstyle",
  "anyhow",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/Cargo.toml 
new/neocmakelsp-0.8.18/Cargo.toml
--- old/neocmakelsp-0.8.17/Cargo.toml   1970-01-01 01:00:00.000000000 +0100
+++ new/neocmakelsp-0.8.18/Cargo.toml   1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +1,6 @@
 [package]
 name = "neocmakelsp"
-version = "0.8.17"
+version = "0.8.18"
 edition = "2021"
 license = "MIT"
 description = "The Lsp for cmake"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/README.md 
new/neocmakelsp-0.8.18/README.md
--- old/neocmakelsp-0.8.17/README.md    1970-01-01 01:00:00.000000000 +0100
+++ new/neocmakelsp-0.8.18/README.md    1970-01-01 01:00:00.000000000 +0100
@@ -22,11 +22,10 @@
    - [Neovim Configuration](#neovim)
    - [Helix Configuration](#helix)
    - [Emacs Configuration](#emacs)
-5. [Features](#features)
-6. [User Feedback](#user-feedback)
+5. [User Feedback](#user-feedback)
    - [macOS Users](#user-feedback)
    - [Windows Users](#user-feedback)
-7. [Visual Examples](#visual-examples)
+6. [Visual Examples](#visual-examples)
 
 
 
@@ -149,6 +148,7 @@
 -   symbol_provider
 -   On hover
 -   Format
+-   CodeAction
 -   document_link
 -   GO TO Definitation
     -   find_package
@@ -169,7 +169,7 @@
 
 ### `cmake-lint` integration
 
-When 
[`cmake-lint`](https://cmake-format.readthedocs.io/en/latest/cmake-lint.html) 
is installed, `neocmakelsp` will utilize it to offer linting and code analysis 
each time the file is saved. This functionality can be enabled or disabled in 
the `.neocmakelint.toml` file:
+When 
[`cmake-lint`](https://cmake-format.readthedocs.io/en/latest/cmake-lint.html) 
is installed, `neocmakelsp` can utilize it to offer linting and code analysis 
each time the file is saved. This functionality can be enabled or disabled in 
the `.neocmakelint.toml` file:
 
 ```toml
 enable_external_cmake_lint = true # true to use external cmake-lint, or false 
to disable it
@@ -177,6 +177,14 @@
 
 If `enable_external_cmake_lint` is turned on but `cmake-lint` is not 
installed, external linting will not report any error message.
 
+### internal lint
+
+cmake-lint now is disabled by default from 0.8.18. And from 0.8.18, 
neocmakelsp itself starts to support similar lint functions like cmake-lint.
+
+```toml
+line_max_words = 80 # this define the max words in a line
+```
+
 ### If you want to use watchfile in Neovim, set
 
 ```lua
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/meson.build 
new/neocmakelsp-0.8.18/meson.build
--- old/neocmakelsp-0.8.17/meson.build  1970-01-01 01:00:00.000000000 +0100
+++ new/neocmakelsp-0.8.18/meson.build  1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +1,4 @@
-project('neocmakelsp', 'rust', version: '0.8.2', meson_version: '>= 1.1.0')
+project('neocmakelsp', 'rust', version: '0.8.18', meson_version: '>= 1.1.0')
 
 find_program('cargo', version: '>= 1.80')
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/src/ast.rs 
new/neocmakelsp-0.8.18/src/ast.rs
--- old/neocmakelsp-0.8.17/src/ast.rs   1970-01-01 01:00:00.000000000 +0100
+++ new/neocmakelsp-0.8.18/src/ast.rs   1970-01-01 01:00:00.000000000 +0100
@@ -13,6 +13,7 @@
     "target_link_libraries",
     "target_include_directories",
 ];
+
 pub async fn getast(client: &Client, context: &str) -> 
Option<DocumentSymbolResponse> {
     let line = context.lines().count();
     if line > 10000 {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/src/complete.rs 
new/neocmakelsp-0.8.18/src/complete.rs
--- old/neocmakelsp-0.8.17/src/complete.rs      1970-01-01 01:00:00.000000000 
+0100
+++ new/neocmakelsp-0.8.18/src/complete.rs      1970-01-01 01:00:00.000000000 
+0100
@@ -409,7 +409,7 @@
                     let child = child.child(2).unwrap();
                     let mut advancedwalk = child.walk();
                     for identifier in child.children(&mut advancedwalk) {
-                        if identifier.kind() == "argument"
+                        if identifier.kind() == CMakeNodeKinds::ARGUMENT
                             && identifier.start_position().row == 
identifier.end_position().row
                         {
                             let startx = identifier.start_position().column;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/src/config.rs 
new/neocmakelsp-0.8.18/src/config.rs
--- old/neocmakelsp-0.8.17/src/config.rs        1970-01-01 01:00:00.000000000 
+0100
+++ new/neocmakelsp-0.8.18/src/config.rs        1970-01-01 01:00:00.000000000 
+0100
@@ -7,6 +7,7 @@
 pub struct CMakeLintConfig {
     pub command_upcase: String,
     pub enable_external_cmake_lint: bool,
+    pub line_max_words: usize,
 }
 
 pub struct LintSuggestion {
@@ -52,7 +53,8 @@
     fn default() -> Self {
         Self {
             command_upcase: "ignore".to_string(),
-            enable_external_cmake_lint: true,
+            enable_external_cmake_lint: false,
+            line_max_words: 80,
         }
     }
 }
@@ -85,6 +87,7 @@
     #[test]
     fn tst_lint_config() {
         assert_eq!((*CMAKE_LINT_CONFIG).command_upcase, "ignore");
-        assert_eq!((*CMAKE_LINT_CONFIG).enable_external_cmake_lint, true);
+        assert_eq!((*CMAKE_LINT_CONFIG).enable_external_cmake_lint, false);
+        assert_eq!((*CMAKE_LINT_CONFIG).line_max_words, 80);
     }
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/src/gammar.rs 
new/neocmakelsp-0.8.18/src/gammar.rs
--- old/neocmakelsp-0.8.17/src/gammar.rs        1970-01-01 01:00:00.000000000 
+0100
+++ new/neocmakelsp-0.8.18/src/gammar.rs        1970-01-01 01:00:00.000000000 
+0100
@@ -1,6 +1,7 @@
 use std::ops::Deref;
 use std::path::Path;
 use std::process::Command;
+use std::sync::LazyLock;
 
 use tower_lsp::lsp_types::DiagnosticSeverity;
 use tree_sitter::Point;
@@ -47,20 +48,16 @@
         use_extra_cmake_lint,
     }: LintConfigInfo,
 ) -> Option<ErrorInfo> {
-    let cmake_lint_info = if use_lint && use_extra_cmake_lint {
-        run_cmake_lint(local_path)
+    let newsource = source.lines().collect();
+    let cmake_lint_info = if use_lint {
+        run_cmake_lint(local_path, use_extra_cmake_lint, &newsource)
     } else {
         None
     };
     let mut parse = tree_sitter::Parser::new();
     parse.set_language(&TREESITTER_CMAKE_LANGUAGE).unwrap();
     let thetree = parse.parse(source, None)?;
-    let mut result = checkerror_inner(
-        local_path,
-        &source.lines().collect(),
-        thetree.root_node(),
-        use_lint,
-    );
+    let mut result = checkerror_inner(local_path, &newsource, 
thetree.root_node(), use_lint);
     if let Some(v) = cmake_lint_info {
         let error_info = result.get_or_insert(ErrorInfo { inner: vec![] });
         for item in v.inner {
@@ -74,20 +71,59 @@
 const RE_MATCH_LINT_RESULT: &str =
     r#"(?P<line>\d+)(,(?P<column>\d+))?: 
(?P<message>\[(?P<severity>[A-Z])\d+\]\s+.*)"#;
 
-fn run_cmake_lint<P: AsRef<Path>>(path: P) -> Option<ErrorInfo> {
+static LINT_REGEX: LazyLock<regex::Regex> =
+    LazyLock::new(|| regex::Regex::new(RE_MATCH_LINT_RESULT).unwrap());
+
+fn run_cmake_lint<P: AsRef<Path>>(
+    path: P,
+    use_extra_cmake_lint: bool,
+    contexts: &Vec<&str>,
+) -> Option<ErrorInfo> {
+    if use_extra_cmake_lint {
+        return run_extra_lint(path);
+    }
+    let mut info = vec![];
+    let max_len = CMAKE_LINT_CONFIG.line_max_words;
+    for (index, line) in contexts.iter().enumerate() {
+        let len = line.len();
+        if len > max_len {
+            let start_point = Point {
+                row: index,
+                column: 0,
+            };
+            let end_point = Point {
+                row: index,
+                column: 0,
+            };
+            let message = format!("[C0301] Line too long ({}/{})", len, 
max_len);
+            info.push(ErrorInformation {
+                start_point,
+                end_point,
+                message,
+                severity: Some(DiagnosticSeverity::WARNING),
+            });
+        }
+    }
+    if info.is_empty() {
+        None
+    } else {
+        Some(ErrorInfo { inner: info })
+    }
+}
+
+fn run_extra_lint<P: AsRef<Path>>(path: P) -> Option<ErrorInfo> {
     let path = path.as_ref();
-    if !path.exists() || !CMAKE_LINT_CONFIG.enable_external_cmake_lint {
+    if !path.exists() {
         return None;
     }
 
     let output = Command::new("cmake-lint").arg(path).output().ok()?;
     let output_str = String::from_utf8_lossy(&output.stdout);
 
-    let re = regex::Regex::new(RE_MATCH_LINT_RESULT).unwrap();
     let mut info = vec![];
 
     for input in output_str.lines() {
-        if let Some(m) = re.captures(input) {
+        if let Some(m) = LINT_REGEX.captures(input) {
             let severity = match m.name("severity").unwrap().as_str() {
                 "E" => DiagnosticSeverity::ERROR,
                 "W" => DiagnosticSeverity::WARNING,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/src/languageserver/test.rs 
new/neocmakelsp-0.8.18/src/languageserver/test.rs
--- old/neocmakelsp-0.8.17/src/languageserver/test.rs   1970-01-01 
01:00:00.000000000 +0100
+++ new/neocmakelsp-0.8.18/src/languageserver/test.rs   1970-01-01 
01:00:00.000000000 +0100
@@ -99,21 +99,13 @@
     let backend = service.inner();
     #[cfg(unix)]
     {
-        assert!(backend.path_in_project(Path::new("/tmp/helloworld/")).await);
-        assert!(
-            !backend
-                .path_in_project(Path::new("/home/helloworld/"))
-                .await
-        );
+        assert!(backend.path_in_project(Path::new("/tmp/helloworld/")));
+        assert!(!backend.path_in_project(Path::new("/home/helloworld/")));
     }
     #[cfg(not(unix))]
     {
-        assert!(
-            backend
-                .path_in_project(Path::new(r"C:\\Windows\\System\\FolderA"))
-                .await
-        );
-        assert!(!backend.path_in_project(Path::new(r"C:\\Windows")).await);
+        
assert!(backend.path_in_project(Path::new(r"C:\\Windows\\System\\FolderA")));
+        assert!(!backend.path_in_project(Path::new(r"C:\\Windows")));
     }
 
     let test_url = Url::from_file_path(root_cmake.clone()).unwrap();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/src/languageserver.rs 
new/neocmakelsp-0.8.18/src/languageserver.rs
--- old/neocmakelsp-0.8.17/src/languageserver.rs        1970-01-01 
01:00:00.000000000 +0100
+++ new/neocmakelsp-0.8.18/src/languageserver.rs        1970-01-01 
01:00:00.000000000 +0100
@@ -13,15 +13,17 @@
 
 use self::config::Config;
 use super::Backend;
+use crate::config::CMAKE_LINT_CONFIG;
 use crate::consts::TREESITTER_CMAKE_LANGUAGE;
 use crate::fileapi::DEFAULT_QUERY;
 use crate::formatting::getformat;
 use crate::gammar::{checkerror, ErrorInformation, LintConfigInfo};
 use crate::semantic_token::LEGEND_TYPE;
+use crate::utils::treehelper::ToPosition;
 use crate::utils::{did_vcpkg_project, treehelper, DocumentNormalize, 
VCPKG_LIBS, VCPKG_PREFIX};
 use crate::{
-    ast, complete, document_link, fileapi, filewatcher, hover, jump, scansubs, 
semantic_token,
-    utils, BackendInitInfo,
+    ast, complete, document_link, fileapi, filewatcher, hover, jump, 
quick_fix, scansubs,
+    semantic_token, utils, BackendInitInfo,
 };
 
 pub static BUFFERS_CACHE: LazyLock<Arc<Mutex<HashMap<lsp_types::Url, 
String>>>> =
@@ -61,7 +63,7 @@
             .expect("Should have been inited before")
     }
 
-    async fn path_in_project<P: AsRef<Path>>(&self, path: P) -> bool {
+    fn path_in_project<P: AsRef<Path>>(&self, path: P) -> bool {
         let Some(root_path) = self.root_path() else {
             return true;
         };
@@ -86,7 +88,7 @@
             return;
         };
 
-        if !self.path_in_project(&file_path).await {
+        if !self.path_in_project(&file_path) {
             return;
         }
 
@@ -100,10 +102,8 @@
                 severity,
             } in diagnoses.inner
             {
-                let pointx =
-                    lsp_types::Position::new(start_point.row as u32, 
start_point.column as u32);
-                let pointy =
-                    lsp_types::Position::new(end_point.row as u32, 
end_point.column as u32);
+                let pointx = start_point.to_position();
+                let pointy = end_point.to_position();
                 let range = Range {
                     start: pointx,
                     end: pointy,
@@ -236,6 +236,7 @@
                 version: Some(version),
             }),
             capabilities: ServerCapabilities {
+                code_action_provider: 
Some(CodeActionProviderCapability::Simple(true)),
                 text_document_sync: Some(TextDocumentSyncCapability::Options(
                     TextDocumentSyncOptions {
                         open_close: Some(true),
@@ -341,8 +342,7 @@
         self.client
             .log_message(MessageType::INFO, "initialized!")
             .await;
-        let root_path_lock = self.root_path();
-        let root_path = root_path_lock;
+
         let work_done_token = ProgressToken::Number(1);
         let progress = self
             .client
@@ -352,7 +352,7 @@
             .begin()
             .await;
 
-        if let Some(ref project_root) = root_path {
+        if let Some(ref project_root) = self.root_path() {
             progress
                 .report_with_message(&format!("start scanning {}", 
project_root.display()), 10)
                 .await;
@@ -514,6 +514,27 @@
             .await;
     }
 
+    async fn code_action(&self, params: CodeActionParams) -> 
Result<Option<CodeActionResponse>> {
+        let Some(toolong) = params
+            .context
+            .diagnostics
+            .iter()
+            .find(|dia| dia.message.starts_with("[C0301]"))
+        else {
+            return Ok(None);
+        };
+
+        let uri = params.text_document.uri;
+        let storemap = BUFFERS_CACHE.lock().await;
+
+        let Some(context) = storemap.get(&uri) else {
+            return Ok(None);
+        };
+
+        let line = params.range.start.line;
+        Ok(quick_fix::lint_fix_action(context, line, toolong, uri))
+    }
+
     async fn did_change(&self, input: DidChangeTextDocumentParams) {
         // create a parse
         let uri = input.text_document.uri.clone();
@@ -566,7 +587,7 @@
             context.to_string(),
             LintConfigInfo {
                 use_lint: self.init_info().enable_lint,
-                use_extra_cmake_lint: true,
+                use_extra_cmake_lint: 
CMAKE_LINT_CONFIG.enable_external_cmake_lint,
             },
         )
         .await;
@@ -664,6 +685,7 @@
             None => Ok(None),
         }
     }
+
     async fn references(&self, input: ReferenceParams) -> 
Result<Option<Vec<Location>>> {
         let uri = input.text_document_position.text_document.uri;
         let location = input.text_document_position.position;
@@ -672,8 +694,6 @@
             return Ok(None);
         };
         drop(storemap);
-        let mut parse = Parser::new();
-        parse.set_language(&TREESITTER_CMAKE_LANGUAGE).unwrap();
         let file_path = match uri.to_file_path() {
             Ok(file_path) => file_path,
             Err(_) => {
@@ -683,6 +703,7 @@
         };
         Ok(jump::godef(location, context.as_str(), &file_path, &self.client, 
false).await)
     }
+
     async fn goto_definition(
         &self,
         input: GotoDefinitionParams,
@@ -739,6 +760,7 @@
             None => Ok(None),
         }
     }
+
     async fn semantic_tokens_full(
         &self,
         params: SemanticTokensParams,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/src/main.rs 
new/neocmakelsp-0.8.18/src/main.rs
--- old/neocmakelsp-0.8.17/src/main.rs  1970-01-01 01:00:00.000000000 +0100
+++ new/neocmakelsp-0.8.18/src/main.rs  1970-01-01 01:00:00.000000000 +0100
@@ -22,6 +22,7 @@
 mod hover;
 mod jump;
 mod languageserver;
+mod quick_fix;
 mod scansubs;
 mod search;
 mod semantic_token;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/neocmakelsp-0.8.17/src/quick_fix.rs 
new/neocmakelsp-0.8.18/src/quick_fix.rs
--- old/neocmakelsp-0.8.17/src/quick_fix.rs     1970-01-01 01:00:00.000000000 
+0100
+++ new/neocmakelsp-0.8.18/src/quick_fix.rs     1970-01-01 01:00:00.000000000 
+0100
@@ -0,0 +1,124 @@
+use std::sync::LazyLock;
+
+use regex::Regex;
+use tower_lsp::lsp_types::{
+    CodeAction, CodeActionKind, CodeActionOrCommand, CodeActionResponse, 
Diagnostic,
+    DocumentChanges, OneOf, OptionalVersionedTextDocumentIdentifier, Range, 
TextDocumentEdit,
+    TextEdit, WorkspaceEdit,
+};
+
+use crate::CMakeNodeKinds;
+use crate::{consts::TREESITTER_CMAKE_LANGUAGE, utils::treehelper::ToPosition};
+
+static LINT_REGEX: LazyLock<Regex> =
+    LazyLock::new(|| Regex::new(r#"((?<length>\d+)/(?<max>\d+))"#).unwrap());
+
+#[test]
+fn lint_regex_text() {
+    let information = "[C0301] Line too long (92/80)";
+    let caps = LINT_REGEX.captures(&information).unwrap();
+    assert_eq!(&caps["length"], "92");
+    assert_eq!(&caps["max"], "80");
+}
+
+pub fn lint_fix_action(
+    context: &str,
+    line: u32,
+    diagnose: &Diagnostic,
+    uri: tower_lsp::lsp_types::Url,
+) -> Option<CodeActionResponse> {
+    let caps = LINT_REGEX.captures(&diagnose.message)?;
+    let longest = caps["max"].parse().unwrap();
+    let mut parse = tree_sitter::Parser::new();
+    parse.set_language(&TREESITTER_CMAKE_LANGUAGE).unwrap();
+    let tree = parse.parse(context, None)?;
+    let root = tree.root_node();
+    sub_lint_fix_action(
+        root,
+        &context.lines().collect(),
+        line as usize,
+        diagnose,
+        longest,
+        &uri,
+    )
+}
+
+fn sub_lint_fix_action(
+    input: tree_sitter::Node,
+    source: &Vec<&str>,
+    line: usize,
+    diagnose: &Diagnostic,
+    longest: usize,
+    uri: &tower_lsp::lsp_types::Url,
+) -> Option<CodeActionResponse> {
+    let mut cursor = input.walk();
+    for child in input.children(&mut cursor) {
+        if child.end_position().row < line {
+            continue;
+        }
+        if child.start_position().row > line {
+            break;
+        }
+        match child.kind() {
+            CMakeNodeKinds::ARGUMENT_LIST => {
+                let start = child.start_position().to_position();
+                let end = child.end_position().to_position();
+                let range = Range { start, end };
+                let mut arg_cursor = child.walk();
+                let mut start_row = start.character as usize;
+                let start = start.character as usize;
+                let start_space: String = vec![' '; start].iter().collect();
+                let mut new_text = "".to_string();
+                for arg in child.children(&mut arg_cursor) {
+                    let current_row = arg.start_position().row;
+                    // I mean I cannot fix this problem
+                    if current_row != arg.end_position().row {
+                        return None;
+                    }
+                    let start_col = arg.start_position().column;
+                    let end_col = arg.end_position().column;
+                    let len = arg.end_position().column - 
arg.start_position().column;
+                    let arg = &source[current_row][start_col..end_col];
+                    if start_row + len + 1 > longest {
+                        start_row = 0;
+                        new_text.push('\n');
+                        new_text.push_str(&start_space);
+                    } else {
+                        start_row += len + 1;
+                        if !new_text.is_empty() {
+                            new_text.push(' ');
+                        }
+                    }
+                    new_text.push_str(arg);
+                }
+                return Some(vec![CodeActionOrCommand::CodeAction(CodeAction {
+                    title: "too long lint fix".to_string(),
+                    kind: Some(CodeActionKind::QUICKFIX),
+                    diagnostics: Some(vec![diagnose.clone()]),
+                    edit: Some(WorkspaceEdit {
+                        changes: None,
+                        change_annotations: None,
+                        document_changes: 
Some(DocumentChanges::Edits(vec![TextDocumentEdit {
+                            text_document: 
OptionalVersionedTextDocumentIdentifier {
+                                uri: uri.clone(),
+                                version: None,
+                            },
+                            edits: vec![OneOf::Left(TextEdit { range, new_text 
})],
+                        }])),
+                    }),
+                    command: None,
+                    is_preferred: None,
+                    disabled: None,
+                    data: None,
+                })]);
+            }
+            _ => {
+                let try_data = sub_lint_fix_action(child, source, line, 
diagnose, longest, uri);
+                if try_data.is_some() {
+                    return try_data;
+                }
+            }
+        }
+    }
+    None
+}

++++++ vendor.tar.zst ++++++
/work/SRC/openSUSE:Factory/neocmakelsp/vendor.tar.zst 
/work/SRC/openSUSE:Factory/.neocmakelsp.new.31170/vendor.tar.zst differ: char 
3898, line 15

Reply via email to