updated nvim init.lua and waybar network module

This commit is contained in:
2025-08-29 14:38:51 +02:00
parent 251b5a5eeb
commit 653591289d
4 changed files with 97 additions and 126 deletions

View File

@@ -6,6 +6,9 @@ vim.o.smartcase = true
vim.o.ignorecase = true vim.o.ignorecase = true
vim.o.hlsearch = false vim.o.hlsearch = false
vim.o.signcolumn = 'yes' vim.o.signcolumn = 'yes'
vim.o.clipboard = 'unnamedplus'
vim.o.undofile = true
vim.o.undodir = '/home/narl/.cache/nvim-undodir'
vim.g.mapleader = ',' vim.g.mapleader = ','
@@ -14,14 +17,6 @@ require('mini.deps').setup()
local add = MiniDeps.add local add = MiniDeps.add
add({
source = 'neovim/nvim-lspconfig'
})
add({
source = 'chomosuke/typst-preview.nvim'
})
add({ add({
source = 'williamboman/mason.nvim' source = 'williamboman/mason.nvim'
}) })
@@ -34,10 +29,6 @@ add({
source = 'williamboman/mason-lspconfig.nvim' source = 'williamboman/mason-lspconfig.nvim'
}) })
add({
source = 'mhartington/formatter.nvim'
})
add({ add({
source = 'mfussenegger/nvim-lint' source = 'mfussenegger/nvim-lint'
}) })
@@ -70,10 +61,6 @@ add({
hooks = { post_checkout = function() vim.cmd('TSUpdate') end }, hooks = { post_checkout = function() vim.cmd('TSUpdate') end },
}) })
add({
source = 'simrat39/rust-tools.nvim'
})
add({ add({
-- Completion framework: -- Completion framework:
source = 'hrsh7th/nvim-cmp', source = 'hrsh7th/nvim-cmp',
@@ -99,43 +86,7 @@ require('mini.files').setup({
require('mini.icons').setup({style = 'ascii'}) require('mini.icons').setup({style = 'ascii'})
require('mini.pick').setup({}) require('mini.pick').setup({})
require('mini.snippets').setup({}) require('mini.snippets').setup({})
require('mini.notify').setup({ require('mini.notify').setup({})
-- Content management
content = {
-- Function which formats the notification message
-- By default prepends message with notification time
format = nil,
-- Function which orders notification array from most to least important
-- By default orders first by level and then by update timestamp
sort = nil,
},
-- Notifications about LSP progress
lsp_progress = {
-- Whether to enable showing
enable = true,
-- Notification level
level = 'INFO',
-- Duration (in ms) of how long last message should be shown
duration_last = 1000,
},
-- Window options
window = {
-- Floating window config
config = {
},
-- Maximum window width as share (between 0 and 1) of available columns
max_width_share = 0.382,
-- Value of 'winblend' option
winblend = 0,
},
})
require('mini.statusline').setup({}) require('mini.statusline').setup({})
require('mini.tabline').setup({}) require('mini.tabline').setup({})
require('mini.git').setup({}) require('mini.git').setup({})
@@ -147,8 +98,8 @@ imap_expr('<S-Tab>', [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]])
_G.cr_action = function() _G.cr_action = function()
-- If there is selected item in popup, accept it with <C-y> -- If there is selected item in popup, accept it with <C-y>
if vim.fn.complete_info()['selected'] ~= -1 then return '\25' end if vim.fn.complete_info()['selected'] ~= -1 then return '\25' end
-- Fall back to plain `<CR>`. You might want to customize according -- Fall back to plain `<CR>`. You might want to customize this
-- to other plugins. For example if 'mini.pairs' is set up, replace -- according to other plugins. For example if 'mini.pairs' is set up, replace
-- next line with `return MiniPairs.cr()` -- next line with `return MiniPairs.cr()`
return '\r' return '\r'
end end
@@ -205,48 +156,21 @@ vim.lsp.config('rust_analyzer', {
['rust-analyzer'] = {}, ['rust-analyzer'] = {},
}, },
}) })
local mason_registry = require("mason-registry")
local cmd = {}
vim.list_extend(cmd, {
"dotnet",
vim.fs.joinpath("/home/narl/.local/share/nvim/mason/packages/roslyn", "libexec", "Microsoft.CodeAnalysis.LanguageServer.dll"),
"--stdio",
"--logLevel=Information",
"--extensionLogDirectory=" .. vim.fs.dirname(vim.lsp.get_log_path()),
})
local rzls_path = vim.fs.joinpath("/home/narl/.local/share/nvim/mason/packages/rzls", "libexec") require('roslyn').setup({
table.insert(
cmd,
"--razorSourceGenerator=" .. vim.fs.joinpath(rzls_path, "Microsoft.CodeAnalysis.Razor.Compiler.dll")
)
table.insert(
cmd,
"--razorDesignTimePath="
.. vim.fs.joinpath(rzls_path, "Targets", "Microsoft.NET.Sdk.Razor.DesignTime.targets")
)
vim.lsp.config("roslyn", {
cmd = cmd,
config = { config = {
-- the rest of your Roslyn configuration -- the rest of your Roslyn configuration
handlers = require("rzls.roslyn_handlers"), handlers = require("rzls.roslyn_handlers"),
}, },
}) })
vim.lsp.config('nvim-treesitter.configs', {
highlight = { enable = true },
})
vim.cmd("au ColorScheme * highlight MiniNotifyNormal guibg=NONE")
vim.cmd("au ColorScheme * highlight MiniNotifyTitle guibg=NONE")
vim.cmd("au ColorScheme * highlight MiniNotifyBorder guibg=NONE")
require("catppuccin").setup({ require("catppuccin").setup({
flavour = "auto", -- latte, frappe, macchiato, mocha flavour = "auto", -- latte, frappe, macchiato, mocha
background = { -- :h background background = { -- :h background
light = "latte", light = "latte",
dark = "mocha", dark = "mocha",
}, },
transparent_background = true, -- disables setting the background color. transparent_background = false, -- disables setting the background color.
show_end_of_buffer = false, -- shows the '~' characters after the end of buffers show_end_of_buffer = false, -- shows the '~' characters after the end of buffers
term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`) term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`)
dim_inactive = { dim_inactive = {
@@ -335,19 +259,16 @@ vim.diagnostic.config({
}, },
}) })
vim.cmd([[
set signcolumn=yes
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
]])
-- setup must be called before loading -- setup must be called before loading
vim.cmd.colorscheme "catppuccin" vim.cmd.colorscheme "catppuccin"
vim.keymap.set('n', '<leader>w', '<cmd>write<cr>', {desc = 'Save file'}) vim.keymap.set('n', '<leader>w', '<cmd>write<cr>', {desc = 'Save file'})
vim.keymap.set('n', '<leader>q', '<cmd>quitall<cr>', {desc = 'Exit vim'}) vim.keymap.set('n', '<leader>q', '<cmd>quitall<cr>', {desc = 'Exit vim'})
vim.keymap.set({'n', 'x', 'o'}, 'gy', '"+y', {desc = 'Copy to clipboard'}) -- Simplified clipboard mappings
vim.keymap.set({'n', 'x', 'o'}, 'gp', '"+p', {desc = 'Paste clipboard text'}) -- vim.keymap.set({'n', 'x', 'o'}, '<leader>y', '"+y', {desc = 'Copy to clipboard'})
-- vim.keymap.set({'n', 'x'}, '<leader>p', '"+p', {desc = 'Paste from clipboard'})
vim.keymap.set('n', '<leader>e', '<cmd>lua MiniFiles.open()<cr>', {desc = 'File explorer'}) vim.keymap.set('n', '<leader>e', '<cmd>lua MiniFiles.open()<cr>', {desc = 'File explorer'})
vim.keymap.set('n', '<leader><space>', '<cmd>Pick buffers<cr>', {desc = 'Search open files'}) vim.keymap.set('n', '<leader><space>', '<cmd>Pick buffers<cr>', {desc = 'Search open files'})
vim.keymap.set('n', '<leader>ff', '<cmd>Pick files<cr>', {desc = 'Search all files'}) vim.keymap.set('n', '<leader>ff', '<cmd>Pick files<cr>', {desc = 'Search all files'})
@@ -359,20 +280,6 @@ vim.keymap.set('n', '<leader>j', '<cmd>wincmd j<cr>')
vim.keymap.set('n', '<leader>k', '<cmd>wincmd k<cr>') vim.keymap.set('n', '<leader>k', '<cmd>wincmd k<cr>')
-- Rust -- Rust
--
local rt = require("rust-tools")
rt.setup({
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
end,
},
})
local cmp = require'cmp' local cmp = require'cmp'
cmp.setup({ cmp.setup({

View File

@@ -3,14 +3,14 @@
"layer": "top", "layer": "top",
"position": "top", "position": "top",
"output": "eDP-1", "output": "eDP-1",
"height": 40, "height": 30,
"modules-left": ["hyprland/workspaces"], "modules-left": ["hyprland/workspaces"],
"modules-center": [], "modules-center": [],
"modules-right": [ "modules-right": [
"custom/pixelbuds_pro", "custom/pixelbuds_pro",
"wireplumber", "wireplumber",
"custom/audio-output", "custom/audio-output",
"network", "custom/network",
"custom/mem", "custom/mem",
"custom/cpu", "custom/cpu",
"custom/disk-root", "custom/disk-root",
@@ -51,7 +51,7 @@
}, },
"wireplumber": { "wireplumber": {
"format": "{volume}% {icon}", "format": "{volume}% {icon}",
"format-muted": "--- ", "format-muted": "",
"format-icons": { "format-icons": {
"headphone": "", "headphone": "",
"hands-free": "", "hands-free": "",
@@ -87,7 +87,7 @@
}, },
"tray": { "tray": {
"icon-size": 18, "icon-size": 18,
"spacing": 10 "spacing": 6
}, },
"custom/power": { "custom/power": {
"format": "", "format": "",
@@ -192,19 +192,25 @@
"return-type": "json", "return-type": "json",
"exec": "~/.config/waybar/scripts/disk_info.sh ~/games", "exec": "~/.config/waybar/scripts/disk_info.sh ~/games",
"interval": 30 "interval": 30
},
"custom/network": {
"exec": "~/.config/waybar/scripts/network.sh",
"interval": 2, // in seconds
"format": "{}",
"return-type": "json"
} }
},{ },{
"layer": "top", "layer": "top",
"position": "top", "position": "top",
"output": "!eDP-1", "output": "!eDP-1",
"height": 40, "height": 30,
"modules-left": ["hyprland/workspaces"], "modules-left": ["hyprland/workspaces"],
"modules-center": [], "modules-center": [],
"modules-right": [ "modules-right": [
// "custom/pixelbuds_pro", // "custom/pixelbuds_pro",
"wireplumber", "wireplumber",
"custom/audio-output", "custom/audio-output",
"network", "custom/network",
"custom/mem", "custom/mem",
"custom/cpu", "custom/cpu",
"custom/disk-root", "custom/disk-root",
@@ -245,7 +251,7 @@
}, },
"wireplumber": { "wireplumber": {
"format": "{volume}% {icon}", "format": "{volume}% {icon}",
"format-muted": "--- ", "format-muted": "",
"format-icons": { "format-icons": {
"headphone": "", "headphone": "",
"hands-free": "", "hands-free": "",
@@ -281,7 +287,7 @@
}, },
"tray": { "tray": {
"icon-size": 18, "icon-size": 18,
"spacing": 10 "spacing": 6
}, },
"custom/power": { "custom/power": {
"format": "", "format": "",
@@ -386,5 +392,11 @@
"return-type": "json", "return-type": "json",
"exec": "~/.config/waybar/scripts/disk_info.sh ~/games", "exec": "~/.config/waybar/scripts/disk_info.sh ~/games",
"interval": 30 "interval": 30
},
"custom/network": {
"exec": "~/.config/waybar/scripts/network.sh",
"interval": 2, // in seconds
"format": "{}",
"return-type": "json"
} }
}] }]

50
waybar/scripts/network.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
# Path for the temporary file to store previous stats
STATS_FILE="/tmp/waybar_net_stats"
# Find the default network interface
INTERFACE=$(ip route | grep '^default' | awk '{print $5}' | head -n1)
# Exit if no active interface is found
if [ -z "$INTERFACE" ]; then
echo "{\"text\": \"No connection\"}"
exit 0
fi
# Get the IP address for the interface
IP_ADDR=$(ip -4 addr show "$INTERFACE" | grep -oP 'inet \K[\d.]+')
# Get current time and byte counts
TIME_NOW=$(date +%s)
RX_BYTES_NOW=$(cat "/sys/class/net/$INTERFACE/statistics/rx_bytes")
TX_BYTES_NOW=$(cat "/sys/class/net/$INTERFACE/statistics/tx_bytes")
# Initialize speeds to 0
RX_MBPS="0.00"
TX_MBPS="0.00"
# Read previous values if the stats file exists
if [ -f "$STATS_FILE" ]; then
source "$STATS_FILE" # This loads PREV_TIME, PREV_RX_BYTES, PREV_TX_BYTES
fi
# Calculate speed if we have previous data and time has passed
if [ -n "$PREV_TIME" ] && [ "$TIME_NOW" -gt "$PREV_TIME" ]; then
TIME_DIFF=$((TIME_NOW - PREV_TIME))
RX_BPS=$(( (RX_BYTES_NOW - PREV_RX_BYTES) / TIME_DIFF ))
TX_BPS=$(( (TX_BYTES_NOW - PREV_TX_BYTES) / TIME_DIFF ))
# Using printf for better formatting (forces two decimal places)
RX_MBPS=$(printf "%.2f" "$(echo "$RX_BPS / 1024 / 1024" | bc -l)")
TX_MBPS=$(printf "%.2f" "$(echo "$TX_BPS / 1024 / 1024" | bc -l)")
fi
# Save current values for the next run
echo "PREV_TIME=$TIME_NOW" > "$STATS_FILE"
echo "PREV_RX_BYTES=$RX_BYTES_NOW" >> "$STATS_FILE"
echo "PREV_TX_BYTES=$TX_BYTES_NOW" >> "$STATS_FILE"
# Output JSON for Waybar
echo "{\"text\": \"$INTERFACE ($IP_ADDR):  ${RX_MBPS} MB/s  ${TX_MBPS} MB/s\"}"

View File

@@ -11,7 +11,7 @@
window#waybar { window#waybar {
background-color: alpha(@base, 0.4); background-color: alpha(@base, 0.4);
padding: 10px; padding: 4px;
transition-property: background-color; transition-property: background-color;
transition-duration: 0.5s; transition-duration: 0.5s;
color: @text; color: @text;
@@ -28,7 +28,7 @@ window#waybar.hidden {
/* Fix weird spacing in materia (waybar #450) */ /* Fix weird spacing in materia (waybar #450) */
box-shadow: inset 0 -3px transparent; box-shadow: inset 0 -3px transparent;
/* Use box-shadow instead of border so the text isn't offset */ /* Use box-shadow instead of border so the text isn't offset */
padding: 6px 18px; padding: 0px 12px;
margin: 0px 3px; margin: 0px 3px;
border-radius: 10px; border-radius: 10px;
background-color: @base; background-color: @base;
@@ -62,6 +62,7 @@ window#waybar.hidden {
#battery, #battery,
#backlight, #backlight,
#wireplumber, #wireplumber,
#custom-network,
#network, #network,
#clock, #clock,
#tray, #tray,
@@ -76,7 +77,7 @@ window#waybar.hidden {
#custom-gpu-screen-recorder { #custom-gpu-screen-recorder {
border-radius: 10px; border-radius: 10px;
margin: 0px 3px; margin: 0px 3px;
padding: 6px 12px; padding: 0px 6px;
background-color: @base; background-color: @base;
color: @text; color: @text;
} }
@@ -88,19 +89,19 @@ window#waybar.hidden {
} }
#custom-pixelbuds_pro.disconnected { #custom-pixelbuds_pro.disconnected {
padding-right: 16px; padding-right: 10px;
padding-left: 12px; padding-left: 8px;
} }
#custom-gpu-screen-recorder, #custom-gpu-screen-recorder,
#custom-gpu-screen-recorder.recording { #custom-gpu-screen-recorder.recording {
padding-right: 18px; padding-right: 12px;
padding-left: 10px; padding-left: 4px;
} }
#custom-gamemode { #custom-gamemode {
padding-right: 15px; padding-right: 9px;
padding-left: 11px; padding-left: 5px;
} }
#custom-pixelbuds_pro.anc-active { #custom-pixelbuds_pro.anc-active {
@@ -141,7 +142,7 @@ window#waybar.hidden {
} }
#custom-tlp { #custom-tlp {
padding: 0 10px; padding: 0 4px;
min-width: 10px; min-width: 10px;
} }
@@ -206,6 +207,7 @@ window#waybar.hidden {
#cpu, #cpu,
#disk, #disk,
#network, #network,
#custom-network,
#custom-gpu.normal, #custom-gpu.normal,
#custom-cpu.normal, #custom-cpu.normal,
#custom-mem.normal, #custom-mem.normal,
@@ -224,7 +226,7 @@ window#waybar.hidden {
} }
#wireplumber { #wireplumber {
padding-right: 16px; padding-right: 10px;
} }
#custom-audio-output.unmuted, #wireplumber { #custom-audio-output.unmuted, #wireplumber {
@@ -237,12 +239,12 @@ window#waybar.hidden {
} }
#network { #network {
padding-right: 15px; padding-right: 9px;
} }
tooltip { tooltip {
border-radius: 10px; border-radius: 10px;
padding: 15px; padding: 9px;
background-color: @base; background-color: @base;
} }