mattn / mattn/vim-lsp-settings

Unneeded uniq()

Open
#646 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Vim Script
Stars
1.4k
Forks
245
Avg merge
3m
Merged PRs (30d)
1

Description

This is apparently a minor issue, but I just noticed and decided to report it:

https://github.com/mattn/vim-lsp-settings/blob/7166674dc49306a6fcaff19d4dde8bca95271460/autoload/lsp_settings/profile.vim#L101-L110

First you create a unique list of commands, then pass it to uniq() which makes no difference. Unless I'm missing something.

On a side note I thought if it could be done in a more compact way, and here's what I ended up with:

let Flatten = {d -> reduce(values(d), {r, i -> extend(r, i)})}
let l:servers = mapnew(l:settings, 'mapnew(v:val, "v:val.command")')
let l:servers = uniq(sort(Flatten(l:servers)))

Not that it's necessarily better.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open autoload/lsp_settings/profile.vim at lines 101-110 and inspect how the command list is made unique before uniq() is called. Confirm whether the earlier operation already guarantees uniqueness, then remove only the redundant step if appropriate and verify that the generated server command list is unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
vim
Domain
tooling
Issue type
Refactor
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.