Skip to content

build(bin,lsp): add lsp feature flag to executable - #18148

Merged
fdncred merged 12 commits into
nushell:mainfrom
mkatychev:feat/lsp-feature-flag
Jun 23, 2026
Merged

fdncred merged 12 commits into
nushell:mainfrom
mkatychev:feat/lsp-feature-flag

Conversation

@mkatychev

@mkatychev mkatychev commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

Add nu-lsp feature flag to the executable.

This change allows the Nushell LSP functionality to be feature gated to help slim down binary size for CI use cases.


Here are some size comparisons:
image

  • nushell-pre.tar.gz is the tarball for cargo build --release --no-default-features on latest main

User-facing changes (Release notes)

Added support for feature gating LSP functionality, specifically enable it via --features lsp.

Additional notes

@mkatychev mkatychev changed the title feat(cli,ci): add lsp feature flag feat(cli,ci): add lsp feature flag to executable May 1, 2026
@mkatychev mkatychev changed the title feat(cli,ci): add lsp feature flag to executable build(bin,lsp): add lsp feature flag to executable May 1, 2026
@fdncred

fdncred commented May 1, 2026

Copy link
Copy Markdown
Contributor

I'm not sure about this but i'd call the feature lsp vs nu-lsp.

@mkatychev

Copy link
Copy Markdown
Contributor Author

I'm not sure about this but i'd call the feature lsp vs nu-lsp.

Yeah, this was me being lazy about adding a feature flag declaration. Glad I got called out!

Comment thread src/main.rs Outdated
LanguageServer::initialize_stdio_connection(engine_state)?.serve_requests()?
if is_lsp {
#[cfg(feature = "lsp")]
run_lsp(engine_state, parsed_nu_cli_args, use_color)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should probably pass the start_time to the run_lsp function instead of starting a new one and put it at the top like the function does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully I've addressed this correctly: d718675

@mkatychev
mkatychev requested a review from fdncred May 26, 2026 14:58
@fdncred

fdncred commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Can you fix the merge conflicts please?

Comment thread src/main.rs Outdated
#[cfg(feature = "mcp")]
if parsed_nu_cli_args.mcp {
perf!("mcp starting", start_time, use_color);
perf!("mcp starting", nu_utils::time::Instant::now(), use_color);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the point of the start_time is not to start it every line that has perf! on it. can we switch all these perf! lines back and make sure it works as it originally did (as far as perf! goes). You can see what perf! lines look like with nu --log-level info

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fdncred I think I am more confused now, all perf calls use past tense:

"perf: {}:{}:{} \x1b[32m{}\x1b[0m took \x1b[33m{:?}\x1b[0m",

And yet the log here is done before the mcp server initialized so for the lsp section the log below implies that starting the lsp took ~13 microseconds:

[INFO ] nu::run: perf: src/run.rs:231:5 lsp starting took 12.667µs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've hopefully addressed feedback in 6a945cf but I'm still unsure of the reasoning

@fdncred fdncred Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning is that perf! is supposed to show how long things took to run. It was like that when I added it years ago but people have messed it up over the years.

So, like for the run_lsp command you'd have to remove perf! from the start of the function and do something like:

... all stuff at start of function
let serve_requests = nu_lsp::LanguageServer::initialize_stdio_connection(engine_state)?.serve_requests();
perf!("lsp started", start_time, use_color);
serve_requests

or above do something similar with run_lsp in the if is_lsp instead of having anything in the run_lsp.

I'm not sure if either of those would work. You'd have to experiment. I'm sure there's a better way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, @fdncred I am aiming to address this by end of week.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks for working with me.

@mkatychev
mkatychev requested a review from fdncred June 2, 2026 16:09
@fdncred

fdncred commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

conflicts, ugh. sorry.

@mkatychev
mkatychev force-pushed the feat/lsp-feature-flag branch from 86af869 to 7fe5c75 Compare June 22, 2026 21:44
@mkatychev

Copy link
Copy Markdown
Contributor Author

@fdncred can you take another look?

@fdncred fdncred added notes:ready Indicates Ready for Release notes notes:other Noted in "Other changes" section labels Jun 23, 2026
@fdncred

fdncred commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

ok, let's try this. I already fixed the security failure in another PR.

@fdncred
fdncred merged commit 56fcf3a into nushell:main Jun 23, 2026
17 of 19 checks passed
@github-actions github-actions Bot added this to the v0.114.0 milestone Jun 23, 2026
@mkatychev
mkatychev deleted the feat/lsp-feature-flag branch June 29, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:other Noted in "Other changes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants