diff --git a/nvim/init.lua b/nvim/init.lua index 257e03f..fa9e181 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -6,6 +6,9 @@ vim.o.smartcase = true vim.o.ignorecase = true vim.o.hlsearch = false vim.o.signcolumn = 'yes' +vim.o.clipboard = 'unnamedplus' +vim.o.undofile = true +vim.o.undodir = '/home/narl/.cache/nvim-undodir' vim.g.mapleader = ',' @@ -14,14 +17,6 @@ require('mini.deps').setup() local add = MiniDeps.add -add({ - source = 'neovim/nvim-lspconfig' -}) - -add({ - source = 'chomosuke/typst-preview.nvim' -}) - add({ source = 'williamboman/mason.nvim' }) @@ -34,10 +29,6 @@ add({ source = 'williamboman/mason-lspconfig.nvim' }) -add({ - source = 'mhartington/formatter.nvim' -}) - add({ source = 'mfussenegger/nvim-lint' }) @@ -70,10 +61,6 @@ add({ hooks = { post_checkout = function() vim.cmd('TSUpdate') end }, }) -add({ - source = 'simrat39/rust-tools.nvim' -}) - add({ -- Completion framework: source = 'hrsh7th/nvim-cmp', @@ -99,43 +86,7 @@ require('mini.files').setup({ require('mini.icons').setup({style = 'ascii'}) require('mini.pick').setup({}) require('mini.snippets').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.notify').setup({}) require('mini.statusline').setup({}) require('mini.tabline').setup({}) require('mini.git').setup({}) @@ -147,8 +98,8 @@ imap_expr('', [[pumvisible() ? "\" : "\"]]) _G.cr_action = function() -- If there is selected item in popup, accept it with if vim.fn.complete_info()['selected'] ~= -1 then return '\25' end --- Fall back to plain ``. You might want to customize according --- to other plugins. For example if 'mini.pairs' is set up, replace +-- Fall back to plain ``. You might want to customize this +-- according to other plugins. For example if 'mini.pairs' is set up, replace -- next line with `return MiniPairs.cr()` return '\r' end @@ -205,48 +156,21 @@ vim.lsp.config('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") -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, +require('roslyn').setup({ config = { -- the rest of your Roslyn configuration 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({ flavour = "auto", -- latte, frappe, macchiato, mocha background = { -- :h background light = "latte", 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 term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`) 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 vim.cmd.colorscheme "catppuccin" vim.keymap.set('n', 'w', 'write', {desc = 'Save file'}) vim.keymap.set('n', 'q', 'quitall', {desc = 'Exit vim'}) -vim.keymap.set({'n', 'x', 'o'}, 'gy', '"+y', {desc = 'Copy to clipboard'}) -vim.keymap.set({'n', 'x', 'o'}, 'gp', '"+p', {desc = 'Paste clipboard text'}) +-- Simplified clipboard mappings +-- vim.keymap.set({'n', 'x', 'o'}, 'y', '"+y', {desc = 'Copy to clipboard'}) +-- vim.keymap.set({'n', 'x'}, 'p', '"+p', {desc = 'Paste from clipboard'}) + vim.keymap.set('n', 'e', 'lua MiniFiles.open()', {desc = 'File explorer'}) vim.keymap.set('n', '', 'Pick buffers', {desc = 'Search open files'}) vim.keymap.set('n', 'ff', 'Pick files', {desc = 'Search all files'}) @@ -359,20 +280,6 @@ vim.keymap.set('n', 'j', 'wincmd j') vim.keymap.set('n', 'k', 'wincmd k') -- Rust --- - -local rt = require("rust-tools") - -rt.setup({ - server = { - on_attach = function(_, bufnr) - -- Hover actions - vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) - -- Code action groups - vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) - end, - }, -}) local cmp = require'cmp' cmp.setup({ diff --git a/waybar/config.jsonc b/waybar/config.jsonc index 0d9ac1b..af69767 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -3,14 +3,14 @@ "layer": "top", "position": "top", "output": "eDP-1", - "height": 40, + "height": 30, "modules-left": ["hyprland/workspaces"], "modules-center": [], "modules-right": [ "custom/pixelbuds_pro", "wireplumber", "custom/audio-output", - "network", + "custom/network", "custom/mem", "custom/cpu", "custom/disk-root", @@ -51,7 +51,7 @@ }, "wireplumber": { "format": "{volume}% {icon}", - "format-muted": "--- ", + "format-muted": "", "format-icons": { "headphone": "", "hands-free": "", @@ -87,7 +87,7 @@ }, "tray": { "icon-size": 18, - "spacing": 10 + "spacing": 6 }, "custom/power": { "format": "", @@ -192,19 +192,25 @@ "return-type": "json", "exec": "~/.config/waybar/scripts/disk_info.sh ~/games", "interval": 30 + }, + "custom/network": { + "exec": "~/.config/waybar/scripts/network.sh", + "interval": 2, // in seconds + "format": "{}", + "return-type": "json" } },{ "layer": "top", "position": "top", "output": "!eDP-1", - "height": 40, + "height": 30, "modules-left": ["hyprland/workspaces"], "modules-center": [], "modules-right": [ // "custom/pixelbuds_pro", "wireplumber", "custom/audio-output", - "network", + "custom/network", "custom/mem", "custom/cpu", "custom/disk-root", @@ -245,7 +251,7 @@ }, "wireplumber": { "format": "{volume}% {icon}", - "format-muted": "--- ", + "format-muted": "", "format-icons": { "headphone": "", "hands-free": "", @@ -281,7 +287,7 @@ }, "tray": { "icon-size": 18, - "spacing": 10 + "spacing": 6 }, "custom/power": { "format": "", @@ -386,5 +392,11 @@ "return-type": "json", "exec": "~/.config/waybar/scripts/disk_info.sh ~/games", "interval": 30 + }, + "custom/network": { + "exec": "~/.config/waybar/scripts/network.sh", + "interval": 2, // in seconds + "format": "{}", + "return-type": "json" } }] diff --git a/waybar/scripts/network.sh b/waybar/scripts/network.sh new file mode 100755 index 0000000..f4ae619 --- /dev/null +++ b/waybar/scripts/network.sh @@ -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\"}" diff --git a/waybar/style.css b/waybar/style.css index afd35d1..167377e 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -11,7 +11,7 @@ window#waybar { background-color: alpha(@base, 0.4); - padding: 10px; + padding: 4px; transition-property: background-color; transition-duration: 0.5s; color: @text; @@ -28,7 +28,7 @@ window#waybar.hidden { /* Fix weird spacing in materia (waybar #450) */ box-shadow: inset 0 -3px transparent; /* Use box-shadow instead of border so the text isn't offset */ - padding: 6px 18px; + padding: 0px 12px; margin: 0px 3px; border-radius: 10px; background-color: @base; @@ -62,6 +62,7 @@ window#waybar.hidden { #battery, #backlight, #wireplumber, +#custom-network, #network, #clock, #tray, @@ -76,7 +77,7 @@ window#waybar.hidden { #custom-gpu-screen-recorder { border-radius: 10px; margin: 0px 3px; - padding: 6px 12px; + padding: 0px 6px; background-color: @base; color: @text; } @@ -88,19 +89,19 @@ window#waybar.hidden { } #custom-pixelbuds_pro.disconnected { - padding-right: 16px; - padding-left: 12px; + padding-right: 10px; + padding-left: 8px; } #custom-gpu-screen-recorder, #custom-gpu-screen-recorder.recording { - padding-right: 18px; - padding-left: 10px; + padding-right: 12px; + padding-left: 4px; } #custom-gamemode { - padding-right: 15px; - padding-left: 11px; + padding-right: 9px; + padding-left: 5px; } #custom-pixelbuds_pro.anc-active { @@ -141,7 +142,7 @@ window#waybar.hidden { } #custom-tlp { - padding: 0 10px; + padding: 0 4px; min-width: 10px; } @@ -206,6 +207,7 @@ window#waybar.hidden { #cpu, #disk, #network, +#custom-network, #custom-gpu.normal, #custom-cpu.normal, #custom-mem.normal, @@ -224,7 +226,7 @@ window#waybar.hidden { } #wireplumber { - padding-right: 16px; + padding-right: 10px; } #custom-audio-output.unmuted, #wireplumber { @@ -237,12 +239,12 @@ window#waybar.hidden { } #network { - padding-right: 15px; + padding-right: 9px; } tooltip { border-radius: 10px; - padding: 15px; + padding: 9px; background-color: @base; }