Skip to content

Commit 4978eaa

Browse files
committed
Updates the documentation for the interface
Adds autogenerated command line documentation
1 parent d92537c commit 4978eaa

File tree

8 files changed

+319
-248
lines changed

8 files changed

+319
-248
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Initialises the log channel and adds `$/setTrace` to override client's (i.e. VS Code) loglevel
2020
- Unified the interfaces from the command line and the configuration options file
2121
([gnikit/fortls#17](https://github.com/gnikit/fortls/issues/17))
22+
- Updated the documentation and simplified the README.md
2223

2324
### Deprecated
2425

README.md

Lines changed: 22 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# fortls - the Fortran Language Server
22

33
[![PyPI Latest Release](https://img.shields.io/pypi/v/fortls.svg)](https://pypi.org/project/fortls/)
4-
[![Tests](https://github.com/gnikit/fortran-language-server/actions/workflows/main.yml/badge.svg)](https://github.com/gnikit/fortran-language-server/actions/workflows/main.yml)
4+
[![Tests](https://github.com/gnikit/fortls/actions/workflows/main.yml/badge.svg)](https://github.com/gnikit/fortls/actions/workflows/main.yml)
55
[![Documentation](https://github.com/gnikit/fortls/actions/workflows/docs.yml/badge.svg)](https://github.com/gnikit/fortls/actions/workflows/docs.yml)
6-
[![image](https://img.shields.io/github/license/gnikit/fortran-language-server.svg)](https://github.com/gnikit/fortran-language-server/blob/master/LICENSE)
6+
[![image](https://img.shields.io/github/license/gnikit/fortls.svg)](https://github.com/gnikit/fortls/blob/master/LICENSE)
77
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
88

99
`fortls` is an implementation of the [Language Server Protocol](https://github.com/Microsoft/language-server-protocol)
@@ -23,6 +23,9 @@ This project is based on @hansec's original Language Server implementation but t
2323
`fortls` (this project) is now developed independently of the upstream `hansec/fortran-language-server` project and contains numerous bug fixes and new features
2424
the original `fortran-language-server` does not.
2525

26+
For a complete and detailed list of the differences between the two Language Servers
27+
see the Documentation section: [Unique fortls features (not in fortran-language-server)](https://gnikit.github.io/fortls/fortls_changes.html)
28+
2629
The name of executable for this project has been chosen to remain `fortls`
2730
to allow for integration with pre-existing plugins and workflows but it is
2831
potentially subject to change.
@@ -32,7 +35,7 @@ potentially subject to change.
3235
- Project-wide and Document symbol detection and Renaming
3336
- Hover support, Signature help and Auto-completion
3437
- GoTo/Peek implementation and Find/Peek references
35-
- Symbol renaming (`textDocument/rename`)
38+
- Preprocessor support
3639
- Documentation parsing ([Doxygen](http://www.doxygen.org/) and
3740
[FORD](https://github.com/Fortran-FOSS-Programmers/ford) styles)
3841
- Access to multiple intrinsic modules and functions
@@ -61,7 +64,6 @@ potentially subject to change.
6164

6265
- Signature help is not available for overloaded subroutines/functions
6366
- Diagnostics are only updated when files are saved or opened/closed
64-
- Files included for preprocessor are not parsed for Fortran objects
6567

6668
## Installation
6769

@@ -71,216 +73,28 @@ pip install fortls
7173

7274
## Settings
7375

74-
The following global settings can be used when launching the language
75-
server.
76-
77-
- `--config` Configuration options file (default: `.fortls`)
78-
- `--nthreads` Number of threads to use during workspace
79-
initialization (default: 4)
80-
- `--notify_init` Send notification message when workspace
81-
initialization is complete
82-
- `--symbol_skip_mem` Do not include type members in document symbol
83-
results
84-
- `--incremental_sync` Use incremental document synchronization
85-
- `--autocomplete_no_prefix` Do not filter autocomplete results by
86-
variable prefix
87-
- `--autocomplete_no_snippets` Do not use snippets with place holders
88-
in autocomplete results
89-
- `--autocomplete_name_only` Complete only the name of procedures and
90-
not the parameters
91-
- `--lowercase_intrinsics` Use lowercase for intrinsics and keywords
92-
in autocomplete requests
93-
- `--use_signature_help` Use signature help instead of snippets for
94-
subroutines/functions
95-
- `--variable_hover` Show hover information for variables (default:
96-
subroutines/functions only)
97-
- `--hover_signature` Show signature information in hover for argument
98-
(also enables '--variable_hover')
99-
- `--preserve_keyword_order` Display variable keywords information in
100-
original order (default: sort to consistent ordering)
101-
- `--enable_code_actions` Enable experimental code actions (default:
102-
false)
103-
- `--disable_diagnostics` Disable code diagnostics (default: false)
104-
- `--max_line_length` Maximum line length (default: none)
105-
- `--max_comment_line_length` Maximum comment line length (default:
106-
none)
107-
- `--debug_log` Write debug information to `root_dir/fortls_debug.log`
108-
(requires a specified `root_dir` during initialization)
109-
110-
### Debug settings
111-
112-
The following settings can be used to perform [standalone debug
113-
tests](https://github.com/hansec/fortran-language-server/wiki) on the
114-
fortls
115-
116-
- `--debug_filepath=DEBUG_FILEPATH` File path for fortls tests
117-
- `--debug_rootpath=DEBUG_ROOTPATH` Root path for fortls tests
118-
- `--debug_line=DEBUG_LINE` Line position for fortls (1-indexed)
119-
- `--debug_char=DEBUG_CHAR` Character position for fortls tests (1-indexed)
120-
- `--debug_full_result` Print full result object instead of condensed
121-
version
122-
- `--debug_parser` Test source code parser on specified file
123-
- `--debug_diagnostics` Test diagnostic notifications for specified
124-
file
125-
- `--debug_symbols` Test symbol request for specified file
126-
- `--debug_workspace_symbols=QUERY_STRING` Test workspace/symbol
127-
request for project-wide search
128-
- `--debug_completion` Test completion request for specified file and
129-
position
130-
- `--debug_signature` Test signatureHelp request for specified file
131-
and position
132-
- `--debug_definition` Test definition request for specified file and
133-
position
134-
- `--debug_hover` Test hover request for specified file and position
135-
- `--debug_implementation` Test implementation request for specified
136-
file and position
137-
- `--debug_references` Test references request for specified file and
138-
position
139-
- `--debug_rename=RENAME_STRING` Test rename request for specified
140-
file and position
141-
- `--debug_actions` Test codeAction request for specified file and
142-
position
143-
144-
## Configuration
145-
146-
Project specific settings can be specified by creating a **options** JSON file.
147-
You can specify the location and name of the file with the `--config` option.
148-
By default the options file is assumed to be `root_dir` with the name `.fortls`.
149-
150-
All command line options are also available through the **options** file as well.
151-
152-
- `lowercase_intrinsics` Use lowercase for intrinsics and keywords in
153-
autocomplete requests (default: false)
154-
- `debug_log` Write debug information to `root_dir/fortls_debug.log`
155-
(default: false)
156-
- `disable_diagnostics` Disable diagnostics for this project only
157-
(default: false)
158-
- `max_line_length` Maximum line length (default: none)
159-
- `max_comment_line_length` Maximum comment line length (default:
160-
none)
161-
- `incl_suffixes` Add more Fortran extensions to be parsed by the server
162-
163-
## Additional settings
164-
165-
### Default file extensions
166-
167-
By default all files with the suffix `F,F77,F90,F95,F03,F08,FOR,FPP`
168-
(case-insensitive) in the `root_dir` directory, specified during
169-
initialization, and all its sub-directories are parsed and included in
170-
the project.
171-
172-
### Excluding folders and file extensions
173-
174-
Directories and files can be excluded from the project by specifying
175-
their paths in the `excl_paths` variable in the options file.
176-
Paths can be absolute or relative to `root_dir`.
177-
178-
Excluded directories **will not** exclude all sub-directories.
179-
Source files with a common suffix may also be excluded using the
180-
`excl_suffixes` variable.
181-
182-
> NOTE: All directory inputs fields (`excl_paths`, `source_dirs`, `include_dirs`) support
183-
> [Python glob patterns](https://docs.python.org/3/library/glob.html) e.g. `/**`, `*`, etc.
184-
185-
### Including source directories
186-
187-
By default all source directories under `root_dir` are recursively included.
188-
Source file directories can also be specified manually by specifying
189-
their paths in the `source_dirs` variable in the configuration options file.
190-
Paths can be absolute or relative to `root_dir`.
191-
`root_dir` does not need to be specified manually as it is always included.
192-
193-
When defining `source_dirs` in the configuration options filethe default behaviour (i.e. including
194-
all files in all subdirectories under `root_dir`) is overriden. To include them
195-
back again one can do
196-
197-
```json
198-
{
199-
"source_dirs": ["/**", "all", "other", "dirs"]
200-
}
201-
```
202-
203-
### Preprocessing
204-
205-
**Note:** Preprocessor support is not "complete", see below. For
206-
preprocessed files the `fortls` will only analyze code within
207-
preprocessor conditional regions if the conditional test can be
208-
evaluated by the server or if the region is the _default_ path (ie. a
209-
bare `#else` region).
210-
211-
**Note:** Currently, `#include` statements are only used for
212-
preprocessing (ie. tracking definitions). Fortran objects defined in
213-
these files will not be processed.
214-
215-
File suffixes for preprocessing can be controlled with the variable
216-
`pp_suffixes` in a workspace's configuration options file. When this variable is
217-
used _only_ those files with the specified suffixes will be
218-
preprocessed. If an empty array is specified then _no_ preprocessing
219-
will be performed on any files. By default, or if the variable is
220-
omitted or `null`, only files with upper case suffixes are preprocessed.
76+
`fortls` can be configured through both the command line e.g.
77+
`fortls --hover_signature` or through a Configuration json file.
78+
The two interfaces are identical and a full list of the available options can
79+
be found in the [Documentation](https://gnikit.github.io/fortls/options.html)
80+
or through `fortls -h`
22181

222-
Preprocessor definitions can be set for each project, to improve support
223-
for Fortran files using conditional compilation, using the `pp_defs`
224-
variable in the configuration options file. Preprocessing is performed _only_ for
225-
files where the file extension is all caps (ie. ".F90", ".F", etc.).
226-
Currently, support for preprocessing is limited to variables declared in
227-
the project's configuration options file or in the source file of interest as
228-
`#include` files and inheritance through `USE` statements are yet not
229-
supported. Variable substitution is also performed within files, but is
230-
currently limited to non-recursive cases. For example, `#define PP_VAR1 PP_VAR2` will cause `PP_VAR1` to be replaced with the text `PP_VAR2`
231-
throughout the file, not that value of `PP_VAR2`.
232-
233-
Include directories can be specified using the variable `include_dirs`
234-
in a workspace's configuration options file. These directories are _only_ used to
235-
search for preprocessor `#include`'d files. The directory containing the
236-
file where an `#include` statement is encountered is always searched.
237-
File search is performed starting with the containing directory followed
238-
by the specified `include_dirs` specified paths, in order (left to
239-
right).
82+
An example for a Configuration file is given below
24083

24184
```json
24285
{
243-
"source_dirs": ["subdir1/**", "subdir2"],
244-
"excl_paths": ["subdir3/**", "subdir1/file_to_skip.F90"],
86+
"incremental_sync": true,
87+
"lowercase_intrinsics": true,
88+
"hover_signature": true,
89+
"use_signature_help": true,
90+
"excl_paths": ["tests/**", "tools/**"],
24591
"excl_suffixes": ["_skip.f90"],
246-
"pp_suffixes": [".f03", ".F90"],
247-
"pp_defs": { "HAVE_PACKAGE": "" },
248-
"include_dirs": ["rel_include/dir_path", "/abs/include/dir/path"],
249-
"lowercase_intrinsics": false,
250-
"debug_log": false
92+
"include_dirs": ["include/**"],
93+
"pp_suffixes": [".F90", ".h"],
94+
"pp_defs": { "HAVE_HDF5": "", "MPI_Comm": "integer" }
25195
}
25296
```
25397

254-
<!-- ## Editor examples (Atom)
255-
256-
Document symbols (`textDocument/documentSymbol`):
257-
258-
![image](https://raw.githubusercontent.com/gnikit/fortran-language-server/master/images/fortls_outline.png)
259-
260-
Auto-complete (`textDocument/completion`):
261-
262-
![image](https://raw.githubusercontent.com/gnikit/fortran-language-server/master/images/fortls_autocomplete.gif)
263-
264-
Signature help (`textDocument/signatureHelp`):
265-
266-
![image](https://raw.githubusercontent.com/gnikit/fortran-language-server/master/images/fortls_sigHelp.gif)
267-
268-
Goto definition (`textDocument/definition`):
269-
270-
![image](https://raw.githubusercontent.com/gnikit/fortran-language-server/master/images/fortls_gotodef.gif)
271-
272-
Hover (`textDocument/hover`):
273-
274-
![image](https://raw.githubusercontent.com/gnikit/fortran-language-server/master/images/fortls_hover.gif)
275-
276-
Find references (`textDocument/references`):
277-
278-
![image](https://raw.githubusercontent.com/gnikit/fortran-language-server/master/images/fortls_refs.png)
279-
280-
Diagnostics:
281-
282-
![image](https://raw.githubusercontent.com/gnikit/fortran-language-server/master/images/fortls_diag.png) -->
283-
28498
## Implemented server requests
28599

286100
| Request | Description |
@@ -310,9 +124,9 @@ Support the original project go [here](https://paypal.me/hansec)
310124

311125
## Bug reports
312126

313-
When [filing bugs](https://github.com/gnikit/fortran-language-server/issues/new)
127+
When [filing bugs](https://github.com/gnikit/fortls/issues/new)
314128
please provide example code to reproduce the observed issue.
315129

316130
## License
317131

318-
This project is made available under the [MIT License](https://github.com/gnikit/fortran-language-server/blob/master/LICENSE).
132+
This project is made available under the [MIT License](https://github.com/gnikit/fortls/blob/dev/LICENSE).

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
6767
# ones.
6868
extensions = [
69+
"sphinxarg.ext",
6970
"sphinx.ext.autodoc",
7071
"sphinx.ext.autosectionlabel",
7172
"sphinx.ext.autosummary",

docs/fortls.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ fortls.helper\_functions module
2020
:undoc-members:
2121
:show-inheritance:
2222

23+
fortls.interface module
24+
-----------------------
25+
26+
.. automodule:: fortls.interface
27+
:members:
28+
:undoc-members:
29+
:show-inheritance:
30+
2331
fortls.intrinsics module
2432
------------------------
2533

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fortls
1111
:caption: Contents:
1212

1313
README.md
14+
options.rst
1415
fortls_changes.md
1516
modules.rst
1617

0 commit comments

Comments
 (0)