-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move lsp settings to its own namespace
- Loading branch information
Showing
4 changed files
with
218 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
_: { | ||
programs.nixvim = { | ||
plugins.conform-nvim = { | ||
enable = true; | ||
notifyOnError = true; | ||
formattersByFt = { | ||
html = [["prettierd" "prettier"]]; | ||
css = [["prettierd" "prettier"]]; | ||
javascript = [["prettierd" "prettier"]]; | ||
javascriptreact = [["prettierd" "prettier"]]; | ||
typescript = [["prettierd" "prettier"]]; | ||
typescriptreact = [["prettierd" "prettier"]]; | ||
java = ["google-java-format"]; | ||
python = ["black"]; | ||
lua = ["stylua"]; | ||
nix = ["alejandra"]; | ||
markdown = [["prettierd" "prettier"]]; | ||
rust = ["rustfmt"]; | ||
}; | ||
}; | ||
|
||
keymaps = [ | ||
{ | ||
mode = "n"; | ||
key = "<leader>uf"; | ||
action = ":FormatToggle<CR>"; | ||
options = { | ||
desc = "Toggle Format"; | ||
silent = true; | ||
}; | ||
} | ||
{ | ||
mode = "n"; | ||
key = "<leader>cf"; | ||
action = "<cmd>lua require('conform').format()<cr>"; | ||
options = { | ||
silent = true; | ||
desc = "Format Buffer"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "v"; | ||
key = "<leader>cF"; | ||
action = "<cmd>lua require('conform').format()<cr>"; | ||
options = { | ||
silent = true; | ||
desc = "Format Lines"; | ||
}; | ||
} | ||
]; | ||
|
||
extraConfigLua = '' | ||
local conform = require("conform") | ||
local notify = require("notify") | ||
conform.setup({ | ||
format_on_save = function(bufnr) | ||
-- Disable with a global or buffer-local variable | ||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then | ||
return | ||
end | ||
return { timeout_ms = 500, lsp_fallback = true } | ||
end, | ||
}) | ||
local function show_notification(message, level) | ||
notify(message, level, { title = "conform.nvim" }) | ||
end | ||
vim.api.nvim_create_user_command("FormatToggle", function(args) | ||
local is_global = not args.bang | ||
if is_global then | ||
vim.g.disable_autoformat = not vim.g.disable_autoformat | ||
if vim.g.disable_autoformat then | ||
show_notification("Autoformat-on-save disabled globally", "info") | ||
else | ||
show_notification("Autoformat-on-save enabled globally", "info") | ||
end | ||
else | ||
vim.b.disable_autoformat = not vim.b.disable_autoformat | ||
if vim.b.disable_autoformat then | ||
show_notification("Autoformat-on-save disabled for this buffer", "info") | ||
else | ||
show_notification("Autoformat-on-save enabled for this buffer", "info") | ||
end | ||
end | ||
end, { | ||
desc = "Toggle autoformat-on-save", | ||
bang = true, | ||
}) | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
_: { | ||
imports = [ | ||
./lsp.nix | ||
]; | ||
imports = [ | ||
./conform.nix | ||
./fidget.nix | ||
./lsp.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
programs.nixvim = { | ||
plugins = { | ||
fidget = { | ||
enable = true; | ||
logger = { | ||
level = "warn"; # “off”, “error”, “warn”, “info”, “debug”, “trace” | ||
floatPrecision = 0.01; # Limit the number of decimals displayed for floats | ||
}; | ||
progress = { | ||
pollRate = 0; # How and when to poll for progress messages | ||
suppressOnInsert = true; # Suppress new messages while in insert mode | ||
ignoreDoneAlready = false; # Ignore new tasks that are already complete | ||
ignoreEmptyMessage = false; # Ignore new tasks that don't contain a message | ||
clearOnDetach = | ||
# Clear notification group when LSP server detaches | ||
'' | ||
function(client_id) | ||
local client = vim.lsp.get_client_by_id(client_id) | ||
return client and client.name or nil | ||
end | ||
''; | ||
notificationGroup = | ||
# How to get a progress message's notification group key | ||
'' | ||
function(msg) return msg.lsp_client.name end | ||
''; | ||
ignore = []; # List of LSP servers to ignore | ||
lsp = { | ||
progressRingbufSize = 0; # Configure the nvim's LSP progress ring buffer size | ||
}; | ||
display = { | ||
renderLimit = 16; # How many LSP messages to show at once | ||
doneTtl = 3; # How long a message should persist after completion | ||
doneIcon = "✔"; # Icon shown when all LSP progress tasks are complete | ||
doneStyle = "Constant"; # Highlight group for completed LSP tasks | ||
progressTtl = "math.huge"; # How long a message should persist when in progress | ||
progressIcon = { | ||
pattern = "dots"; | ||
period = 1; | ||
}; # Icon shown when LSP progress tasks are in progress | ||
progressStyle = "WarningMsg"; # Highlight group for in-progress LSP tasks | ||
groupStyle = "Title"; # Highlight group for group name (LSP server name) | ||
iconStyle = "Question"; # Highlight group for group icons | ||
priority = 30; # Ordering priority for LSP notification group | ||
skipHistory = true; # Whether progress notifications should be omitted from history | ||
formatMessage = '' | ||
require ("fidget.progress.display").default_format_message | ||
''; # How to format a progress message | ||
formatAnnote = '' | ||
function (msg) return msg.title end | ||
''; # How to format a progress annotation | ||
formatGroupName = '' | ||
function (group) return tostring (group) end | ||
''; # How to format a progress notification group's name | ||
overrides = { | ||
rust_analyzer = { | ||
name = "rust-analyzer"; | ||
}; | ||
}; # Override options from the default notification config | ||
}; | ||
}; | ||
notification = { | ||
pollRate = 10; # How frequently to update and render notifications | ||
filter = "info"; # “off”, “error”, “warn”, “info”, “debug”, “trace” | ||
historySize = 128; # Number of removed messages to retain in history | ||
overrideVimNotify = true; | ||
redirect = '' | ||
function(msg, level, opts) | ||
if opts and opts.on_open then | ||
return require("fidget.integration.nvim-notify").delegate(msg, level, opts) | ||
end | ||
end | ||
''; | ||
configs = { | ||
default = "require('fidget.notification').default_config"; | ||
}; | ||
|
||
window = { | ||
normalHl = "Comment"; | ||
winblend = 0; | ||
border = "none"; # none, single, double, rounded, solid, shadow | ||
zindex = 45; | ||
maxWidth = 0; | ||
maxHeight = 0; | ||
xPadding = 1; | ||
yPadding = 0; | ||
align = "bottom"; | ||
relative = "editor"; | ||
}; | ||
view = { | ||
stackUpwards = true; # Display notification items from bottom to top | ||
iconSeparator = " "; # Separator between group name and icon | ||
groupSeparator = "---"; # Separator between notification groups | ||
groupSeparatorHl = | ||
# Highlight group used for group separator | ||
"Comment"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters