Skip to content

Commit

Permalink
feat: multi-config
Browse files Browse the repository at this point in the history
Add docs for multiconfig, validation of
project config paths

filter completions with config

Allow configs in subdirectories of other configs

trailing whitespace in README

Change config field name: `projects`->`project`

feat: Support file paths as `project` config paths

feat: User supplied compiler command in `.asm-lsp.toml`

feat: Improved assembler and isa config values

fix serialization of new config values

Update README

feat: Make `config.opts` optional

feat: Log error when multiple project configs point
to the same path

resolve lingering conflicts

post rebase lints
  • Loading branch information
WillLillis committed Nov 3, 2024
1 parent d2c511a commit 5e66331
Show file tree
Hide file tree
Showing 22 changed files with 773 additions and 675 deletions.
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,28 @@ selectively target specific assemblers and/or instruction sets. Omitting an item
from the `assemblers` or `instruction_sets` sections is equivalent to setting it
to `false`. Be default, diagnostics are enabled and the server attempts to invoke
`gcc` (and then `clang`) to generate them. If the `compiler` config field is specified,
the server will attempt to use the specified path to generate diagnostics.
the server will attempt to use the specified path to generate diagnostics. Different
configurations can be created for different sub-directories or files within your
project as `project`s. Source files not contained within any `project` configs will
use the default configuration if provided.

```toml
version = "0.1"

[assemblers]
gas = true
go = false
z80 = false
masm = false
nasm = false

[instruction_sets]
x86 = false
x86_64 = true
z80 = false
arm = false
arm64 = false
riscv = false
[default_config]
assembler = "Go"
instruction_set = "x86/x86-64"

[opts]
compiler = "zig" # need "cc" as the first argument in `compile_flags.txt`
diagnostics = true
default_diagnostics = true

# Configure the server's treatment of source files in the `arm-project` sub-directory
[[project]]
path = "arm-project"
assembler = "Gas"
instruction_set = "arm"

# NOTE: Specifying the `opts` field isn't necessary
```

### [OPTIONAL] Extend functionality via `compile_commands.json`/`compile_flags.txt`
Expand Down
128 changes: 66 additions & 62 deletions asm-lsp/bin/main.rs

Large diffs are not rendered by default.

23 changes: 17 additions & 6 deletions asm-lsp/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use tree_sitter::Parser;
use crate::{
apply_compile_cmd, get_comp_resp, get_default_compile_cmd, get_document_symbols,
get_goto_def_resp, get_hover_resp, get_ref_resp, get_sig_help_resp, get_word_from_pos_params,
send_empty_resp, text_doc_change_to_ts_edit, Config, NameToInfoMaps, NameToInstructionMap,
TreeEntry, TreeStore,
send_empty_resp, text_doc_change_to_ts_edit, Arch, Assembler, Config, ConfigOptions,
NameToInfoMaps, NameToInstructionMap, TreeEntry, TreeStore,
};

/// Handles hover requests
Expand Down Expand Up @@ -91,9 +91,9 @@ pub fn handle_completion_request(
config: &Config,
text_store: &TextDocuments,
tree_store: &mut TreeStore,
instruction_completion_items: &[CompletionItem],
directive_completion_items: &[CompletionItem],
register_completion_items: &[CompletionItem],
instruction_completion_items: &[(Arch, CompletionItem)],
directive_completion_items: &[(Assembler, CompletionItem)],
register_completion_items: &[(Arch, CompletionItem)],
) -> Result<()> {
let uri = &params.text_document_position.text_document.uri;
if let Some(doc) = text_store.get_document(uri) {
Expand Down Expand Up @@ -217,6 +217,7 @@ pub fn handle_signature_help_request(
let sig_resp = get_sig_help_resp(
doc.get_content(None),
params,
config,
tree_entry,
names_to_instructions,
);
Expand Down Expand Up @@ -315,7 +316,17 @@ pub fn handle_diagnostics(
// If no user-provided entries corresponded to the file, just try out
// invoking the user-provided compiler (if they gave one), or alternatively
// gcc (and clang if that fails) with the source file path as the only argument
if !has_entries && cfg.opts.default_diagnostics.unwrap_or(false) {
if !has_entries
&& matches!(
cfg.opts,
// NOTE: We ensure this field is always `Some` at load time
Some(ConfigOptions {
// NOTE: We ensure this field is always `Some` at load time
default_diagnostics: Some(true),
..
})
)
{
info!(
"No applicable user-provided commands for {}. Applying default compile command",
uri.path().as_str()
Expand Down
Loading

0 comments on commit 5e66331

Please sign in to comment.