Skip to content

Commit

Permalink
Merge pull request #13 from rszyma/formatter
Browse files Browse the repository at this point in the history
Formatting `deflayer`s doesn't work yet within `include`s. Support for it will be added in a separate PR. Formatter is disabled-by-default in settings right now.
  • Loading branch information
rszyma authored Jan 15, 2024
2 parents 1c8fbf1 + 0eccd72 commit 20b6142
Show file tree
Hide file tree
Showing 20 changed files with 1,526 additions and 1,022 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ jobs:
env:
VSCE_PAT: ${{ secrets.VSCE_ACCESS_TOKEN }}
run: |
make package
make CARGO_FLAGS=--release package
just release ${{ steps.new_version.outputs.value }}
9 changes: 3 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@ jobs:
- name: Setup - rust target for wasm
run: rustup target add wasm32-unknown-unknown

# - name: Build with wasm-pack
# run: wasm-pack build

# - name: Test with wasm-pack
# run: wasm-pack test --headless --firefox
- name: Rust - test kls
run: cargo test

- name: Setup - install clippy
run: rustup component add clippy

- name: Rust - Lint
run: cargo clippy --target wasm32-unknown-unknown -- -D warnings
run: cargo clippy -- -D warnings

- name: Rust - Format
run: cargo fmt --check
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**/target
**/node_modules
**/out
out
yarn-error.log
.vscode-test
*.vsix
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
"rust-analyzer.cargo.features": "all",
"todo-tree.tree.showBadges": false,
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Unreleased

* no changes yet
* Added experimental support for formatting `deflayer`s according to `defsrc` layout (disabled by default, can be enabled in settings)

### 0.6.3

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ See the [change log](CHANGELOG.md).
- https://github.com/osohq/oso - used this as vscode extension template (with a lot of things removed)
- https://github.com/canadaduane/vscode-kmonad - syntax highlighting config
- https://github.com/jtroo/kanata/blob/main/assets/kanata-icon.svg - kanata icon
- https://github.com/entibo/vscode-kmonad-format - the idea of formatting `deflayer`s according to spacing in `defsrc`
23 changes: 22 additions & 1 deletion client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class Extension implements Disposable {
.getConfiguration()
.get<string>('vscode-kanata.includesAndWorkspaces', ''),
localKeysVariant: localKeysVariant as string,
format: getFormatterSettings(),
},
};

Expand Down Expand Up @@ -258,4 +259,24 @@ function getLocalKeysVariant(): LocalKeysVariant {
}

return localKeysVariant as LocalKeysVariant;
}
}


interface FormatterSettings {
enable: boolean;
useDefsrcLayoutOnDeflayers: boolean;
}

function getFormatterSettings(): FormatterSettings {
const formatSettings = workspace
.getConfiguration()
.get<FormatterSettings>('vscode-kanata.format');

if (formatSettings === undefined) {
throw new Error('should be defined')
}

console.log("formatSettings:", formatSettings)

return formatSettings;
}
7 changes: 6 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ _default:
install:
git submodule update
make package
code --install-extension kanata.vsix
code --install-extension kanata.vsix --force

install_release:
git submodule update
make CARGO_FLAGS=--release package
code --install-extension kanata.vsix --force

# Creates a commit, that updates kanata to latest git and adds notice about it to CHANGELOG.md
bump_kanata:
Expand Down
3 changes: 3 additions & 0 deletions kls/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
.vscode
Cargo.lock
Loading

0 comments on commit 20b6142

Please sign in to comment.