Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inlay hints Toggle + lsp support #60

Merged
merged 7 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable

- name: Install Nix Linting and Formatting Tools
run: nix-env -i statix nixpkgs-fmt -f '<nixpkgs>'
run: nix-env -i statix alejandra -f '<nixpkgs>'

- name: Flake update
run: nix flake update
Expand Down
13 changes: 5 additions & 8 deletions config/keymaps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,10 @@
end
end

if vim.lsp.inlay_hint then
vim.keymap.set(
"n",
"<leader>uh",
function() vim.lsp.inlay_hiny(0, nil) end,
{ desc = "Toggle inlay hints" }
)
end
if vim.lsp.inlay_hint then
vim.keymap.set('n', '<leader>uh', function()
vim.lsp.inlay_hint(0, nil)
end, { desc = 'Toggle Inlay Hints' })
end
'';
}
23 changes: 23 additions & 0 deletions config/languages/typescript-tools-nvim.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
{
plugins.typescript-tools = {
enable = true;
onAttach = ''
function(client, bufnr)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false

if vim.lsp.inlay_hint then
vim.lsp.inlay_hint(bufnr, true)
end
end
'';
settings = {
tsserverFilePreferences = {
# Inlay Hints
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayVariableTypeHints = true;
includeInlayVariableTypeHintsWhenTypeMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayEnumMemberValueHints = true;
};
};
};

keymaps = [
Expand Down
39 changes: 33 additions & 6 deletions config/lsp/lsp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
enable = true;
capabilities = "offsetEncoding = 'utf-16'";
servers = {
clangd = { enable = true; };
clangd = {enable = true;};
lua-ls = {
enable = true;
extraOptions = {
Expand All @@ -19,18 +19,45 @@
telemetry = {
enabled = false;
};
hint = {enable = true;};
};
};
};
};
nil_ls = { enable = true; };
nil_ls = {enable = true;};
tsserver = {
enable = false;
filetypes = [ "javascript" "javascriptreact" "typescript" "typescriptreact" ];
filetypes = ["javascript" "javascriptreact" "typescript" "typescriptreact"];
extraOptions = {
settings = {
javascript = {
inlayHints = {
includeInlayEnumMemberValueHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayVariableTypeHints = true;
};
};
typescript = {
inlayHints = {
includeInlayEnumMemberValueHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayVariableTypeHints = true;
};
};
};
};
};
eslint = { enable = true; };
pyright = { enable = true; };
ruff-lsp = { enable = true; };
eslint = {enable = true;};
pyright = {enable = true;};
ruff-lsp = {enable = true;};

rust-analyzer = {
enable = true;
Expand Down
14 changes: 14 additions & 0 deletions config/utils/whichkey.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
# TODO: Implement general mappings
plugins.which-key = {
enable = true;
ignoreMissing = false;
icons = {
breadcrumb = "»";
group = "+";
separator = ""; # ➜
};
# registrations = {
# "<leader>t" = " Terminal";
# };
window = {
border = "none";
winblend = 0;
};
};
}
17 changes: 8 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 12 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{ self
, nixpkgs
, nixvim
, flake-utils
, ...
} @ inputs:
let
config = import ./config; # import the module directly
in
flake-utils.lib.eachDefaultSystem (system:
let
outputs = {
self,
nixpkgs,
nixvim,
flake-utils,
...
} @ inputs: let
config = import ./config; # import the module directly
in
flake-utils.lib.eachDefaultSystem (system: let
nixvimLib = nixvim.lib.${system};
pkgs = import nixpkgs { inherit system; };
pkgs = import nixpkgs {inherit system;};
nixvim' = nixvim.legacyPackages.${system};
nvim = nixvim'.makeNixvimWithModule {
inherit pkgs;
Expand All @@ -29,8 +27,7 @@
inherit self;
};
};
in
{
in {
checks = {
# Run `nix flake check .` to verify that your config is not broken
default = nixvimLib.check.mkTestDerivationFromNvim {
Expand Down