refactor(nvim): better dir structure

This commit is contained in:
max_richter 2021-11-10 13:09:54 +01:00
parent 3c81fd59fe
commit 59b5bdce99
21 changed files with 358 additions and 148 deletions

View File

@ -174,11 +174,11 @@ font:
#draw_bold_text_with_bright_colors: false
# Colors (Tomorrow Night)
#colors:
colors:
# Default colors
#primary:
# background: '#1d1f21'
# foreground: '#c5c8c6'
primary:
background: '#000000'
foreground: '#c5c8c6'
# Bright and dim foreground colors
#
@ -205,9 +205,9 @@ font:
#
# Allowed values are CellForeground/CellBackground, which reference the
# affected cell, or hexadecimal colors like #ff00ff.
#vi_mode_cursor:
# text: CellBackground
# cursor: CellForeground
vi_mode_cursor:
text: CellBackground
cursor: CellForeground
# Search colors
#

View File

@ -1,70 +0,0 @@
{ pkgs, ... }:
{
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
programs.direnv.nix-direnv.enableFlakes = true;
programs.zsh.enable = true;
home.packages = [
pkgs.zsh
pkgs.direnv
pkgs.tmux
pkgs.tmuxPlugins.yank
pkgs.tmuxPlugins.cpu
pkgs.nodejs_latest
pkgs.nodePackages.pnpm
pkgs.nodePackages.typescript-language-server
pkgs.nodePackages.svelte-language-server
pkgs.nodePackages.diagnostic-languageserver
];
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
nixpkgs.overlays = [
(import (builtins.fetchTarball {
url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz;
}))
];
programs.neovim = {
enable = true;
package = pkgs.neovim-nightly;
};
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "jim";
home.homeDirectory = "/home/jim";
home.file = {
".zshrc".source = ./.zshrc;
".bashrc".source = ./.bashrc;
".p10k.zsh".source = ./.p10k.zsh;
".tmux.conf".source = ./.tmux.conf;
".dircolors".source = ./.dircolors;
# ".local/share/nvim/site/pack/paqs/start/paq-nvim".source = pkgs.fetchzip {
# url = "https://github.com/savq/paq-nvim/archive/refs/heads/master.zip";
# };
};
xdg.configFile = {
"nvim/init.lua".source = ./init.lua;
};
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "21.11";
}

View File

@ -1,53 +0,0 @@
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
interval = 2
}
# order += "ipv6"
# order += "wireless _first_"
order += "ethernet _first_"
# order += "battery all"
order += "disk /"
# order += "load"
order += "memory"
order += "tztime local"
wireless _first_ {
format_up = "W: (%quality at %essid) %ip"
format_down = "W: down"
}
ethernet _first_ {
format_up = "E: %ip (%speed)"
format_down = "E: down"
}
battery all {
format = "%status %percentage %remaining"
}
disk "/" {
format = "%avail"
}
load {
format = "%1min"
}
memory {
format = "%used | %available"
threshold_degraded = "1G"
format_degraded = "MEMORY < %available"
}
tztime local {
format = "%Y-%m-%d %H:%M"
}

View File

@ -5,6 +5,7 @@ local u = require("utils")
local o = vim.o
local g = vim.g
local cmd = vim.cmd
local opt = vim.opt
require ("plugins")
@ -19,18 +20,41 @@ if u.has_plugin("cmp") then
o.showmatch = true -- show matching brackets
o.swapfile = false
o.autoread = true
o.lazyredraw = true
g.hidden = true --unload buffers when hidden
g.filetype = true -- execute autocommands based on filetype
-- Search
o.inccommand = 'nosplit' -- show substitutions incrementally
o.ignorecase = true
o.smartcase = true
opt.wildignore:append('.git/*', 'node_modules/*')
o.wildignorecase = true
o.lazyredraw = true
opt.listchars:append({
extends = "#",
eol = '',
space = '',
tab = '',
})
-- Shortmess
cmd [[set shortmess+=F]]
g.loaded_netrw = 1
g.loaded_netrwPlugin = 1
g.loaded_zipPlugin = 1
g.loaded_zip = 1
cmd [[set mouse=a]] -- enable mouse interaction
cmd [[set undofile]]
cmd [[set fcs=eob:\ ]] --disable showing ~ in empty lines
cmd [[command Format :lua vim.lsp.buf.formatting()]]
cmd [[set noshowmode]] --to get rid of thing like --INSERT--
cmd [[set noshowcmd]] --to get rid of display of last command
cmd [[set shortmess+=F]] --to get rid of the file name displayed in the command line bar
cmd [[set noruler]]
g.ale_fixers = {"prettier", "eslint"}
@ -129,6 +153,7 @@ if u.has_plugin("cmp") then
-- Toggleterm / Lazygit setup
require "lazy-git"
require "autocommands"
-- Setup rest.vim
require("rest-nvim").setup(

View File

@ -0,0 +1,13 @@
local cmd = vim.cmd;
cmd [[
augroup auto_format
au!
au BufWritePre * silent! lua vim.lsp.buf.formatting_sync(nil, 300)<CR>
augroup END
augroup highlight_yank
au!
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 150 }
augroup END
]]

View File

@ -18,8 +18,10 @@ local function on_attach(client)
-- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then
vim.cmd [[command Format :lua vim.lsp.buf.formatting()<CR>]]
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
elseif client.resolved_capabilities.document_range_formatting then
vim.cmd [[command Format :lua vim.lsp.buf.range_formatting()<CR>]]
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
end

View File

@ -20,6 +20,8 @@ return require("packer").startup(function()
use "lukas-reineke/indent-blankline.nvim"
use "karb94/neoscroll.nvim"
use "tpope/vim-fugitive"
-- Code Navigation
use "dense-analysis/ale"
use "nathanmsmith/nvim-ale-diagnostic"
@ -53,7 +55,7 @@ return require("packer").startup(function()
use "ellisonleao/glow.nvim"
-- Autoformat
use "sbdchd/neoformat"
--use "sbdchd/neoformat"
-- General Popup Window
use "akinsho/nvim-toggleterm.lua"

View File

@ -33,8 +33,8 @@ input * {
}
smart_gaps off
gaps inner 0
gaps outer 10
gaps inner 5
gaps outer 5
default_border none
@ -130,17 +130,17 @@ output * bg `find ~/.customization/background -type f | shuf -n 1` fill
#
# Workspaces:
#
set $ws1 " Code"
set $ws1 "1:  Code"
assign [class="Alacritty"] $ws1
set $ws2 " Browser"
set $ws2 "2:  Browser"
assign [class="Firefox"] $ws2
assign [class="Chromium"] $ws2
assign [class="Google-chrome-beta"] $ws2
assign [class="Google-chrome"] $ws2
set $ws3 " Music"
set $ws3 "3:  Music"
assign [class="Spotify"] $ws3
assign [class="spotify"] $ws3
set $ws4 " Chat"
set $ws4 "4:  Chat"
# Switch to workspace
bindsym $mod+1 workspace $ws1

20
configs/waybar/capture_mp3.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
cd "$(dirname "$0")"
arecord -f cd -t raw -d 4 -q | lame -r -q - output.mp3 2>/dev/null
if [ ! -f "./output.mp3" ]; then
exit 0
fi
JSON=$(songrec audio-file-to-recognized-song output.mp3)
RETRYMS=$(echo $JSON | jq '.retryms')
if [ $RETRYMS != null ]; then
echo $(expr $RETRYMS / 1000)
else
SONG=$(echo $JSON | tr '\r\n' ' ' | jq '.track.share.subject')
echo $SONG
rm -rf output.mp3
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
CONFIG_FILES="$HOME/.config/waybar/config $HOME/.config/waybar/style.css"
CONFIG_FILES="$HOME/.config/waybar/config $HOME/.config/waybar/*.css $HOME/.config/waybar/*.sh"
killall waybar;

34
configs/waybar/mediaplayer.py Normal file → Executable file
View File

@ -3,20 +3,23 @@ import argparse
import logging
import sys
import signal
import time
import gi
import json
gi.require_version('Playerctl', '2.0')
from gi.repository import Playerctl, GLib
import subprocess
logger = logging.getLogger(__name__)
playerVisible = False
def write_output(text, player):
def write_output(text, player_name):
logger.info('Writing output')
output = {'text': text,
'class': 'custom-' + player.props.player_name,
'alt': player.props.player_name}
output = {'text': text.replace("&", "&amp;"),
'class': 'custom-' + player_name,
'alt': player_name}
sys.stdout.write(json.dumps(output) + '\n')
sys.stdout.flush()
@ -43,18 +46,32 @@ def on_metadata(player, metadata, manager):
if player.props.status != 'Playing' and track_info:
track_info = '' + track_info
write_output(track_info, player)
write_output(track_info, player.props.player_name)
def update_song():
global playerVisible
while not playerVisible:
result = subprocess.run("./capture_mp3.sh",stdout=subprocess.PIPE)
resultString = result.stdout.decode("utf-8")
print(resultString);
write_output(resultString, "Spotify")
time.sleep(6)
def on_player_appeared(manager, player, selected_player=None):
global playerVisible
if player is not None and (selected_player is None or player.name == selected_player):
playerVisible = True
init_player(manager, player)
else:
logger.debug("New player appeared, but it's not the selected player, skipping")
def on_player_vanished(manager, player):
global playerVisible
logger.info('Player has vanished')
playerVisible = False
update_song()
sys.stdout.write('\n')
sys.stdout.flush()
@ -64,6 +81,7 @@ def init_player(manager, name):
player = Playerctl.Player.new_from_name(name)
player.connect('playback-status', on_play, manager)
player.connect('metadata', on_metadata, manager)
update_song()
manager.manage_player(player)
on_metadata(player, player.props.metadata, manager)
@ -72,7 +90,7 @@ def signal_handler(sig, frame):
logger.debug('Received signal to stop, exiting')
sys.stdout.write('\n')
sys.stdout.flush()
# loop.quit()
loop.quit()
sys.exit(0)
@ -89,6 +107,7 @@ def parse_arguments():
def main():
arguments = parse_arguments()
# Initialize logging
@ -98,6 +117,7 @@ def main():
# Logging is set by default to WARN and higher.
# With every occurrence of -v it's lowered by one
logger.setLevel(max((3 - arguments.verbose) * 10, 0))
logger.setLevel(0)
# Log the sent command line arguments
logger.debug('Arguments received {}'.format(vars(arguments)))
@ -120,8 +140,8 @@ def main():
init_player(manager, player)
update_song()
loop.run()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,2 @@
#!/bin/bash

249
configs/waybar/song.json Normal file
View File

@ -0,0 +1,249 @@
{
"location": {
"altitude": 300.0,
"latitude": 45.0,
"longitude": 2.0
},
"matches": [
{
"channel": "0",
"frequencyskew": 0.00008058548,
"id": "341270538",
"offset": 148.84515625,
"timeskew": -0.0023667216
}
],
"tagid": "68982327-bef9-4ff3-a426-7fea39f7997f",
"timestamp": 95912955,
"timezone": "Europe/Paris",
"track": {
"albumadamid": "1477092467",
"artists": [
{
"adamid": "827504058",
"id": "44445618"
}
],
"genres": {
"primary": "Alternative"
},
"highlightsurls": {
"artisthighlightsurl": "https://cdn.shazam.com/video/v3/en/US/android/827504058/highlights?affiliate=mttnagencyid%3D769459046716559743%26mttnsiteid%3D125115%26mttn3pid%3Da_custom_779816081798873874%26mttnsub1%3DShazam_android_am%26mttnsub2%3D5348615A-616D-3235-3830-44754D6D5973%26itscg%3D30201%26app%3Dmusic%26itsct%3DShazam_android_am",
"relatedhighlightsurl": "https://cdn.shazam.com/video/v3/en/US/android/44445618/artist-similarities-id-44445618/relatedhighlights?max_artists=5&affiliate=mttnagencyid%3D769459046716559743%26mttnsiteid%3D125115%26mttn3pid%3Da_custom_779816081798873874%26mttnsub1%3DShazam_android_am%26mttnsub2%3D5348615A-616D-3235-3830-44754D6D5973%26itscg%3D30201%26app%3Dmusic%26itsct%3DShazam_android_am"
},
"hub": {
"actions": [
{
"id": "1477092472",
"name": "apple",
"type": "applemusicplay"
},
{
"name": "apple",
"type": "uri",
"uri": "https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview115/v4/17/c4/ff/17c4ff80-8823-5ce9-fa5a-0c1892129e3b/mzaf_15603304596709002890.plus.aac.ep.m4a"
}
],
"displayname": "APPLE MUSIC",
"explicit": false,
"image": "https://images.shazam.com/static/icons/hub/android/v5/applemusic_{scalefactor}.png",
"options": [
{
"actions": [
{
"name": "hub:applemusic:deeplink",
"type": "intent",
"uri": "intent://music.apple.com/us/album/nothings-older-than-yesterday/1477092467?i=1477092472&mttnagencyid=769459046716559743&mttnsiteid=125115&mttn3pid=a_custom_779816081798873874&mttnsub1=Shazam_android_am&mttnsub2=5348615A-616D-3235-3830-44754D6D5973&itscg=30201&app=music&itsct=Shazam_android_am#Intent;scheme=http;package=com.apple.android.music;action=android.intent.action.VIEW;end"
},
{
"id": "1477092472",
"name": "hub:applemusic:connect",
"type": "applemusicconnect",
"uri": "https://unsupported.shazam.com"
},
{
"name": "hub:applemusic:androidstore",
"type": "uri",
"uri": "https://play.google.com/store/apps/details?id=com.apple.android.music&referrer=utm_source=https%3A%2F%2Fmusic.apple.com%2Fsubscribe%3Fmttnagencyid%3D769459046716559743%26mttnsiteid%3D125115%26mttn3pid%3Da_custom_779816081798873874%26mttnsub1%3DShazam_android_am%26mttnsub2%3D5348615A-616D-3235-3830-44754D6D5973%26itscg%3D30201%26app%3Dmusic%26itsct%3DShazam_android_am"
}
],
"beacondata": {
"providername": "applemusic",
"type": "open"
},
"caption": "OPEN",
"colouroverflowimage": false,
"image": "https://images.shazam.com/static/icons/hub/android/v5/overflow-open-option_{scalefactor}.png",
"listcaption": "Open in Apple Music",
"overflowimage": "https://images.shazam.com/static/icons/hub/android/v5/applemusic-overflow_{scalefactor}.png",
"providername": "applemusic",
"type": "open"
}
],
"providers": [
{
"actions": [
{
"name": "hub:spotify:searchdeeplink",
"type": "uri",
"uri": "spotify:search:Nothing%27s%20Older%20Than%20Yesterday%20Cari%20Cari"
}
],
"caption": "Open in Spotify",
"images": {
"default": "https://images.shazam.com/static/icons/hub/android/v5/spotify_{scalefactor}.png",
"overflow": "https://images.shazam.com/static/icons/hub/android/v5/spotify-overflow_{scalefactor}.png"
},
"type": "SPOTIFY"
},
{
"actions": [
{
"name": "hub:youtubemusic:androiddeeplink",
"type": "uri",
"uri": "https://music.youtube.com/search?q=Nothings+Older+Than+Yesterday+Cari+Cari&feature=shazam"
}
],
"caption": "Open in YouTube Music",
"images": {
"default": "https://images.shazam.com/static/icons/hub/android/v5/youtubemusic_{scalefactor}.png",
"overflow": "https://images.shazam.com/static/icons/hub/android/v5/youtubemusic-overflow_{scalefactor}.png"
},
"type": "YOUTUBEMUSIC"
},
{
"actions": [
{
"name": "hub:deezer:searchdeeplink",
"type": "uri",
"uri": "deezer-query://www.deezer.com/play?query=%7Btrack%3A%27Nothing%5C%27s+Older+Than+Yesterday%27%20artist%3A%27Cari+Cari%27%7D"
}
],
"caption": "Open in Deezer",
"images": {
"default": "https://images.shazam.com/static/icons/hub/android/v5/deezer_{scalefactor}.png",
"overflow": "https://images.shazam.com/static/icons/hub/android/v5/deezer-overflow_{scalefactor}.png"
},
"type": "DEEZER"
}
],
"type": "APPLEMUSIC"
},
"images": {
"background": "https://is3-ssl.mzstatic.com/image/thumb/Music114/v4/62/5c/d7/625cd78a-6d55-3128-1a55-894d244800c9/pr_source.png/800x800cc.jpg",
"coverart": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b8/c5/3c/b8c53c9c-489f-3bec-1b25-c232368a1fac/rls00069784.jpg/400x400cc.jpg",
"coverarthq": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b8/c5/3c/b8c53c9c-489f-3bec-1b25-c232368a1fac/rls00069784.jpg/400x400cc.jpg",
"joecolor": "b:031827p:fdf0dfs:f7831et:cbc5baq:c66e1f"
},
"isrc": "ATT801713001",
"key": "341270538",
"layout": "5",
"relatedtracksurl": "https://cdn.shazam.com/shazam/v3/en/US/android/-/tracks/track-similarities-id-341270538?startFrom=0&pageSize=20&connected=",
"sections": [
{
"metadata": [
{
"text": "Anaana",
"title": "Album"
},
{
"text": "recordJet",
"title": "Label"
},
{
"text": "2017",
"title": "Released"
}
],
"metapages": [
{
"caption": "Cari Cari",
"image": "https://is3-ssl.mzstatic.com/image/thumb/Music114/v4/62/5c/d7/625cd78a-6d55-3128-1a55-894d244800c9/pr_source.png/800x800cc.jpg"
},
{
"caption": "Nothing's Older Than Yesterday",
"image": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b8/c5/3c/b8c53c9c-489f-3bec-1b25-c232368a1fac/rls00069784.jpg/400x400cc.jpg"
}
],
"tabname": "Song",
"type": "SONG"
},
{
"beacondata": {
"commontrackid": "70387093",
"lyricsid": "19307144",
"providername": "musixmatch"
},
"footer": "Writer(s): Stephanie Widmer, Alexander Koeck
Lyrics powered by www.musixmatch.com",
"tabname": "Lyrics",
"text": [
"Waves are rolling on the beach",
"Sunlight is striking through the trees",
"Heads up, don't look back",
"On the coast of Jamaica, there ain't no looking back",
"",
"Move, nothing's older than yesterday",
"'Cause we're riding, it's just the streets and you and me",
"Heads up, don't look back!",
"On the streets of Tokyo, no looking back",
"C'mon baby, we can stay up all night",
"I stay here till sunrise",
"Come on, don't miss this ride"
],
"type": "LYRICS",
"url": "https://cdn.shazam.com/lyrics/v1/en/US/android/musixmatch/subtitles/70387093/202/1?token=d3fe124c5cfcec867f24caddbb4fb700"
},
{
"tabname": "Video",
"type": "VIDEO",
"youtubeurl": "https://cdn.shazam.com/video/v3/-/US/android/341270538/youtube/video?q=Cari+Cari+%22Nothing's+Older+Than+Yesterday%22&c=UCiL526VL2ZWT9pUuUQP52uw"
},
{
"actions": [
{
"id": "44445618",
"type": "artistposts"
},
{
"id": "44445618",
"type": "artist"
}
],
"avatar": "https://is3-ssl.mzstatic.com/image/thumb/Music114/v4/62/5c/d7/625cd78a-6d55-3128-1a55-894d244800c9/pr_source.png/800x800cc.jpg",
"id": "44445618",
"name": "Cari Cari",
"tabname": "Artist",
"toptracks": {
"url": "https://cdn.shazam.com/shazam/v3/en/US/android/-/tracks/artisttoptracks_44445618?startFrom=0&pageSize=20&connected="
},
"type": "ARTIST",
"url": "https://cdn.shazam.com/digest/v1/en/US/android/artist/44445618/recentpost",
"verified": false
},
{
"tabname": "Related",
"type": "RELATED",
"url": "https://cdn.shazam.com/shazam/v3/en/US/android/-/tracks/track-similarities-id-341270538?startFrom=0&pageSize=20&connected="
}
],
"share": {
"avatar": "https://is3-ssl.mzstatic.com/image/thumb/Music114/v4/62/5c/d7/625cd78a-6d55-3128-1a55-894d244800c9/pr_source.png/800x800cc.jpg",
"href": "https://www.shazam.com/track/341270538/nothings-older-than-yesterday",
"html": "https://www.shazam.com/snippets/email-share/341270538?lang=en&country=US",
"image": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b8/c5/3c/b8c53c9c-489f-3bec-1b25-c232368a1fac/rls00069784.jpg/400x400cc.jpg",
"snapchat": "https://www.shazam.com/partner/sc/track/341270538",
"subject": "Nothing's Older Than Yesterday - Cari Cari",
"text": "I used Shazam to discover Nothing's Older Than Yesterday by Cari Cari.",
"twitter": "I used @Shazam to discover Nothing's Older Than Yesterday by Cari Cari."
},
"subtitle": "Cari Cari",
"title": "Nothing's Older Than Yesterday",
"type": "MUSIC",
"url": "https://www.shazam.com/track/341270538/nothings-older-than-yesterday",
"urlparams": {
"{trackartist}": "Cari+Cari",
"{tracktitle}": "Nothing%27s+Older+Than+Yesterday"
}
}
}