Skip to content

Commit

Permalink
Cleanup, reorganise, activate now available features (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 authored Jun 29, 2024
1 parent ab4179b commit 7b2d60b
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 145 deletions.
152 changes: 72 additions & 80 deletions modules/cmp.nix
Original file line number Diff line number Diff line change
@@ -1,93 +1,85 @@
{
plugins.cmp = {
enable = true;
autoEnableSources = true;
plugins = {
cmp = {
enable = true;
autoEnableSources = true;

#preselect = "None";
settings = {
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';

#cmdline =
# let
# search = {
# mapping.__raw = "cmp.mapping.preset.cmdline()";
# sources = [{ name = "buffer"; }];
# };
# in
# {
# "/" = search;
# "?" = search;
# ":" = {
# mapping.__raw = "cmp.mapping.preset.cmdline()";
# sources = [
# { name = "path"; }
# {
# name = "cmdline";
# option = { ignore_cmds = [ "Man" "!" ]; };
# }
# ];
# };
# };
settings = {
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';
# Order influences ranking
sources = map (name: { inherit name; }) [
"crates"
"nvim_lsp"
"luasnip"
#"treesitter"
"path"
"buffer"
#"calc"
"cmdline"
];

sources = map (name: { inherit name; }) [
"crates"
"nvim_lsp"
"luasnip"
#"treesitter"
"path"
"buffer"
#"calc"
"cmdline"
];
mapping = {
"<CR>" = ''
cmp.mapping(function(fallback)
local luasnip = require'luasnip'
if cmp.visible() then
if luasnip.expandable() then
luasnip.expand()
else
cmp.confirm({
select = true,
})
end
else
fallback()
end
end)
'';
"<C-Space>" = "cmp.mapping.complete()";

mapping = {
"<CR>" = ''
# TODO: page up/down buttons to scroll multiple times
"<Tab>" = ''
cmp.mapping(function(fallback)
local luasnip = require'luasnip'
local luasnip = require'luasnip'
if cmp.visible() then
if luasnip.expandable() then
luasnip.expand()
else
cmp.confirm({
select = true,
})
end
cmp.select_next_item()
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
fallback()
end
end)
'';
"<C-Space>" = "cmp.mapping.complete()";

# TODO: page up/down buttons to scroll multiple times
"<Tab>" = ''
end, { "i", "s" })
'';
"<S-Tab>" = ''
cmp.mapping(function(fallback)
local luasnip = require'luasnip'
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" })
'';
"<S-Tab>" = ''
cmp.mapping(function(fallback)
local luasnip = require'luasnip'
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" })
'';
local luasnip = require'luasnip'
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" })
'';
};
};
};

# icons in cmp
lspkind.enable = true;

luasnip = {
enable = true;
extraConfig = {
region_check_events = "CursorHold,InsertLeave";
# those are for removing deleted snippets, also a common problem
delete_check_events = "TextChanged,InsertEnter";
};
};
};
Expand Down
35 changes: 1 addition & 34 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,52 +34,19 @@
};

plugins = {
# needs 24.05
# remove from extraPlugins
# autoclose.enable = true; # brackets, html, ...
autoclose.enable = true; # brackets, html, ...
# does not work
#commentary.enable = true;
bufferline.enable = true;
lastplace.enable = true;
# icons in cmp
lspkind.enable = true;
gitsigns.enable = true;
nvim-colorizer.enable = true;
indent-blankline.enable = true;
lint = {
enable = true;
lintersByFt = {
css = [ "eslint_d" ];
scss = [ "eslint_d" ];
gitcommit = [ "commitlint" ];
javascript = [ "eslint_d" ];
javascriptreact = [ "eslint_d" ];
json = [ "jsonlint" ];
markdownlint = [ "markdownlint" ];
nix = [ "nix" ];
python = [ "ruff" ];
sh = [ "shellcheck" ];
typescript = [ "eslint_d" ];
typescriptreact = [ "eslint_d" ];
yaml = [ "yamllint" ];
};
# Trigger linting more aggressively, not only after writing a buffer
autoCmd.event = [ "BufWritePost" "BufEnter" "BufLeave" ];
};
luasnip = {
enable = true;
extraConfig = {
region_check_events = "CursorHold,InsertLeave";
# those are for removing deleted snippets, also a common problem
delete_check_events = "TextChanged,InsertEnter";
};
};
lualine = {
enable = true;
globalstatus = true;
theme = "onedark";
};
nvim-autopairs.enable = true;
tmux-navigator.enable = true;
crates-nvim.enable = true;
};
Expand Down
64 changes: 34 additions & 30 deletions modules/lsp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,36 @@ let
in
{
plugins = {
lint = {
enable = true;
lintersByFt = {
css = [ "eslint_d" ];
scss = [ "eslint_d" ];
gitcommit = [ "commitlint" ];
javascript = [ "eslint_d" ];
javascriptreact = [ "eslint_d" ];
json = [ "jsonlint" ];
markdownlint = [ "markdownlint" ];
nix = [ "nix" ];
python = [ "ruff" ];
sh = [ "shellcheck" ];
typescript = [ "eslint_d" ];
typescriptreact = [ "eslint_d" ];
yaml = [ "yamllint" ];
};
# Trigger linting more aggressively, not only after writing a buffer
autoCmd.event = [ "BufWritePost" "BufEnter" "BufLeave" ];
};

lsp = {
enable = true;
servers = {
angularls.enable = true;
#ansiblels.enable = true;
ansiblels.enable = true;
bashls.enable = true;
cssls.enable = true;
#docker-compose-language-service.enable = true;
#dockerls.enable = true;
docker-compose-language-service.enable = true;
dockerls.enable = true;
eslint.enable = true;
html.enable = true;
java-language-server = {
Expand All @@ -21,7 +42,7 @@ in
};
jsonls.enable = true;
ltex.enable = true;
#marksman.enable = true;
marksman.enable = true;
#nixd.enable = true;
nil-ls.enable = true;
rust-analyzer = {
Expand All @@ -30,13 +51,14 @@ in
installRustc = false;
package = rust;
};
#sqls.enable = true;
sqls.enable = true;
taplo.enable = true;
texlab.enable = true;
tsserver.enable = true;
#typos-lsp.enable = true;
typos-lsp.enable = true;
yamlls.enable = true;
};

keymaps = {
silent = true;
diagnostic = {
Expand Down Expand Up @@ -83,13 +105,11 @@ in
action = "type_definition";
desc = "Goto Type Defition";
};

"gi" = {
action = "implementation";
desc = "Goto Implementation";
};
"<leader>k" = {

action = "hover";
desc = "Hover";
};
Expand All @@ -102,26 +122,10 @@ in
};
};

extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
name = "toggle-lsp-diagnostics";
src = pkgs.fetchFromGitHub {
owner = "WhoIsSethDaniel";
repo = "toggle-lsp-diagnostics.nvim";
rev = "afcacba44d86df4c3c9752b869e78eb838f55765";
hash = "sha256-7yWZjlfO3OclvS4VAd5J7MaOkRPDvBP1xQyGizRzJgk=";
};
})
];

keymaps = [
{
mode = "n";
key = "<leader>tld";
action = "<Plug>(toggle-lsp-diag)";
options = {
desc = "Toggle LSP diagnostics";
};
}
];
keymaps = [ {
mode = "n";
key = "<leader>tld";
action = "<Plug>(toggle-lsp-diag)";
options.desc = "Toggle LSP diagnostics";
} ];
}
2 changes: 1 addition & 1 deletion pkgs/angular-language-server/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ buildNpmPackage, fetchurl }:

buildNpmPackage rec {
name = "@angular/language-server";
name = "angular-language-server";
version = "18.0.0";

src = fetchurl {
Expand Down

0 comments on commit 7b2d60b

Please sign in to comment.