Liking cljdoc? Tell your friends :D

clojure-lsp.api

Entrypoint for main clojure-lsp features

Entrypoint for main clojure-lsp features
raw docstring

analyze-project-and-deps!clj

(analyze-project-and-deps! {:keys [project-root settings] :as options})

Analyze whole project and all external dependencies caching analysis for future API calls. Useful for REPL usage for example.

This will analyze the whole project and external dependencies with clj-kondo caching its analysis for next other API calls. All features need analysis and will call this internally if the project was not analyzed before.

Options All options below are optional, using its default if not provided.

:project-root a java.io.File representing the project root.

settings map of settings following https://clojure-lsp.io/settings/

Example

(clojure-lsp.api/analyze-project-and-deps! {:project-root (io/file ".")
                                            :settings {:classpath-config-paths ["other-company/other-project"]}})
Analyze whole project and all external dependencies
caching analysis for future API calls. Useful for REPL
usage for example.

This will analyze the whole project and external dependencies with
clj-kondo caching its analysis for next other API calls.
All features need analysis and will call this internally if the project
was not analyzed before.

**Options**
All options below are optional, using its default if not provided.

`:project-root` a java.io.File representing the project root.

`settings` map of settings following https://clojure-lsp.io/settings/

**Example**

```clojure
(clojure-lsp.api/analyze-project-and-deps! {:project-root (io/file ".")
                                            :settings {:classpath-config-paths ["other-company/other-project"]}})
```
sourceraw docstring

analyze-project-only!clj

(analyze-project-only! {:keys [project-root settings] :as options})

Analyze whole project only caching analysis for future API calls. Useful for REPL usage for example.

This will analyze the whole project and external dependencies with clj-kondo caching its analysis for next other API calls. All features need analysis and will call this internally if the project was not analyzed before.

Options All options below are optional, using its default if not provided.

:project-root a java.io.File representing the project root.

settings map of settings following https://clojure-lsp.io/settings/

Example

(clojure-lsp.api/analyze-project-only! {:project-root (io/file ".")
                                        :settings {:classpath-config-paths ["other-company/other-project"]}})
Analyze whole project only caching analysis for future API calls. Useful for REPL
usage for example.

This will analyze the whole project and external dependencies with
clj-kondo caching its analysis for next other API calls.
All features need analysis and will call this internally if the project
was not analyzed before.

**Options**
All options below are optional, using its default if not provided.

`:project-root` a java.io.File representing the project root.

`settings` map of settings following https://clojure-lsp.io/settings/

**Example**

```clojure
(clojure-lsp.api/analyze-project-only! {:project-root (io/file ".")
                                        :settings {:classpath-config-paths ["other-company/other-project"]}})
```
sourceraw docstring

clean-ns!clj

(clean-ns! {:keys [project-root settings namespace filenames ns-exclude-regex]
            :as options})

Organize ns form, removing unused requires/refers/imports and sorting alphabetically by default.

Options All options below are optional, using its default if not provided.

:project-root a java.io.File representing the project root.

:namespace a coll of symbols representing the namespaces which should be cleaned, if empty all project namespaces will be considered.

:filenames a coll of files representing the files which should be cleaned.

:ns-exclude-regex a string regex representing the namespaces that should be excluded during this call.

dry? a boolean, when enabled make no side-effects (no changes to files), only report.

settings map of settings following https://clojure-lsp.io/settings/

Example

(clojure-lsp.api/clean-ns! {:namespace '[my-project.foo my-project.bar]})
Organize `ns` form, removing unused requires/refers/imports and sorting
alphabetically by default.

**Options**
All options below are optional, using its default if not provided.

`:project-root` a java.io.File representing the project root.

`:namespace` a coll of symbols representing the namespaces which should be cleaned,
if empty all project namespaces will be considered.

`:filenames` a coll of files representing the files which should be cleaned.

`:ns-exclude-regex` a string regex representing the namespaces that should be excluded during this call.

`dry?` a boolean, when enabled make no side-effects (no changes to files), only report.

`settings` map of settings following https://clojure-lsp.io/settings/

**Example**

```clojure
(clojure-lsp.api/clean-ns! {:namespace '[my-project.foo my-project.bar]})
```
sourceraw docstring

diagnosticsclj

(diagnostics {:keys [project-root namespace filenames settings] :as options})

Find all project diagnostics (warnings, errors and infos). Returns all clj-kondo lint plus custom linters configured by clojure-lsp like clojure-lsp/unused-public-var for example.

Options All options below are optional, using its default if not provided.

:project-root a java.io.File representing the project root.

:namespace a coll of symbols representing the namespaces which should be checked for diagnostics, if empty all project namespaces will be considered.

:filenames a coll of files representing the files which should be checked for diagnostics.

:ns-exclude-regex a string regex representing the namespaces that should be excluded during this call.

:output a map with options on how the result should be printed, available values are: :canonical-paths a boolean if the path should be absolute or not, defaults to false.

settings map of settings following https://clojure-lsp.github.io/clojure-lsp/settings/

Example

(clojure-lsp.api/diagnostics {:namespace '[my-project.foo my-project.bar]
                              :output {:canonical-paths true}})
Find all project diagnostics (warnings, errors and infos).
Returns all clj-kondo lint plus custom linters configured by clojure-lsp like
clojure-lsp/unused-public-var for example.

**Options**
All options below are optional, using its default if not provided.

`:project-root` a java.io.File representing the project root.

`:namespace` a coll of symbols representing the namespaces which should be checked for diagnostics,
if empty all project namespaces will be considered.

`:filenames` a coll of files representing the files which should be checked for diagnostics.

`:ns-exclude-regex` a string regex representing the namespaces that should be excluded during this call.

`:output` a map with options on how the result should be printed, available values are:
  `:canonical-paths` a boolean if the path should be absolute or not, defaults to false.

`settings` map of settings following https://clojure-lsp.github.io/clojure-lsp/settings/

**Example**

```clojure
(clojure-lsp.api/diagnostics {:namespace '[my-project.foo my-project.bar]
                              :output {:canonical-paths true}})
```
sourceraw docstring

dumpclj

(dump {:keys [project-root output settings] :as options})

Dump all project known data including classpath, source-paths, dep-graph and clj-kondo analysis data.

Options

:project-root a java.io.File representing the project root.

:analysis a map with options on how clojure-lsp should analyze the project, available values are: :type keyword values: project-only, project-and-shallow-analysis, project-and-full-dependencies. Default to project-only.

:output a map with options on how the result should be printed, available values are: :format a keyword specifying in which format the data should be returned, defaults to :edn. :filter-keys a list of keywords in case you want only specific fields from output.

settings map of settings following https://clojure-lsp.io/settings/

Output

result-code an integer representing whether the action was successful, 0 means ok, 1 means error

message-fn a function of no arity to be called if want the result as a stringfied version.

:result :project-root a string path representing the project root. :source-paths list of source-paths considered by clojure-lsp. :classpath list of paths of found classpath. :analysis clj-kondo analysis normalized for clojure-lsp usage. :dep-graph Dependency graph of namespaces relationship derived from clj-kondo analysis. :findings clj-kondo findings used for diagnostics. :settings a map with all settings considered by clojure-lsp.

Example

(clojure-lsp.api/dump {:output {:format :edn
                                :filter-keys [:source-paths :analysis]}})
=> {:result {:source-paths [...]
             :analysis {...}}
    :result-code 0}
Dump all project known data including classpath, source-paths, dep-graph
and clj-kondo analysis data.

**Options**

`:project-root` a java.io.File representing the project root.

`:analysis` a map with options on how clojure-lsp should analyze the project, available values are:
  `:type` keyword values: `project-only`, `project-and-shallow-analysis`, `project-and-full-dependencies`. Default to `project-only`.

`:output` a map with options on how the result should be printed, available values are:
  `:format` a keyword specifying in which format the data should be returned, defaults to `:edn`.
  `:filter-keys` a list of keywords in case you want only specific fields from output.

`settings` map of settings following https://clojure-lsp.io/settings/

**Output**

`result-code` an integer representing whether the action was successful, 0 means ok, 1 means error

`message-fn` a function of no arity to be called if want the result as a stringfied version.

`:result`
  `:project-root` a string path representing the project root.
  `:source-paths` list of source-paths considered by clojure-lsp.
  `:classpath` list of paths of found classpath.
  `:analysis` clj-kondo analysis normalized for clojure-lsp usage.
  `:dep-graph` Dependency graph of namespaces relationship derived from clj-kondo analysis.
  `:findings` clj-kondo findings used for diagnostics.
  `:settings` a map with all settings considered by clojure-lsp.

**Example**

```clojure
(clojure-lsp.api/dump {:output {:format :edn
                                :filter-keys [:source-paths :analysis]}})
=> {:result {:source-paths [...]
             :analysis {...}}
    :result-code 0}
```
sourceraw docstring

format!clj

(format! {:keys [project-root settings namespace filenames ns-exclude-regex]
          :as options})

Format one or more namespaces using cljfmt internally.

Options All options below are optional, using its default if not provided.

:project-root a java.io.File representing the project root.

:namespace a coll of symbols representing the namespaces which should be formatted, if empty all project namespaces will be considered.

:filenames a coll of files representing the files which should be formatted.

dry? a boolean, when enabled make no side-effects (no changes to files), only report.

:ns-exclude-regex a string regex representing the namespaces that should be excluded during this call.

settings map of settings following https://clojure-lsp.io/settings/

Example

(clojure-lsp.api/format! {:namespace '[my-project.foo my-project.bar]})
Format one or more namespaces using cljfmt internally.

**Options**
All options below are optional, using its default if not provided.

`:project-root` a java.io.File representing the project root.

`:namespace` a coll of symbols representing the namespaces which should be formatted,
if empty all project namespaces will be considered.

`:filenames` a coll of files representing the files which should be formatted.

`dry?` a boolean, when enabled make no side-effects (no changes to files), only report.

`:ns-exclude-regex` a string regex representing the namespaces that should be excluded during this call.

`settings` map of settings following https://clojure-lsp.io/settings/

**Example**

```clojure
(clojure-lsp.api/format! {:namespace '[my-project.foo my-project.bar]})
```
sourceraw docstring

referencesclj

(references {:keys [project-root settings from] :as options})

Find all references of an symbol across the project and dependencies. The symbol can be a full qualified symbol or a namespace only.

Options All options besides :from and :to below are optional, using its default if not provided.

:project-root a java.io.File representing the project root.

:analysis a map with options on how clojure-lsp should analyze the project, available values are: :type keyword values: project-only, project-and-shallow-analysis, project-and-full-dependencies. Default to project-and-full-dependencies.

:from the full qualified symbol to find references. e.g. 'my-project.foo/my-var

settings map of settings following https://clojure-lsp.io/settings/

Output

result-code an integer representing whether the action was successful, 0 means ok, 1 means error

message-fn a function of no arity to be called if want the result as a stringfied version.

:result :references a coll of all reference elements found for the :from symbol.

Example

(clojure-lsp.api/references {:from 'my-project.some/foo})
=> {:result {:references [{:name ... :uri ...}]}
    :result-code 0}
Find all references of an symbol across the project and dependencies.
The symbol can be a full qualified symbol or a namespace only.

**Options**
All options besides `:from` and `:to` below are optional, using its default if not provided.

`:project-root` a java.io.File representing the project root.

`:analysis` a map with options on how clojure-lsp should analyze the project, available values are:
  `:type` keyword values: `project-only`, `project-and-shallow-analysis`, `project-and-full-dependencies`. Default to `project-and-full-dependencies`.

`:from` the full qualified symbol to find references. e.g. 'my-project.foo/my-var

`settings` map of settings following https://clojure-lsp.io/settings/

**Output**

`result-code` an integer representing whether the action was successful, 0 means ok, 1 means error

`message-fn` a function of no arity to be called if want the result as a stringfied version.

`:result`
  `:references` a coll of all reference elements found for the `:from` symbol.

**Example**

```clojure
(clojure-lsp.api/references {:from 'my-project.some/foo})
=> {:result {:references [{:name ... :uri ...}]}
    :result-code 0}
```
sourceraw docstring

rename!clj

(rename! {:keys [project-root settings from to] :as options})

Rename a symbol and its definitions across the project. The symbol can be a full qualified symbol or a namespace only.

Options All options besides :from and :to below are optional, using its default if not provided.

:project-root a java.io.File representing the project root.

:from the full qualified symbol origin name that should be renamed. e.g. my-project.foo/my-var or my-project.foo for namespaces

:to the full qualified symbol that will replace the original symbol. e.g. my-project.bar/my-var-2 or my-project.bar for namespaces

dry? a boolean, when enabled make no side-effects (no changes to files), only report.

settings map of settings following https://clojure-lsp.io/settings/

Example

(clojure-lsp.api/rename! {:from 'my-project.some/foo
                          :to 'my-project.some/bar})
Rename a symbol and its definitions across the project.
The symbol can be a full qualified symbol or a namespace only.

**Options**
All options besides `:from` and `:to` below are optional, using its default if not provided.

`:project-root` a java.io.File representing the project root.

`:from` the full qualified symbol origin name that should be renamed. e.g. my-project.foo/my-var or my-project.foo for namespaces

`:to` the full qualified symbol that will replace the original symbol. e.g. my-project.bar/my-var-2 or my-project.bar for namespaces

`dry?` a boolean, when enabled make no side-effects (no changes to files), only report.

`settings` map of settings following https://clojure-lsp.io/settings/

**Example**

```clojure
(clojure-lsp.api/rename! {:from 'my-project.some/foo
                          :to 'my-project.some/bar})
```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close