From 3042da1a97c667d44475443612995da3e06eb3d2 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Wed, 27 Oct 2021 20:37:42 +0200 Subject: [PATCH] feat: add polybar config --- README.md | 2 + configs/.Xresources | 78 ++++++++++++++++++ configs/.p10k.zsh | 6 +- configs/i3.conf | 53 ++++++------ configs/init.lua | 129 ++++++++++++------------------ configs/lua/keymappings.lua | 22 ++++- configs/lua/lsp-utils.lua | 12 +-- configs/lua/lspinstaller-conf.lua | 14 ++++ configs/lua/plugins.lua | 3 +- configs/lua/treesitter-conf.lua | 26 ++++++ configs/polybar-launch.sh | 13 +++ configs/polybar.conf | 120 +++++++++++++++++++++++++++ 12 files changed, 353 insertions(+), 125 deletions(-) create mode 100644 configs/.Xresources create mode 100644 configs/lua/lspinstaller-conf.lua create mode 100644 configs/lua/treesitter-conf.lua create mode 100755 configs/polybar-launch.sh create mode 100644 configs/polybar.conf diff --git a/README.md b/README.md index 9396944..44de1b0 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ - [ZSH](https://www.zsh.org/) + [oh-my-zsh](https://ohmyz.sh/) + [p10k](https://github.com/romkatv/powerlevel10k) - [asdf version manager](https://asdf-vm.com/#/) - [pre-configured](./configs/init.lua) [neovim](https://neovim.io/) +- [tmux](https://github.com/tmux/tmux) +- [i3](https://i3wm.org) - 1 line installation ## Installation diff --git a/configs/.Xresources b/configs/.Xresources new file mode 100644 index 0000000..5e8ab96 --- /dev/null +++ b/configs/.Xresources @@ -0,0 +1,78 @@ +Xft.autohint: 0 +Xft.dpi: 96 +Xft.antialias: true +Xft.rgba: rgb +Xft.hinting: true +Xft.hintstyle: hintslight +Xft.lcdfilter: lcddefault + +URxvt.font: xft:FiraMono Nerd Font:size=11:antialias=true +URxvt.boldFont: xft:FiraMono Nerd Font:bold:size=11:antialias=true +URxvt.italicFont: xft:FiraMono Nerd Font:italic:size=11:antialias=true + +URxvt.letterSpace: -1 +URxvt.lineSpace: 0 +URxvt.geometry: 92x24 +URxvt.internalBorder: 10 +URxvt.externalBorder: 0 +URxvt.cursorBlink: true +URxvt.cursorUnderline: false +URxvt.saveline: 2048 +URxvt.scrollBar: false +URxvt.scrollBar_right: false +URxvt.urgentOnBell: true +URxvt.depth: 24 +URxvt.imLocale: en_US.utf8 +URxvt.perl-ext-common: default,matcher,font-size +URxvt.font-size.step: 2 + +! Resize Text +URxvt.keysym.C-Up: font-size:increase +URxvt.keysym.C-Down: font-size:decrease + +! Enable Copy/Paste +Rxvt.iso14755: false +URxvt.iso14755_52: false +URxvt.keysym.Shift-Control-V: eval:paste_clipboard +URxvt.keysym.Shift-Control-C: eval:selection_to_clipboard + +! margins +*.gap: 6 + +! special +*.foreground: #c0c5ce +*.background: #2b303b +*.cursorColor: #c0c5ce + +! black +*.color0: #2b303b +*.color8: #65737e + +! red +*.color1: #bf616a +*.color9: #bf616a + +! green +*.color2: #a3be8c +*.color10: #a3be8c + +! yellow +*.color3: #ebcb8b +*.color11: #ebcb8b + +! blue +*.color4: #8fa1b3 +*.color12: #8fa1b3 + +! magenta +*.color5: #b48ead +*.color13: #b48ead + +! cyan +*.color6: #96b5b4 +*.color14: #96b5b4 + +! white +*.color7: #c0c5ce +*.color15: #eff1f5 + diff --git a/configs/.p10k.zsh b/configs/.p10k.zsh index 2687d3b..2d944d7 100644 --- a/configs/.p10k.zsh +++ b/configs/.p10k.zsh @@ -80,11 +80,11 @@ # Red prompt symbol if the last command failed. typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=$red # Default prompt symbol. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='>' # Prompt symbol in command vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='>' # Prompt symbol in visual vi mode is the same as in command mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='❮' + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='>' # Prompt symbol in overwrite vi mode is the same as in command mode. typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=false diff --git a/configs/i3.conf b/configs/i3.conf index aef4272..ad0a13c 100644 --- a/configs/i3.conf +++ b/configs/i3.conf @@ -104,8 +104,8 @@ bindsym $mod+a focus parent # Define names for default workspaces for which we configure key bindings later on. # We use variables to avoid repeating the names in multiple places. -set $ws1 "1:  Terminal" -set $ws2 "2:  FireFox" +set $ws1 "1: Terminal" +set $ws2 "2: Browser" set $ws3 "3" set $ws4 "4" set $ws5 "5" @@ -171,31 +171,20 @@ mode "resize" { bindsym $mod+r mode "default" } -set $bg-color #2f343f -set $inactive-bg-color #2f343f -set $text-color #f3f4f5 -set $inactive-text-color #676E7D -set $urgent-bg-color #E53935 +for_window [class="^.*"] border pixel 2 +set_from_resource $gap i3wm.gap 7 +set $bg-color #2f343f +set $inactive-bg-color #2f343f +set $text-color #f3f4f5 +set $inactive-text-color #676E7D +set $urgent-bg-color #E53935 + +gaps inner $gap +gaps outer 0 bindsym $mod+r mode "resize" -# Start i3bar to display a workspace bar (plus the system information i3status -# finds out, if available) -# bar -bar { - status_command i3status - strip_workspace_numbers yes - colors { - background $bg-color - separator #757575 - # border background text - focused_workspace $bg-color $bg-color $text-color - inactive_workspace $inactive-bg-color $inactive-bg-color $inactive-text-color - urgent_workspace $urgent-bg-color $urgent-bg-color $text-color - } -} - #bindsym $mod+d exec rofi -show run -lines 3 -hide-scrollbar 1 -opacity "50" -width 30 -theme Arc-Dark -font "System San Francisco Display 10" bindsym $mod+d exec dmenu_run @@ -204,15 +193,21 @@ bindsym $mod+Tab exec rofi -show window -lines 5 -opacity "50" -width 30 -theme # Always set the keymap to de exec_always "setxkbmap de" - +exec_always --no-startup-id $HOME/.config/polybar/launch.sh # Bind window+l to lock the screen bindsym $mod+e exec nautilus -exec_always feh --bg-scale /home/users/user/.customize/wallpapers/fakurian-design.jpg +bindsym $mod+c exec gnome-control-center + +exec_always feh --bg-scale /home/users/user/customize/wallpapers/fakurian-design.jpg + +exec_always systembus-notify +exec_always earlyoom -n +exec --no-startup-id "compton -b -c" # window colors # border background text indicator -client.focused $bg-color $bg-color $text-color #00ff00 -client.unfocused $inactive-bg-color $inactive-bg-color $inactive-text-color #00ff00 -client.focused_inactive $inactive-bg-color $inactive-bg-color $inactive-text-color #00ff00 -client.urgent $urgent-bg-color $urgent-bg-color $text-color #00ff00 +client.focused $bg-color $bg-color $text-color #e8e8e8 +client.unfocused $inactive-bg-color $inactive-bg-color $inactive-text-color #e8e8e8 +client.focused_inactive $inactive-bg-color $inactive-bg-color $inactive-text-color #ffff00 +client.urgent $urgent-bg-color $urgent-bg-color $text-color #ffff00 diff --git a/configs/init.lua b/configs/init.lua index b4f1a4a..26828ec 100644 --- a/configs/init.lua +++ b/configs/init.lua @@ -10,32 +10,40 @@ require ("plugins") if u.has_plugin("cmp") then -- Global options - o.number = true + o.number = true -- show line number o.tabstop = 2 o.shiftwidth = 2 -- Indents will have a width of 4 o.softtabstop = 2 -- Sets the number of columns for a TAB o.expandtab = false -- Dont expand TABs to spaces o.autoindent = true - cmd [[set mouse=a]] - cmd [[set undofile]] - cmd [[set fcs=eob:\ ]] + o.showmatch = true -- show matching brackets + o.swapfile = false + g.hidden = true --unload buffers when hidden + g.filetype = true -- execute autocommands based on filetype + + cmd [[set mouse=a]] -- enable mouse interaction + cmd [[set undofile]] + cmd [[set fcs=eob:\ ]] --disable showing ~ in empty lines + 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]] - -- Apply Theme + -- Enable Theming / Syntax o.syntax = "enable" o.termguicolors = true - --g.NERDTreeShowHidden = true - --g.NERDTreeAutoDeleteBuffer = true - --g.NERDTreeMinimalUI = true - --g.NERDTreeDirArrows = true - -- g.NERDTreeCustomOpenArgs = {file = {where = "t"}} + cmd("colorscheme material") + g.material_terminal_italics = 1 + g.material_theme_style = "darker" + -- Remove background color + require("transparent").setup({enable = true}) + cmd("highlight Normal guibg=none") + cmd("highlight NonText guibg=none") - g.nvim_tree_root_folder_modifier = ":~:." - g.nvim_tree_special_files = {} + -- Configure nvim-tree + g.nvim_tree_special_files = {} g.nvim_tree_icons = { default = "", symlink = "", @@ -49,8 +57,8 @@ if u.has_plugin("cmp") then ignored = "◌" }, folder = { - arrow_open = "", - arrow_closed = "", + arrow_open = " ", + arrow_closed = " ", default = "", open = "", empty = "", @@ -66,20 +74,33 @@ if u.has_plugin("cmp") then } } - g.hidden = true - g.filetype = true - g.material_terminal_italics = 1 - g.material_theme_style = "darker" + require("nvim-tree").setup { + auto_open = 1, + gitignore = 1, + group_empty = 1, + hijack_cursor = 1, + update_focused_file = { + enable = false, + }, + diagnostics = { + enable = true + }, + view = { + auto_resize = true, + hide_root_folder = true, + winopts = { + signcolumn = "no" + } + } + } + require('nvim-tree.view').View.winopts.signcolumn = 'no' + + -- Configure Wiki g.wiki_root = "~/Notes" g.wiki_filetypes = {"md"} g.wiki_link_extension = ".md" - cmd("colorscheme material") - -- Remove background color - require("transparent").setup({enable = true}) - cmd("highlight Normal guibg=none") - cmd("highlight NonText guibg=none") - - -- KeyBindings + + -- KeyBindings g.mapleader = " " require "keymappings" @@ -97,58 +118,12 @@ if u.has_plugin("cmp") then require'nvim-autopairs'.setup() -- Treesitter config - local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() - parser_configs.http = { - install_info = { - url = "https://github.com/NTBBloodbath/tree-sitter-http", - files = {"src/parser.c"}, - branch = "main" - } - } - require "nvim-treesitter.configs".setup { - ensure_installed = { - "bash", - "yaml", - "http", - "svelte", - "css", - "svelte", - "typescript", - "javascript", - "go", - "lua", - "yaml" - }, - highlight = {enable = true} - } - -- Toggleterm / Lazygit setup + require "treesitter-conf" + + -- Toggleterm / Lazygit setup require "lazy-git" - require("nvim-tree").setup { - auto_open = 1, - gitignore = 1, - group_empty = 1, - diagnostics = { - enable = true - }, - view = { - hide_root_folder = true, - winopts = { - signcolumn = "no" - } - } - } - -- Autocommands - --[[ u.create_augroup(]] - --[[{]] - --[[{"StdinReadPre", "*", "let s:std_in=1"},]] - --[[{"VimEnter", "*", "if argc() == 0 && !exists('s:std_in') | NERDTree | endif"},]] - --[[{"BufEnter", "*", 'if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif'},]] - --[[{"BufWinEnter", "*", "if getcmdwintype() == '' | silent NERDTreeMirror | endif"}]] - --[[},]] - --[["Nerdtree"]] - --[[)]] -- Setup rest.vim require("rest-nvim").setup( { @@ -167,12 +142,12 @@ if u.has_plugin("cmp") then ) -- Autocompletion Setup - o.completeopt = "menuone,noselect" + o.completeopt = "menuone,noselect,noinsert" require "autocomplete" -- LSP Config - require "lspinstall".setup() - require "lsp-utils" + require "lspinstaller-conf" + require "lsp-utils" else vim.cmd[[PackerSync]] diff --git a/configs/lua/keymappings.lua b/configs/lua/keymappings.lua index 0257612..d1c71f7 100644 --- a/configs/lua/keymappings.lua +++ b/configs/lua/keymappings.lua @@ -4,16 +4,30 @@ local g = vim.g local options = {noremap = true} local remap = {noremap = false} -map("n", "", "", remap) -map("n", " ", "", remap) +--map("n", "", "", remap) +--map("n", " ", "", remap) g.mapleader = " " map("n", "", ":Telescope find_files", options) --map("n", "", ":Telescope grep_string", options) -map("n", "", ":Telescope live_grep", options) +map("n", "", ":Telescope live_grep", options) map("n", "c", ":CodeActionMenu", remap) +-- LSP Functionality + map("n", "gD", "lua vim.lsp.buf.declaration()", options) + map("n", "gd", "lua vim.lsp.buf.definition()", options) + map("n", "gr", "lua vim.lsp.buf.references()", options) + map("n", "gi", "lua vim.lsp.buf.implementation()", options) + map("n", "K", "lua vim.lsp.buf.hover()", options) + map("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", options) + map("n", "rn", "lua vim.lsp.buf.rename()", options) + map("n", "", "lua vim.lsp.buf.code_action()", options) + map("n", "[d", "lua vim.lsp.diagnostic.goto_prev()", options) + map("n", "]d", "lua vim.lsp.diagnostic.goto_next()", options) + + + -- Navigate Buffers map("n", "", "h", options) map("n", "", "j", options) @@ -21,7 +35,7 @@ map("n", "", "k", options) map("n", "", "l", options) -- Find file in NvimTree -map("n", "", ":NvimTreeFindFile", options) +map("n", "f", ":NvimTreeFindFile", options) -- I aint no weak boy map("n", "", ":echo 'No Left for you'", options) diff --git a/configs/lua/lsp-utils.lua b/configs/lua/lsp-utils.lua index b4356f0..64ee9c4 100644 --- a/configs/lua/lsp-utils.lua +++ b/configs/lua/lsp-utils.lua @@ -15,18 +15,8 @@ local function on_attach(client) -- Mappings. local opts = {noremap = true, silent = true} - buf_set_keymap("n", "gD", "lua vim.lsp.buf.declaration()", opts) - buf_set_keymap("n", "gd", "lua vim.lsp.buf.definition()", opts) - buf_set_keymap("n", "gr", "lua vim.lsp.buf.references()", opts) - buf_set_keymap("n", "gi", "lua vim.lsp.buf.implementation()", opts) - buf_set_keymap("n", "K", "lua vim.lsp.buf.hover()", opts) - buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) - buf_set_keymap("n", "rn", "lua vim.lsp.buf.rename()", opts) - buf_set_keymap("n", "", "lua vim.lsp.buf.code_action()", opts) - buf_set_keymap("n", "[d", "lua vim.lsp.diagnostic.goto_prev()", opts) - buf_set_keymap("n", "]d", "lua vim.lsp.diagnostic.goto_next()", opts) - -- Set some keybinds conditional on server capabilities + -- Set some keybinds conditional on server capabilities if client.resolved_capabilities.document_formatting then buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) elseif client.resolved_capabilities.document_range_formatting then diff --git a/configs/lua/lspinstaller-conf.lua b/configs/lua/lspinstaller-conf.lua new file mode 100644 index 0000000..81bd493 --- /dev/null +++ b/configs/lua/lspinstaller-conf.lua @@ -0,0 +1,14 @@ +local lsp_installer = require("nvim-lsp-installer") + +lsp_installer.on_server_ready(function(server) + local opts = {} + + -- (optional) Customize the options passed to the server + -- if server.name == "tsserver" then + -- opts.root_dir = function() ... end + -- end + + -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart) + server:setup(opts) + vim.cmd [[ do User LspAttachBuffers ]] +end) diff --git a/configs/lua/plugins.lua b/configs/lua/plugins.lua index 6053057..f53e3ae 100644 --- a/configs/lua/plugins.lua +++ b/configs/lua/plugins.lua @@ -16,6 +16,7 @@ return require("packer").startup(function() use "kyazdani42/nvim-web-devicons" use "kyazdani42/nvim-tree.lua" use "nvim-lua/popup.nvim" + use "mhinz/vim-startify" -- Code Navigation use "dense-analysis/ale" @@ -32,7 +33,7 @@ return require("packer").startup(function() -- Syntax / Autocomplete use "preservim/nerdcommenter" use "neovim/nvim-lspconfig" - use "kabouzeid/nvim-lspinstall" + use "williamboman/nvim-lsp-installer" use "nvim-lua/lsp-status.nvim" use "hrsh7th/nvim-cmp" use "hrsh7th/cmp-nvim-lsp" diff --git a/configs/lua/treesitter-conf.lua b/configs/lua/treesitter-conf.lua new file mode 100644 index 0000000..6056b6f --- /dev/null +++ b/configs/lua/treesitter-conf.lua @@ -0,0 +1,26 @@ +local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() + parser_configs.http = { + install_info = { + url = "https://github.com/NTBBloodbath/tree-sitter-http", + files = {"src/parser.c"}, + branch = "main" + } + } + require "nvim-treesitter.configs".setup { + ensure_installed = { + "bash", + "yaml", + "http", + "svelte", + "css", + "svelte", + "typescript", + "javascript", + "go", + "lua", + "yaml" + }, + highlight = {enable = true} + } + + diff --git a/configs/polybar-launch.sh b/configs/polybar-launch.sh new file mode 100755 index 0000000..f9b9e66 --- /dev/null +++ b/configs/polybar-launch.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Terminate already running bar instances +killall -q i3bar +killall -q polybar + +# Wait until the processes have been shut down +while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + +# Launch Polybar, using default config location ~/.conig/polybar/config +polybar base & + +echo "Polybar launched..." diff --git a/configs/polybar.conf b/configs/polybar.conf new file mode 100644 index 0000000..df304ac --- /dev/null +++ b/configs/polybar.conf @@ -0,0 +1,120 @@ +;-------------------------------------------- +; settings ; +;-------------------------------------------- + +[settings] + screenchange-reload = true + +;-------------------------------------------- +; colors ; +;-------------------------------------------- + +[colors] + + bar_bg = ${xrdb:color0} + bar_fg = ${xrdb:color7} + + border_col = ${xrdb:color0} + + modules_bg = ${xrdb:color7} + modules_fg = ${xrdb:color0} + + mod_bg = ${xrdb:color7} + + modules_prefix_bg = ${xrdb:color7} + modules_prefix_fg = ${xrdb:color0} + + urgent_bg = ${xrdb:color1} + focused_bg = ${xrdb:color10} + + essid_p_bg = ${xrdb:color6} + down_p_bg = #5e606c + cpu_p_bg = ${xrdb:color5} + ram_p_bg = ${xrdb:color11} + vol_p_bg = #637b81 + bright_p_bg = #c29f6f + battery_p_bg = ${xrdb:color9} + time_p_bg = ${xrdb:color10} + +;-------------------------------------------- +; bars ; +;-------------------------------------------- + +[bar/base] + dpi = 192 + width = 100% + height = 32 + offset-x = 0 + offset-y = 0 + + bottom = false + + background = ${xrdb:background} + foreground = ${xrdb:color7} + + border-bottom-size = 0 + border-top-size = ${xrdb:gap} + + border-left-size = ${xrdb:gap} + border-right-size = ${xrdb:gap} + + border-bottom-color = #000f0f0f + border-top-color = #000f0f0f + + border-left-color = #000f0f0f + border-right-color = #000f0f0f + + spacing = 0 + padding-left = 0 + padding-right = 2 + module-margin-left = 0 + + font-N = ; + font-0 = FiraMono Nerd:size=4;2 + font-1 = Font Awesome 5 Free Regular:pixelsize=14;-1 + font-2 = Font Awesome 5 Brands:pixelsize=4;2 + + fixed-center = true + + modules-left = i3 + modules-center = date + modules-right = cpu ram + +;-------------------------------------------- +; modules ; +;-------------------------------------------- +[module/date] + type = internal/date + interval = 1.0 + time = "%I:%M %p" + label = "%time%" + + format =