diff options
Diffstat (limited to '.config')
122 files changed, 17760 insertions, 0 deletions
diff --git a/.config/Code/User/keybindings.json b/.config/Code/User/keybindings.json new file mode 100644 index 0000000..9d04af3 --- /dev/null +++ b/.config/Code/User/keybindings.json @@ -0,0 +1,274 @@ +[ + { + "key": "ctrl+shift+r", + "command": "workbench.action.reloadWindow", + "when": "editorTextFocus" + }, + { + "key": "ctrl+i", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .py", + "args": { + "text": "python \"${file}\" < ./i\n" + } + }, + { + "key": "f5", + "command": "python.execInTerminal", + "when": "resourceExtname == .py", + }, + { + "key": "f5", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .dart", + "args": { + "text": "dart \"${file}\"\n" + } + }, + { + "key": "f5", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .js", + "args": { + "text": "node \"${file}\"\n" + } + }, + { + "key": "f5", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .java", + "args": { + "text": "java \"${file}\"\n" + } + }, + { + "key": "f5", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .sh", + "args": { + "text": "\"${file}\"\n" + } + }, + { + "key": "f5", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .cpp", + "args": { + "text": "g++ -g \"${file}\" -o \"${fileDirname}/${fileBasenameNoExtension}\" && \"${fileDirname}/${fileBasenameNoExtension}\"\n" + } + }, + { + "key": "f5", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .c", + "args": { + "text": "gcc -g \"${file}\" -o \"${fileDirname}/${fileBasenameNoExtension}\" && \"${fileDirname}/${fileBasenameNoExtension}\"\n" + } + }, + { + "key": "f5", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .asm", + "args": { + "text": "nasm -f elf64 \"${file}\" && ld -o \"${fileDirname}/${fileBasenameNoExtension}\" \"${fileDirname}/${fileBasenameNoExtension}.o\" && \"${fileDirname}/${fileBasenameNoExtension}\"\n" + } + }, + { + "key": "ctrl+i", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .cpp", + "args": { + "text": "g++ -g \"${file}\" -o \"${fileDirname}/${fileBasenameNoExtension}\" && \"${fileDirname}/${fileBasenameNoExtension}\" < ./i\n" + } + }, + { + "key": "ctrl+g", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .cpp", + "args": { + "text": "g++ -g \"${file}\" -o \"${fileDirname}/${fileBasenameNoExtension}\" -lgraph -lGL -lGLU -lglut && \"${fileDirname}/${fileBasenameNoExtension}\" 2>/dev/null\n" + } + }, + // { + // "key": "f5", + // "command": "workbench.action.tasks.runTask", + // "when": "resourceExtname == .cpp", + // "args": "Build and Run C++" + // }, + { + "key": "shift+f5", + "command": "workbench.action.terminal.sendSequence", + "when": "resourceExtname == .cpp", + "args": { + "text": "g++ -g \"${fileDirname}/*.cpp\" -o \"${fileDirname}/${fileBasenameNoExtension}\" && \"${fileDirname}/${fileBasenameNoExtension}\"\n" + } + }, + // { + // "key": "shift+f5", + // "command": "workbench.action.tasks.runTask", + // "when": "resourceExtname == .cpp", + // "args": "Build and Run C++ (Multiple cpp files)" + // }, + { + "key": "f4", + "command": "workbench.action.debug.continue", + "when": "inDebugMode" + }, + { + "key": "f4", + "command": "workbench.action.debug.start", + "when": "!inDebugMode" + }, + { + "key": "f4", + "command": "workbench.action.debug.start", + "when": "debuggersAvailable && !inDebugMode" + }, + { + "key": "f5", + "command": "-workbench.action.debug.continue", + "when": "inDebugMode" + }, + { + "key": "f5", + "command": "-workbench.action.debug.start", + "when": "!inDebugMode" + }, + { + "key": "f5", + "command": "-workbench.action.debug.start", + "when": "debuggersAvailable && !inDebugMode" + }, + { + "key": "shift+f4", + "command": "workbench.action.debug.stop", + "when": "inDebugMode" + }, + { + "key": "shift+f5", + "command": "-workbench.action.debug.stop", + "when": "inDebugMode" + }, + { + "key": "ctrl+v", + "command": "workbench.action.terminal.paste", + "when": "terminalFocus && terminalProcessSupported" + }, + { + "key": "ctrl+shift+v", + "command": "-workbench.action.terminal.paste", + "when": "terminalFocus && terminalProcessSupported" + }, + { + "key": "ctrl+alt+up", + "command": "editor.action.copyLinesUpAction", + "when": "editorTextFocus && !editorReadonly" + }, + { + "key": "ctrl+alt+down", + "command": "editor.action.copyLinesDownAction", + "when": "editorTextFocus && !editorReadonly" + }, + { + "key": "ctrl+shift+alt+up", + "command": "-editor.action.copyLinesUpAction", + "when": "editorTextFocus && !editorReadonly" + }, + { + "key": "ctrl+shift+alt+down", + "command": "-editor.action.copyLinesDownAction", + "when": "editorTextFocus && !editorReadonly" + }, + { + "key": "ctrl+,", + "command": "-workbench.action.openSettings" + }, + { + "key": "ctrl+,", + "command": "workbench.action.openSettingsJson" + }, + { + "key": "ctrl+i", + "command": "-editor.action.triggerSuggest", + "when": "editorHasCompletionItemProvider && textInputFocus && !editorReadonly" + }, + { + "key": "ctrl+c", + "command": "workbench.action.terminal.copySelection", + "when": "terminalFocus && terminalProcessSupported && terminalTextSelected && terminalTextSelected" + }, + { + "key": "ctrl+shift+c", + "command": "-workbench.action.terminal.copySelection", + "when": "terminalFocus && terminalProcessSupported && terminalTextSelected && terminalTextSelected" + }, + { + "key": "ctrl+k", + "command": "workbench.action.terminal.kill", + "when": "terminalIsOpen && terminalFocus" + }, + { + "key": "delete", + "command": "-workbench.action.terminal.killInstance", + "when": "terminalIsOpen && terminalTabsFocus || terminalProcessSupported && terminalTabsFocus" + }, + { + "key": "ctrl+shift+i", + "command": "-editor.action.formatDocument.none", + "when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorReadonly" + }, + { + "key": "ctrl+shift+i", + "command": "-notebook.formatCell", + "when": "editorHasDocumentFormattingProvider && editorTextFocus && inCompositeEditor && notebookEditable && !editorReadonly && activeEditor == 'workbench.editor.notebook'" + }, + { + "key": "ctrl+shift+i", + "command": "editor.action.formatDocument", + "when": "editorTextFocus" + }, + { + "key": "ctrl+shift+i", + "command": "-editor.action.formatDocument", + "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor" + }, + { + "key": "ctrl+shift+i", + "command": "workbench.action.toggleDevTools", + "when": "!editorTextFocus" + }, + { + "key": "ctrl+shift+i", + "command": "-workbench.action.toggleDevTools", + "when": "isDevelopment" + }, + { + "key": "ctrl+t", + "command": "-workbench.action.showAllSymbols" + }, + { + "key": "ctrl+t", + "command": "workbench.action.files.newUntitledFile" + }, + { + "key": "ctrl+n", + "command": "-workbench.action.files.newUntitledFile" + }, + { + "key": "ctrl+shift+m", + "command": "github.cweijan.mysql.focus" + }, + { + "key": "ctrl+shift+m", + "command": "-workbench.actions.view.problems", + "when": "workbench.panel.markers.view.active" + }, + { + "key": "ctrl+shift+0", + "command": "workbench.action.zoomReset" + }, + { + "key": "ctrl+numpad0", + "command": "-workbench.action.zoomReset" + } +] diff --git a/.config/Code/User/settings.json b/.config/Code/User/settings.json new file mode 100644 index 0000000..d7bae40 --- /dev/null +++ b/.config/Code/User/settings.json @@ -0,0 +1,733 @@ +{ + "workbench.colorCustomizations": { + "[Chromodynamics]": { + "terminal.background": "#060606", + "terminal.foreground": "#e0e0e0", + "terminal.selectionBackground": "#555555", + "titleBar.activeBackground": "#020202", + "titleBar.activeForeground": "#e0e0e0", + "titleBar.inactiveBackground": "#020202", + "titleBar.inactiveForeground": "#e0e0e0", + "tab.inactiveBackground": "#0b0b0b", + "editor.background": "#060606", + "editor.findMatchBorder": "#0c0c0d", + "editor.findMatchHighlightBorder": "#0c0c0d", + "editor.lineHighlightBackground": "#060606", + "editor.selectionBackground": "#222222", + "editor.selectionHighlightBackground": "#e4dddd", + "editor.selectionHighlightBorder": "#0c0c0d", + "editorGroupHeader.tabsBackground": "#0b0b0b", + "editorGutter.background": "#000000", + "sideBar.background": "#060606", + "sideBarSectionHeader.background": "#0b0b0b", + "statusBar.background": "#060606" + }, + "[Sweet Dracula]": { + "editorGroupHeader.tabsBackground": "#161925", + } + }, + "editor.tokenColorCustomizations": { + "[Chromodynamics]": { + "textMateRules": [ + { + "scope": [ + "constant.language.python", + "variable.parameter.function.language.special.self.python" + ], + "settings": { + "foreground": "#66D9EF" + } + }, + { + "scope": [ + "entity.name.function.operator", + "keyword.operator" + ], + "settings": { + "foreground": "#E8364F", + "fontStyle": "" + } + }, + { + "scope": [ + "punctuation.definition.template-expression.begin.js", + "punctuation.definition.template-expression.end.js" + ], + "settings": { + "foreground": "#da70d6", + "fontStyle": "italic" + } + }, + { + "scope": [ + "variable.other.readwrite.js" + ], + "settings": { + "foreground": "#c6c6c6", + "fontStyle": "" + } + } + ] + }, + "textMateRules": [ + { + "scope": [ + "entity.name.type.class", + "storage.type.class", + "storage.modifier", + "storage.type", + "constant", + "comment", + "keyword", + "invalid" + ], + "settings": { + "fontStyle": "italic" + } + } + ] + }, + // Window Settings + "window.commandCenter": false, + "window.menuBarVisibility": "toggle", + "window.newWindowDimensions": "maximized", + "window.restoreWindows": "all", + "window.title": "${activeEditorShort}${separator}${rootName}", + "window.titleBarStyle": "native", + "window.titleSeparator": " ・ ・", + "workbench.editor.enablePreviewFromQuickOpen": false, + "workbench.editor.highlightModifiedTabs": true, + "workbench.editor.restoreViewState": false, + "workbench.editor.sharedViewState": false, + "workbench.editor.showTabs": true, + "workbench.editor.tabCloseButton": "right", + "workbench.editor.tabSizing": "shrink", + "workbench.editor.untitled.hint": "hidden", + "workbench.iconTheme": "sweet-vscode-icons", + "workbench.layoutControl.type": "menu", + "workbench.list.smoothScrolling": true, + "workbench.panel.defaultLocation": "right", + "workbench.startupEditor": "none", + "workbench.statusBar.visible": true, + "workbench.editorAssociations": { + "*.ipynb": "jupyter-notebook" + }, + "workbench.reduceMotion": "off", + // Editor Settings + "editor.acceptSuggestionOnEnter": "smart", + "editor.autoClosingBrackets": "always", + "editor.bracketPairColorization.enabled": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, + "editor.colorDecorators": false, + "editor.cursorBlinking": "phase", + "editor.cursorSmoothCaretAnimation": "on", + "editor.cursorStyle": "line-thin", + "editor.detectIndentation": false, + "editor.emptySelectionClipboard": false, + "editor.fontFamily": "'Operator Mono SSm Lig Book', 'FiraCode Nerd Font', 'Hack Nerd Font Mono', 'codicon'", + "editor.fontVariations": true, + "editor.fontLigatures": "'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'zero', 'onum'", + "editor.fontSize": 12, + "editor.fontWeight": "normal", + "editor.formatOnSave": true, + "editor.formatOnType": true, + "editor.glyphMargin": true, + "editor.guides.bracketPairs": "active", + "editor.guides.bracketPairsHorizontal": "active", + "editor.guides.highlightActiveBracketPair": true, + "editor.hover.above": false, + "editor.inlayHints.enabled": "on", + "editor.inlineSuggest.enabled": true, + "editor.insertSpaces": true, + "editor.linkedEditing": true, + "editor.matchBrackets": "never", + "editor.maxTokenizationLineLength": 99999999, + "editor.minimap.enabled": false, + "editor.mouseWheelScrollSensitivity": 1.5, + "editor.occurrencesHighlight": false, + "editor.renderControlCharacters": true, + "editor.renderFinalNewline": "on", + "editor.renderLineHighlight": "gutter", + "editor.renderWhitespace": "none", + "editor.scrollbar.horizontal": "auto", + "editor.scrollbar.vertical": "auto", + "editor.selectionHighlight": true, + "editor.smoothScrolling": true, + "editor.stickyScroll.enabled": true, + "editor.stickyScroll.maxLineCount": 5, + "editor.stickyTabStops": false, + "editor.suggestSelection": "first", + "editor.suggest.insertMode": "replace", + "editor.suggest.preview": true, + "editor.suggest.snippetsPreventQuickSuggestions": false, + "editor.tabCompletion": "on", + "editor.tabSize": 4, + "editor.wordBasedSuggestions": true, + "editor.wordBasedSuggestionsMode": "matchingDocuments", + "editor.wordWrap": "on", + "editor.quickSuggestions": { + "other": "on", + "comments": "on", + "strings": "on", + }, + // Emmet Settings + "emmet.excludeLanguages": [], + "emmet.includeLanguages": { + "javascript": "javascriptreact", + "markdown": "html", + "vue-html": "html" + }, + // Explorer Settings + "explorer.compactFolders": false, + "explorer.confirmDelete": false, + "explorer.confirmDragAndDrop": false, + // Customize UI + // "customizeUI.activityBar": "bottom", + // "customizeUI.activityBarHideSettings": true, + // "customizeUI.listRowHeight": 20, + // "customizeUI.font.monospace": "CaskaydiaCove Nerd Font", + // "customizeUI.font.regular": "CaskaydiaCove Nerd Font", + // "customizeUI.fontSizeMap": { + // "13px": "12px", + // "monospace": "12px", + // "tab-title": "12px", + // "window-title": "12.5px" + // }, + // "customizeUI.titleBar": "inline", + // "customizeUI.stylesheet": { + // ":root,::after,::before": "--tab-height: 25px;--tab-radius: 8px;--ui-radius: 6px;--base-color: #bd93f9;--gradient-one: #c50ed2;--gradient-two: #8500f7;--side-pane-color: var(--vscode-editor-background);--focus-border: #3f4f81;--sash-size: 2px !important;--sash-hover-size: 2px !important;", + // ".editor-container": "-webkit-font-smoothing: antialiased;", + // ".monaco-workbench .part.editor > .content > .watermark": "display: none !important;", + // ".monaco-workbench .part.titlebar .window-controls-container .layout-dropdown-container": "margin-left: auto !important;", + // ".monaco-workbench .part.titlebar > .window-controls-container": "width: unset !important;", + // ".monaco-workbench .part.titlebar > .window-controls-container > .window-icon": "width: 30px !important;", + // ".monaco-workbench .part.titlebar > .titlebar-container .window-appicon > .home-bar-icon-badge, .monaco-workbench .part.titlebar > .titlebar-container > .window-appicon:not(.codicon)": "background-image: url(./vsc/vsc.svg) !important;", + // ".monaco-workbench .part.editor > .content .editor-group-container.empty .editor-group-letterpress": "background-image: url(./vsc/vsc-back.svg) !important;", + // ".monaco-workbench .part.editor.has-watermark > .content.empty .editor-group-container > .editor-group-letterpress": "background-position-y: 50% !important;", + // ".monaco-sash.hover:before, .monaco-sash.active:before": "background: linear-gradient(to bottom, var(--gradient-one), var(--gradient-two)) !important;", + // ".monaco-editor .squiggly-error": "background: none !important;border-bottom: 0.5px solid var(--vscode-editorError-foreground) !important;", + // ".monaco-editor .squiggly-warning": "background: none !important;border-bottom: 0.5px solid var(--vscode-editorWarning-foreground) !important;", + // ".monaco-editor .squiggly-info": "background: none !important;border-bottom: 0.5px solid var(--vscode-editorInfo-foreground) !important;", + // ".monaco-editor .squiggly-hint": "background: none !important;border-bottom: 0.5px solid var(--vscode-editorHint-foreground) !important;", + // "body.activity-bar-at-bottom .monaco-workbench .activitybar .active-item-indicator": "display: block !important;", + // ".monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.checked .active-item-indicator:before": "border: 0 !important;width: 100% !important;height: 3px !important;position: absolute !important;bottom: 0 !important;left: 0 !important;top: unset !important;background-image: linear-gradient(to top, var(--gradient-one), var(--gradient-two)) !important;border-radius: 100vmax !important;", + // ".monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab > .tab-border-bottom-container, .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab > .tab-border-top-container": "background-image: linear-gradient(to left, var(--gradient-one), var(--gradient-two)) !important;height: 3px !important;", + // ".monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .badge .badge-content": "background-image: linear-gradient(90deg, var(--gradient-one), var(--gradient-two)) !important;", + // ".monaco-workbench .part.editor > .content .editor-group-container.active > .title .tabs-container > .tab.dirty > .tab-actions .action-label:not(:hover):before, .monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.dirty > .tab-actions .action-label:not(:hover):before": "content: '' !important;", + // ".codicon-git-branch:before": "background: linear-gradient(to bottom, var(--gradient-one), var(--gradient-two)) !important;-webkit-background-clip: text !important;background-clip: text !important;color: rgba(255, 255, 255, 0.4) !important;", + // ".monaco-editor, .split-view-view .monaco-editor-background": "background: url(./vsc/pek.png) bottom right / 10% auto no-repeat scroll;", + // ".monaco-scrollable-element > .scrollbar > .slider": "border-radius: 7px !important;", + // ".monaco-scrollable-element > .scrollbar > .slider.active": "background: linear-gradient(to top, var(--gradient-one), var(--gradient-two)) !important;", + // "canvas.decorationsOverviewRuler, .monaco-scrollable-element > .scrollbar.vertical, .monaco-scrollable-element > .scrollbar.vertical > .slider": "width: 7px !important;", + // ".monaco-scrollable-element > .scrollbar.horizontal, .monaco-scrollable-element > .scrollbar.horizontal > .slider": "height: 7px !important;", + // ".monaco-scrollable-element > .scrollbar.horizontal > .slider": "width: 135px !important;", + // ".monaco-editor .monaco-hover, .monaco-editor .suggest-widget, .monaco-editor .suggest-details": "border-radius: var(--ui-radius) !important;overflow: hidden !important;box-shadow: rgb(0 0 0 / 36%) 0px 2px calc(var(--ui-radius) + 2px) !important;", + // ".pane .pane-body, .pane .pane-body .monaco-list, .pane .pane-body .monaco-list .monaco-scrollable-element, .pane .pane-body .monaco-list .monaco-scrollable-element .monaco-list-rows, .pane .pane-body .monaco-list .monaco-scrollable-element .monaco-list-rows .monaco-list-row": "overflow: visible !important;", + // ".open-editors .monaco-list .monaco-list-row": "padding-left: 0px !important;", + // ".monaco-list-row:hover, .monaco-list-row.selected, .monaco-list-row.focused": "border-radius: 0 var(--ui-radius) var(--ui-radius) 0 !important;", + // ".monaco-workbench .monaco-list:not(.element-focused):focus:before, .monaco-select-box, .monaco-select-box-dropdown-container, .monaco-select-box-dropdown-container .monaco-list-row:hover, .monaco-select-box-dropdown-container .monaco-list-row.selected, .monaco-select-box-dropdown-container .monaco-list-row.focused": "border-radius: var(--ui-radius) !important;", + // ".monaco-list-row.selected::before, .monaco-list-row.selected::after": "--ui-radius: 6px;content: '' !important;display: block !important;position: absolute !important;width: var(--ui-radius) !important;height: var(--ui-radius) !important;left: 0 !important;pointer-events: none !important;", + // ".monaco-list-row.selected::before": "top: calc(0px - var(--ui-radius)) !important;background: radial-gradient(circle at 100% 0%, transparent 70.71%, var(--side-pane-color) 29.289%) no-repeat;background-position: 100% 0%;", + // ".monaco-list-row.selected::after": "bottom: calc(0px - var(--ui-radius)) !important;background: radial-gradient(circle at 100% 100%, transparent 70.71%, var(--side-pane-color) 29.289%) no-repeat;background-position: 100% 100%;", + // ".monaco-button.monaco-text-button": "border-radius: var(--ui-radius) !important;", + // ".monaco-editor .cursors-layer.cursor-smooth-caret-animation > .cursor": "transition: all 100ms ease-out;", + // ".tab:first-child": "margin-left: var(--tab-radius) !important;", + // ".tab:last-child": "margin-right: var(--tab-radius) !important;", + // ".tab.active": "border-radius: var(--tab-radius) var(--tab-radius) 0 0 !important;", + // ".tab.dirty-border-top > .tab-border-top-container": "border-radius: var(--tab-radius) var(--tab-radius) 0 0 !important;", + // ".tab.active::before, .tab.active::after": "content: '' !important;display: block !important;box-sizing: border-box !important;position: absolute !important;z-index: 1;width: var(--tab-radius) !important;height: var(--tab-radius) !important;bottom: 0px !important;pointer-events: none !important;", + // ".tab.active::before": "left: calc(0px - var(--tab-radius)) !important;border-bottom-right-radius: var(--tab-radius) !important;box-shadow: 3px 3px 0 3px var(--vscode-editor-background) !important;", + // ".tab.active::after": "right: 0 !important;transform: translateX(var(--tab-radius)) !important;border-bottom-left-radius: var(--tab-radius) !important;box-shadow: -3px 3px 0 3px var(--vscode-editor-background) !important;", + // ".monaco-workbench .part.sidebar>.title>.title-label h2": "font-weight: bold !important;", + // "body.activity-bar-at-bottom div.monaco-grid-view > div > div > div.monaco-scrollable-element > div.split-view-container > div.split-view-view.visible > div > div > div.monaco-scrollable-element > div.split-view-container > div:nth-child(1) > div > div > div.monaco-scrollable-element > div.split-view-container > div:nth-child(2)": "height: auto !important;", + // "body.activity-bar-at-bottom .monaco-workbench .part.activitybar": "border: none !important; padding: 0px 6px 6px 6px !important;margin-top: -8px !important; background-color: var(--vscode-editor-background) !important; position: relative !important; z-index: 10 !important;", + // "body.activity-bar-at-bottom .monaco-workbench .activitybar.bordered:before": "display: none !important;", + // "body.activity-bar-at-bottom .monaco-workbench .activitybar > .content": "justify-content: center !important; border-radius: 6px; width: unset !important; border: 1px solid #3f4f818c !important;", + // "body.activity-bar-at-bottom .monaco-workbench .activitybar>.content>.composite-bar": "margin-bottom: unset !important;", + // "body.activity-bar-at-bottom .monaco-action-bar .action-item.icon > .action-label": "color: var(--vscode-editor-foreground) !important;opacity: 0.4;", + // "body.activity-bar-at-bottom .monaco-action-bar .action-item.icon.checked > .action-label": "opacity: 1 !important;", + // ".monaco-workbench .part.editor .tabs-and-actions-container .window-controls-container": "display: flex;flex-grow: 0;flex-shrink: 0;text-align: center; -webkit-app-region: no-drag; height: 100%;", + // ".monaco-workbench .part.editor .tabs-and-actions-container .window-controls-container .window-icon": "width: 30px !important;height: 30px !important; display: flex; align-items: center; justify-content: center;", + // ".monaco-workbench .part.editor .tabs-and-actions-container .window-controls-container .window-icon.window-close:hover": "background-color: #FF5555", + // }, + // Terminal Settings + "terminal.integrated.altClickMovesCursor": true, + "terminal.integrated.cursorBlinking": true, + "terminal.integrated.customGlyphs": true, + "terminal.integrated.cursorStyle": "line", + "terminal.integrated.enableMultiLinePasteWarning": false, + "terminal.integrated.fontFamily": "'CaskaydiaCove Nerd Font', 'FiraCode Nerd Font', 'Hack Nerd Font Mono'", + "terminal.integrated.fontSize": 13, + "terminal.integrated.gpuAcceleration": "auto", + "terminal.integrated.scrollback": 200000, + "terminal.integrated.smoothScrolling": true, + "terminal.integrated.tabs.enabled": false, + "terminal.integrated.tabs.enableAnimation": true, + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/usr/bin/zsh" + } + }, + "terminal.integrated.shellIntegration.enabled": false, + "terminal.integrated.shellIntegration.decorationsEnabled": "never", + // Language Settings + "[python]": { + "editor.semanticHighlighting.enabled": false + }, + "python.analysis.completeFunctionParens": true, + "python.formatting.provider": "black", + "python.formatting.blackArgs": [ + "--line-length", + "120" + ], + "python.languageServer": "Pylance", + "python.linting.ignorePatterns": [ + ".vscode/*.py", + "**/site-packages/**/*.py", + ".git" + ], + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.linting.pylintArgs": [ + "--rcfile", + "${env:HOME}/.pylintrc" + // "--load-plugins=pylint_django" + ], + "[cpp]": { + "editor.semanticHighlighting.enabled": false, + }, + "C_Cpp.default.includePath": [ + "${workspaceFolder}/**", + "/usr/include", + "/usr/local/include", + "/usr/include/c++/11.1.0" + ], + "C_Cpp.default.defines": [ + "${default}" + ], + "C_Cpp.default.compilerPath": "/usr/bin/g++", + "C_Cpp.default.cppStandard": "c++20", + "C_Cpp.default.cStandard": "c17", + "C_Cpp.default.intelliSenseMode": "gcc-x64", + "C_Cpp.default.compilerArgs": [ + "-g" + ], + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${fileDirname}/${fileBasenameNoExtension}", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb", + "preLaunchTask": "Build", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] + }, + "tasks": { + "version": "2.0.0", + "tasks": [ + { + "label": "Build", + "type": "shell", + "command": "g++ -g \"${file}\" -o \"${fileDirname}/${fileBasenameNoExtension}\"", + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build (Multiple cpp files)", + "type": "shell", + "command": "g++ -g \"${fileDirname}/*.cpp\" -o \"${fileDirname}/${fileBasenameNoExtension}\"", + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + } + } + ] + }, + "C_Cpp.autocompleteAddParentheses": true, + "C_Cpp.codeFolding": "enabled", + "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 2, ColumnLimit: 0}", + "C_Cpp.inlayHints.autoDeclarationTypes.enabled": true, + "C_Cpp.inlayHints.autoDeclarationTypes.showOnLeft": true, + "C_Cpp.inlayHints.parameterNames.enabled": true, + "C_Cpp.inlayHints.parameterNames.hideLeadingUnderscores": true, + "C_Cpp.inlayHints.parameterNames.suppressWhenArgumentContainsName": true, + "C_Cpp.inlayHints.referenceOperator.enabled": true, + "C_Cpp.inlayHints.referenceOperator.showSpace": false, + "css.format.enable": true, + "css.format.newlineBetweenRules": true, + "css.format.newlineBetweenSelectors": true, + "css.format.spaceAroundSelectorSeparator": true, + "[css]": { + "editor.tabSize": 2 + }, + "java.jdt.ls.java.home": "/usr/lib/jvm/java-11-openjdk-amd64", + "java.configuration.runtimes": [ + { + "name": "JavaSE-11", + "path": "/usr/lib/jvm/java-11-openjdk-amd64" + } + ], + "java.server.launchMode": "LightWeight", + "[html]": { + "editor.tabSize": 2 + }, + "html.autoClosingTags": true, + "html.completion.attributeDefaultValue": "singlequotes", + "[dart]": { + "editor.suggestSelection": "first", + "editor.tabCompletion": "onlySnippets", + "editor.wordBasedSuggestions": false + }, + "[javascript]": { + "editor.tabSize": 2 + }, + "javascript.autoClosingTags": true, + "javascript.suggest.autoImports": true, + "javascript.suggest.completeFunctionCalls": true, + "javascript.suggest.enabled": true, + "javascript.updateImportsOnFileMove.enabled": "always", + "javascript.validate.enable": false, + "[json]": { + "editor.tabSize": 2 + }, + "json.maxItemsComputed": 100000, + "[markdown]": { + "editor.quickSuggestions": { + "other": "on", + "comments": "on", + "strings": "on", + } + }, + "[scss]": { + "editor.tabSize": 2 + }, + "[typescript]": { + "editor.tabSize": 2 + }, + "typescript.autoClosingTags": true, + "typescript.suggest.autoImports": true, + "typescript.updateImportsOnFileMove.enabled": "always", + "typescript.validate.enable": false, + "[typescriptreact]": { + "editor.tabSize": 2, + "editor.formatOnSave": false, + }, + "js/ts.implicitProjectConfig.checkJs": true, + //Latex + "[latex]": { + "editor.formatOnSave": false + }, + // Empty-Indent Extension + "emptyIndent.highlightColor": "rgba(246,36,89,0.6)", + "emptyIndent.highlightIndent": false, + "emptyIndent.removeIndent": true, + // Github Co-pilot + "github.copilot.inlineSuggest.enable": true, + "github.copilot.enable": { + "*": true, + "yaml": false, + "plaintext": true, + "markdown": false + }, + // Gitlens + "gitlens.currentLine.enabled": true, + "gitlens.hovers.currentLine.over": "line", + "gitlens.codeLens.enabled": false, + "gitlens.statusBar.enabled": true, + // General Setting\ + "color-highlight.markRuler": false, + "color-highlight.markerType": "background", + "debug.onTaskErrors": "showErrors", + "debug.openDebug": "openOnDebugBreak", + "eslint.enable": true, + "extensions.ignoreRecommendations": true, + "files.autoSave": "onWindowChange", + "files.insertFinalNewline": true, + "files.restoreUndoStack": true, + "files.trimFinalNewlines": true, + "files.trimTrailingWhitespace": true, + "git.autofetch": true, + "grammarly.files.include": [ + "**/*.md", + "**/*.txt", + "**/*.tex", + ], + "latex-workshop.latex.autoBuild.cleanAndRetry.enabled": true, + "latex-workshop.latex.autoBuild.run": "never", + "latex-workshop.latex.clean.fileTypes": [ + "*/*.aux", + "*/*.synctex.gz" + ], + "latex-workshop.latex.outDir": "/tmp/Review-Paper/", + "latex-workshop.latex.recipe.default": "latexmk (lualatex)", + "latex-workshop.latex.recipes": [ + { + "name": "latexmk 🔃", + "tools": [ + "latexmk" + ] + }, + { + "name": "latexmk (latexmkrc)", + "tools": [ + "latexmk_rconly" + ] + }, + { + "name": "latexmk (lualatex)", + "tools": [ + "lualatexmk" + ] + }, + { + "name": "latexmk (xelatex)", + "tools": [ + "xelatexmk" + ] + }, + { + "name": "pdflatex ➞ bibtex ➞ pdflatex × 2", + "tools": [ + "pdflatex", + "bibtex", + "pdflatex", + "pdflatex" + ] + }, + { + "name": "Compile Rnw files", + "tools": [ + "rnw2tex", + "latexmk" + ] + }, + { + "name": "Compile Jnw files", + "tools": [ + "jnw2tex", + "latexmk" + ] + }, + { + "name": "tectonic", + "tools": [ + "tectonic" + ] + } + ], + "latex-workshop.latex.tools": [ + { + "name": "latexmk", + "command": "latexmk", + "args": [ + "-synctex=1", + "-interaction=nonstopmode", + "-file-line-error", + "-pdf", + "-outdir=%OUTDIR%", + "%DOC%" + ], + "env": {} + }, + { + "name": "lualatexmk", + "command": "latexmk", + "args": [ + "-synctex=1", + "-interaction=nonstopmode", + "-file-line-error", + "-lualatex", + "-outdir=%OUTDIR%", + "%DOC%" + ], + "env": {} + }, + { + "name": "xelatexmk", + "command": "latexmk", + "args": [ + "-synctex=1", + "-interaction=nonstopmode", + "-file-line-error", + "-xelatex", + "-outdir=%OUTDIR%", + "%DOC%" + ], + "env": {} + }, + { + "name": "latexmk_rconly", + "command": "latexmk", + "args": [ + "%DOC%" + ], + "env": {} + }, + { + "name": "pdflatex", + "command": "pdflatex", + "args": [ + "-synctex=1", + "-interaction=nonstopmode", + "-file-line-error", + "-output-directory=%OUTDIR%", + "%DOC%" + ], + "env": {} + }, + { + "name": "bibtex", + "command": "bibtex", + "args": [ + "%DOCFILE%" + ], + "env": {} + }, + { + "name": "rnw2tex", + "command": "Rscript", + "args": [ + "-e", + "knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')" + ], + "env": {} + }, + { + "name": "jnw2tex", + "command": "julia", + "args": [ + "-e", + "using Weave; weave(\"%DOC_EXT%\", doctype=\"tex\")" + ], + "env": {} + }, + { + "name": "jnw2texmintex", + "command": "julia", + "args": [ + "-e", + "using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")" + ], + "env": {} + }, + { + "name": "tectonic", + "command": "tectonic", + "args": [ + "--synctex", + "--keep-logs", + "%DOC%.tex" + ], + "env": {} + } + ], + "liveServer.settings.donotShowInfoMsg": true, + "liveServer.settings.donotVerifyTags": true, + "liveServer.settings.file": "404.html", + // "liveServer.settings.https": { + // "enable": true, + // "cert": "/home/proxzima/.ssh/cert/cert.pem", + // "key": "/home/proxzima/.ssh/cert/key.pem", + // "passphrase": "1234" + // }, + "liveServer.settings.useLocalIp": true, + "markdown.preview.markEditorSelection": true, + "markdown.preview.scrollEditorWithPreview": false, + "markdown.preview.scrollPreviewWithEditor": false, + "svgPreview.autoOpen": true, + "svgPreview.scaleToFit": true, + "svgPreview.style": { + "html": { + "background-position": "0 0, 13px 13px", + "background-size": "26px 26px", + "background": "rgba(255, 255, 255, 1)", + // "background-image": "linear-gradient(45deg, #141414 25%, transparent 25%, transparent 75%, #141414 75%, #141414), linear-gradient(45deg, #141414 25%, transparent 25%, transparent 75%, #141414 75%, #141414)" + } + }, + "print.folder.exclude": [ + "{bin,obj,out}", + "node_module", + "**/*.{bin,exe,dll,hex,pdb,pdf,pfx,png,jpg,gif,bmp,suo,pptx,ppt,jar,woff2,woff,ttf,eot,odt,otf,class}" + ], + "print.lineNumbers": "on", + "print.printAndClose": false, + "print.colourScheme": "XCode", + "print.alternateBrowser": true, + "print.browserPath": "/usr/bin/google-chrome", + "spellright.documentTypes": [ + "markdown", + "latex", + "plaintext" + ], + "spellright.language": [ + "en_GB" + ], + "spellright.notificationClass": "information", + "spellright.suggestionsInHints": false, + "spellright.useDocumentSymbolsInCode": true, + "telemetry.telemetryLevel": "off", + "search.exclude": { + "**/bower_components": true, + "**/*.code-search": true, + "**/node_modules": true, + "**/env": true, + "**/venv": true + }, + "files.associations": { + "*.xml": "html", + "*.svg": "html", + "*.json": "jsonc" + }, + "files.exclude": { + "**/.DS_Store": true, + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.classpath": true, + "**/.project": true, + "**/.settings": true, + "**/.factorypath": true + }, + "files.watcherExclude": { + "**/.DS_Store/**": true, + "**/.git/objects/**": true, + "**/.git/subtree-cache/**": true, + "**/.svn/**": true, + "**/.hg/**": true, + "**/CVS/**": true, + "**/node_modules/**": true, + "**/env/**": true, + "**/venv/**": true, + "env-*": true + }, + "workbench.colorTheme": "Sweet Dracula", + "security.workspace.trust.untrustedFiles": "open", + "workbench.activityBar.visible": false +} diff --git a/.config/Code/User/snippets/snippet.code-snippets b/.config/Code/User/snippets/snippet.code-snippets new file mode 100644 index 0000000..16bdfed --- /dev/null +++ b/.config/Code/User/snippets/snippet.code-snippets @@ -0,0 +1,126 @@ +{ + // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and + // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope + // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is + // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: + // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. + // Placeholders with the same ids are connected. + // Example: + "if name is main": { + "scope": "python", + "prefix": "ifn", + "body": [ + "if __name__ == '__main__':", + "\t$0" + ], + "description": "" + }, + "for in": { + "scope": "python", + "prefix": "fori", + "body": [ + "for ${1:item} in ${2:items}:", + "\t$0" + ], + "description": "" + }, + "for in range": { + "scope": "python", + "prefix": "forr", + "body": [ + "for ${1:i} in range($2):", + "\t$0" + ], + "description": "" + }, + "lambda": { + "scope": "python", + "prefix": "lamb", + "body": [ + "lambda ${1:arg} : $0", + ], + "description": "" + }, + "map input": { + "scope": "python", + "prefix": "mapi", + "body": [ + "map(${1:func}, input($2).split())" + ], + "description": "" + }, + "html boiler plate": { + "scope": "html", + "prefix": "html", + "body": [ + "<!DOCTYPE html>", + "<html lang=\"en\">", + "", + "<head>", + " <meta charset=\"utf-8\">", + " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">", + "", + " <title>${1:Basic HTML5}</title>", + " <meta name=\"author\" content=\"${2:Trevor Gray}\">", + " <meta name=\"description\" content=\"${3:HTML5 Template}\">", + "", + " <meta property=\"og:title\" content=\"${4:HTML5 Template}\">", + " <meta property=\"og:type\" content=\"website\">", + " <meta property=\"og:url\" content=\"https://$5\">", + " <meta property=\"og:description\" content=\"${6:HTML5 Template}\">", + " <meta property=\"og:image\" content=\"${7:./assets/preview.png}\">", + "", + " <link rel=\"icon\" href=\"${8:./assets/favicon.ico}\">", + " <link rel=\"icon\" href=\"${9:./assets/favicon.svg}\" type=\"image/svg+xml\">", + " <link rel=\"apple-touch-icon\" href=\"${10:./assets/apple-touch-icon.png}\">", + "", + " <link rel=\"stylesheet\" href=\"${11:./css/style.css}\">", + "", + "</head>", + "", + "<body>", + " ${0:<!-- your content here... -->}", + " <script src=\"${12:./js/main.js}\" defer></script>", + "</body>", + "", + "</html>", + ], + "description": "" + }, + "css boiler plate": { + "scope": "css", + "prefix": "css", + "body": [ + "html {", + " font-family: sans-serif;", + " font-size: 100%;", + " box-sizing: border-box;", + "}", + "", + "*, ::before, ::after {", + " box-sizing: inherit;", + "}", + "", + "html, body {", + " margin: 0;", + " padding: 0;", + " width: 100vw;", + " min-height: 100%;", + " text-rendering: optimizeLegibility;", + "}", + "" + ] + }, + "consoleLog": { + "scope": "javascript", + "prefix": "clg", + "body": "console.log(${1:object});", + "description": "Displays a message in the console" + }, + "consoleLogObject": { + "scope": "javascript", + "prefix": "clo", + "body": "console.log('${1:object} :>> ', ${1:object});", + "description": "Displays an object in the console with its name" + } +} diff --git a/.config/Code/User/spellright.dict b/.config/Code/User/spellright.dict new file mode 100644 index 0000000..94f1e64 --- /dev/null +++ b/.config/Code/User/spellright.dict @@ -0,0 +1,14 @@ +srdusr +gui +url +yara +backend +txt +Regex +github +args +grep +res +yar +shipit +json diff --git a/.config/Code/User/vsc.css b/.config/Code/User/vsc.css new file mode 100644 index 0000000..8316df0 --- /dev/null +++ b/.config/Code/User/vsc.css @@ -0,0 +1,408 @@ +/* *:not(.monaco-editor .margin):not(.monaco-editor .lines-content.monaco-editor-background):not(.monaco-editor .cursors-layer.cursor-smooth-caret-animation > .cursor):not(.monaco-scrollable-element > .scrollbar.vertical > .slider):not(.monaco-scrollable-element > .scrollbar.horizontal > .slider):not(.pane .pane-body .monaco-list .monaco-scrollable-element .monaco-list-rows) { + transition-duration: 100ms !important; +} */ + +:root, +::after, +::before { + --tab-height: 25px; + --tab-radius: 8px; + --ui-radius: 6px; + --base-color: #bd93f9; + --gradient-one: #cba6f7; + --gradient-two: #89b4fa; + --side-pane-color: var(--vscode-editor-background); + --focus-border: #3f4f81; + --sash-size: 2px !important; + --sash-hover-size: 2px !important; +} + +body > .monaco-workbench > .monaco-grid-view > .monaco-grid-branch-node > .monaco-split-view2 > .monaco-scrollable-element > .split-view-container { + background: var(--vscode-editor-background) !important; +} + +.editor-container { + -webkit-font-smoothing: antialiased; +} + +.monaco-workbench .part.titlebar .window-controls-container .window-icon, +.monaco-workbench .part.editor > .content > .watermark { + display: none !important; +} + +.monaco-workbench .part.editor .tabs-and-actions-container .window-controls-container { + display: flex; + flex-grow: 0; + flex-shrink: 0; + text-align: center; + -webkit-app-region: no-drag; + height: 100%; +} + +.monaco-workbench .part.editor .tabs-and-actions-container .window-controls-container .window-icon { + width: 30px !important; + height: 30px !important; + display: flex; + align-items: center; + justify-content: center; +} + +.monaco-workbench .part.editor .tabs-and-actions-container .window-controls-container .window-icon.window-close:hover { + background: #FF5555 !important; +} + +.monaco-workbench .part.titlebar .window-controls-container .layout-dropdown-container { + margin-left: auto !important; +} + +.monaco-workbench .part.titlebar > .window-controls-container { + width: unset !important; +} + +.monaco-workbench .part.titlebar > .window-controls-container > .window-icon { + width: 30px !important; +} + +.monaco-workbench.linux .part.titlebar > .window-title { + font-size: 12.5px !important; +} + +.monaco-workbench .part.titlebar > .titlebar-container .window-appicon > .home-bar-icon-badge, +.monaco-workbench .part.titlebar > .titlebar-container > .window-appicon:not(.codicon) { + background-image: url(./vsc/vsc.svg) !important; +} + +.monaco-workbench .part.editor > .content .editor-group-container.empty .editor-group-letterpress { + background-image: url(./vsc/vsc-back.svg) !important; +} + +.monaco-workbench .part.editor.has-watermark > .content.empty .editor-group-container > .editor-group-letterpress { + background-position-y: 50% !important; +} + +.mac, +.windows, +.linux { + /* font-family: 'CaskaydiaCove Nerd Font' !important; + --monaco-monospace-font: 'CaskaydiaCove Nerd Font' !important; */ + /* font-family: 'Delugia' !important; + --monaco-monospace-font: 'Delugia Mono' !important; */ +} + + +.monaco-workbench .part.sidebar > .title > .title-label h2 { + font-weight: bold !important; +} + +.monaco-sash.hover:before, +.monaco-sash.active:before { + background: linear-gradient(to bottom, var(--gradient-one), var(--gradient-two)) !important; +} + +/* Squiggly lines to straight lines */ + +.monaco-editor .squiggly-error { + background: none !important; + border-bottom: 0.5px solid var(--vscode-editorError-foreground) !important; +} + +.monaco-editor .squiggly-warning { + background: none !important; + border-bottom: 0.5px solid var(--vscode-editorWarning-foreground) !important; +} + +.monaco-editor .squiggly-info { + background: none !important; + border-bottom: 0.5px solid var(--vscode-editorInfo-foreground) !important; +} + +.monaco-editor .squiggly-hint { + background: none !important; + border-bottom: 0.5px solid var(--vscode-editorHint-foreground) !important; +} + +/* */ + +/* Gradient Tab border */ +body.activity-bar-at-bottom .monaco-workbench .activitybar .active-item-indicator { + display: block !important; +} + +.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.checked .active-item-indicator:before { + border: 0 !important; + width: 3px !important; + height: 100% !important; + position: absolute !important; + top: 0 !important; + left: 0 !important; + background-image: linear-gradient(to top, var(--gradient-one), var(--gradient-two)) !important; + border-radius: 100vmax !important; +} + +.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab > .tab-border-bottom-container, +.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab > .tab-border-top-container { + background-image: linear-gradient(to left, var(--gradient-one), var(--gradient-two)) !important; + height: 3px !important; + display: none !important; +} + +.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .badge .badge-content { + background-image: linear-gradient(90deg, var(--gradient-one), var(--gradient-two)) !important; +} + +/* */ + +/* Hides dirty tab white dot indicator */ + +.monaco-workbench .part.editor > .content .editor-group-container.active > .title .tabs-container > .tab.dirty > .tab-actions .action-label:not(:hover):before, +.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.dirty > .tab-actions .action-label:not(:hover):before { + content: '' !important; +} + +/* */ + +/* Git icon background */ + +.codicon-git-branch:before { + background: linear-gradient(to bottom, var(--gradient-one), var(--gradient-two)) !important; + -webkit-background-clip: text !important; + background-clip: text !important; + color: rgba(255, 255, 255, 0.4) !important; +} + +/* */ + +/* Editor Background */ + +.monaco-editor, +.split-view-view .lines-content.monaco-editor-background { + background: url(./vsc/pek.png) bottom right / 10% auto no-repeat scroll; + /*background: linear-gradient(rgba(0,0,0,.65), rgba(0,0,0,.65)), url(./vsc/bg.jpg) center center / auto 100vh no-repeat scroll;*/ +} + +/* */ + +/* Scrollbar */ +.monaco-scrollable-element > .scrollbar > .slider { + border-radius: 7px !important; +} + +.monaco-scrollable-element > .scrollbar > .slider.active { + background: linear-gradient(to top, var(--gradient-one), var(--gradient-two)) !important; +} + +canvas.decorationsOverviewRuler, +.monaco-scrollable-element > .scrollbar.vertical, +.monaco-scrollable-element > .scrollbar.vertical > .slider { + width: 7px !important; +} + +.monaco-scrollable-element > .scrollbar.vertical > .slider { + transition: all 100ms ease-out; +} + +.monaco-scrollable-element > .scrollbar.horizontal, +.monaco-scrollable-element > .scrollbar.horizontal > .slider { + height: 7px !important; +} + +.monaco-scrollable-element > .scrollbar.horizontal > .slider { + transition: all 100ms ease-out; +} + +.monaco-scrollable-element > .scrollbar.horizontal > .slider { + width: 135px !important; +} + +/* */ + +/* Rounded UI */ + +/* Suggestions */ +.monaco-editor .monaco-hover, +.monaco-editor .suggest-widget, +.monaco-editor .suggest-details { + border-radius: var(--ui-radius) !important; + overflow: hidden !important; + box-shadow: rgb(0 0 0 / 36%) 0px 2px calc(var(--ui-radius) + 2px) !important; +} + +/* Left pane selected file */ +.pane .pane-body, +.pane .pane-body .monaco-list, +.pane .pane-body .monaco-list .monaco-scrollable-element, +.pane .pane-body .monaco-list .monaco-scrollable-element .monaco-list-rows, +.pane .pane-body .monaco-list .monaco-scrollable-element .monaco-list-rows .monaco-list-row { + overflow: visible !important; +} + +.open-editors .monaco-list .monaco-list-row { + padding-left: 0px !important; +} + +.monaco-list-row:hover, +.monaco-list-row.selected, +.monaco-list-row.focused { + border-radius: 0 var(--ui-radius) var(--ui-radius) 0 !important; +} + +.monaco-workbench .monaco-list:not(.element-focused):focus:before, +.monaco-select-box, +.monaco-select-box-dropdown-container, +.monaco-select-box-dropdown-container .monaco-list-row:hover, +.monaco-select-box-dropdown-container .monaco-list-row.selected, +.monaco-select-box-dropdown-container .monaco-list-row.focused { + border-radius: var(--ui-radius) !important; +} + +.monaco-list-row.selected::before, +.monaco-list-row.selected::after { + content: '' !important; + display: block !important; + position: absolute !important; + width: var(--ui-radius) !important; + height: var(--ui-radius) !important; + left: 0 !important; + pointer-events: none !important; +} + +.monaco-list-row.selected::before { + top: calc(0px - var(--ui-radius)) !important; + background: radial-gradient(circle at 100% 0%, transparent 70.71%, var(--side-pane-color) 29.289%) no-repeat; + background-position: 100% 0%; +} + +.monaco-list-row.selected::after { + bottom: calc(0px - var(--ui-radius)) !important; + background: radial-gradient(circle at 100% 100%, transparent 70.71%, var(--side-pane-color) 29.289%) no-repeat; + background-position: 100% 100%; +} + +.monaco-button.monaco-text-button { + border-radius: var(--ui-radius) !important; +} + +/* */ + +/* Smooth cursor */ + +.monaco-editor .cursors-layer.cursor-smooth-caret-animation > .cursor { + transition: all 100ms ease-out; +} + +/* */ + +/* Active tab (Without border) */ + +..tab:first-child { + margin-left: var(--tab-radius) !important; + /* margin-left: calc(var(--tab-radius) - 2px) !important; */ +} + +..tab:last-child { + margin-right: var(--tab-radius) !important; + /* margin-right: calc(var(--tab-radius) - 2px) !important; */ +} + +..tab.active { + /* border: 2px solid var(--base-color) !important; */ + /* background-color: transparent !important; */ + /* rgb(20, 24, 34) */ + border-radius: var(--tab-radius) var(--tab-radius) 0 0 !important; + /* border-bottom: 2px solid #0c0e14 !important; */ + /* z-index: 1 !important; */ +} + +.tab.dirty-border-top > .tab-border-top-container { + border-radius: var(--tab-radius) var(--tab-radius) 0 0 !important; +} + +/* Border bottom radius*/ +..tab.active::before, +..tab.active::after { + content: '' !important; + display: block !important; + box-sizing: border-box !important; + position: absolute !important; + z-index: 1; + width: var(--tab-radius) !important; + height: var(--tab-radius) !important; + bottom: 0px !important; + /* bottom: -2px !important; */ + pointer-events: none !important; + /* border-bottom: 2px solid var(--base-color) !important; */ +} + +...tab.active::before { + left: calc(0px - var(--tab-radius)) !important; + /* transform: translateX(calc(0px - var(--tab-radius))) !important; */ + /* border-right: 2px solid var(--base-color) !important; */ + border-bottom-right-radius: var(--tab-radius) !important; + /* box-shadow: 3px 3px 0 3px var(--tab-color) !important; */ + box-shadow: 3px 3px 0 3px var(--vscode-editor-background) !important; + /* background: radial-gradient(circle at 0% 0%, transparent 70.71%, var(--tab-color) 29.289%) no-repeat; + background-position: 0% 0%; */ +} + +..tab.active::after { + right: 0 !important; + transform: translateX(var(--tab-radius)) !important; + /* border-left: 2px solid var(--base-color) !important; */ + border-bottom-left-radius: var(--tab-radius) !important; + /* box-shadow: -3px 3px 0 3px var(--tab-color) !important; */ + box-shadow: -3px 3px 0 3px var(--vscode-editor-background) !important; + /* background: radial-gradient(circle at 100% 0%, transparent 70.71%, var(--tab-color) 29.289%) no-repeat; + background-position: 100% 0%; */ +} + +/* .tabs-container:before { + content: '' !important; + top: 0 !important; + left: 0 !important; + right: 0 !important; + bottom: 0 !important; + background: linear-gradient(90deg, rgb(12, 14, 20), rgb(189, 172, 255), rgb(189, 147, 249), rgb(189, 147, 249), rgb(189, 147, 249), rgb(189, 172, 249), rgb(12, 14, 20)) !important; + clip: rect(33px, 2600px, 33px, 0px) !important; + position: absolute !important; +} + +.tabs-container:after { + content: '' !important; + top: 0 !important; + left: 0 !important; + right: 0 !important; + bottom: 0 !important; + background: linear-gradient(90deg, rgb(12, 14, 20), rgb(189, 172, 255), rgb(189, 147, 249), rgb(189, 147, 249), rgb(189, 147, 249), rgb(189, 172, 249), rgb(12, 14, 20)) !important; + clip: rect(33px, 2600px, 35px, 0px) !important; + position: absolute !important; +} + +.tab-label > .monaco-icon-label-container::after { + background: transparent !important; +} */ + +/* */ + +.tab{ + border-radius: 12px !important; + margin: 5px !important; + height: 40px !important; + border:2px solid #313244 !important; + background-color: #161925 !important; +} +.tab.active { + border: 2px solid var(--gradient-one) !important; + color: var(--gradient-one) !important; + font-weight: bold !important; +} +.tab.dirty { + border: 2px solid var(--gradient-two) !important; + +} +.tabs-container{ + height: auto !important; + padding: 5px !important; +} +.editor-actions { + height: inherit !important; +} diff --git a/.config/Code/User/vsc.js b/.config/Code/User/vsc.js new file mode 100644 index 0000000..a14bf5a --- /dev/null +++ b/.config/Code/User/vsc.js @@ -0,0 +1,100 @@ +function getOffset(el) { + const rect = el.getBoundingClientRect(); + return { + left: rect.left + window.scrollX, + top: rect.top + window.scrollY, + }; +} + +const prevOffset = {}; + +const displayEffect = (event) => { + if (prevOffset.top === undefined) { + let initialOffset = getOffset(document.getElementsByClassName("cursor")[0]); + prevOffset.top = initialOffset.top; + prevOffset.left = initialOffset.left; + } + + const existingRect = document.getElementById("myRect"); + if (existingRect !== null) { + existingRect.remove(); + } + + setTimeout(function () { + const currOffset = getOffset(document.getElementsByClassName("cursor")[0]); + const top = prevOffset.top; + const left = prevOffset.left; + const rect = document.createElement("div"); + + // console.log("prev: ", top, left); + // console.log("curr: ", currOffset.top, currOffset.left); + + rect.id = "myRect"; + rect.style.cssText = ` + position:absolute; + top:${top}px; + left:${left}px; + width:9px; + height:20px; + z-index:10; + background-color:red; + opacity: 0.5; + `; + rect.animate( + [ + // keyframes + { transform: "scale(1) skew(10deg)" }, + { transform: "scale(0) skew(10deg)" }, + ], + { + // timing options + duration: 500, + easing: "ease-in-out", + direction: "alternate", + iterations: Infinity, + } + ); + + document.body.appendChild(rect); + prevOffset.top = currOffset.top; + prevOffset.left = currOffset.left; + }, 24); +}; + +// NOTE: First enable editor.cursorSmoothCaretAnimation. +// NOTE: Uncomment this to get a cursor trail effect. +// document.addEventListener("keydown", displayEffect); + +const windowControls = document.createElement('div'); +windowControls.className = 'window-controls-container'; +const minimize = document.createElement('div'); +minimize.classList.add('window-icon', 'window-minimize', 'codicon', 'codicon-chrome-minimize'); +const restore = document.createElement('div'); +restore.classList.add('window-icon', 'window-max-restore', 'codicon', 'codicon-chrome-restore'); +const close = document.createElement('div'); +close.classList.add('window-icon', 'window-close', 'codicon', 'codicon-chrome-close'); +windowControls.appendChild(minimize); +windowControls.appendChild(restore); +windowControls.appendChild(close); +// const html = '<div class="window-controls-container"><div class="window-icon window-minimize codicon codicon-chrome-minimize"></div><div class="window-icon window-max-restore codicon codicon-chrome-restore"></div><div class="window-icon window-close codicon codicon-chrome-close"></div></div>'; +// template.innerHTML = html; +// const windowControls = template.content.firstChild; + +var observer = new MutationObserver(function (mutations, me) { + console.warn('Observing if window controls present'); + // const windowControls = document.querySelector(".window-controls-container"); + const tabContainer = document.querySelector(".tabs-and-actions-container"); + + if (windowControls && tabContainer) { + tabContainer.appendChild(windowControls); + console.warn('Observing completed'); + me.disconnect(); + return; + } +}); + + +// observer.observe(document, { +// childList: true, +// subtree: true +// }); diff --git a/.config/X11/.Xresources b/.config/X11/.Xresources new file mode 100644 index 0000000..be509d1 --- /dev/null +++ b/.config/X11/.Xresources @@ -0,0 +1,307 @@ +st.alpha: 255 +!! Transparency (0-1): +*.alpha: 0.2 + +urxvt*shading: 10 +urxvt*tintColor: #000000 +urxvt*blurRadius: 5 +urxvt*transparent: true +urxvt*depth: 32 +urxvt*background: rgba:0000/0000/1111/dddd +!urxvt*background: rgba:0000/0000/0200/c800 +!URxvt*scrollstyle: plain +URxvt.scrollBar: False +!URxvt.font: xft:DejaVu Sans Mono:pixelsize=11:antialias=true +URxvt.font: xft:monospace:Bold:pixelsize=12:antialias=true +!URxvt*transparent: true +!URxvt*shading: 5 +! change to whateva background +URxvt.keysym.C-7: command:\033]11;#ff0000\007 +!URxvt*reverseVideo: True + +URxvt*saveLines : 10000 + +!URxvt.keysym.Control-Up: \033[1;5A +!URxvt.keysym.Control-Down: \033[1;5B +!URxvt.keysym.Control-Left: \033[1;5D +!URxvt.keysym.Control-Right: \033[1;5C + +URxvt.keysym.Control-1: command:\007\033]711;xft:monospace:Bold:pixelsize=12:antialias=true\007 +URxvt.keysym.Control-2: command:\007\033]711;xft:monospace:Bold:pixelsize=18:antialias=true\007 +URxvt.keysym.Control-3: command:\007\033]711;xft:monospace:Bold:pixelsize=28:antialias=true\007 +!URxvt.keysym.Control-1: command:\033]710;xft:Terminus:pixelsize=10:antialias=false\007\033]711;xft:Terminus:Bold:pixelsize=10:antialias=false\007 +!URxvt.keysym.Control-2: command:\033]710;xft:Terminus:pixelsize=14:antialias=false\007\033]711;xft:Terminus:Bold:pixelsize=14:antialias=false\007 +!URxvt.keysym.Control-3: command:\033]710;xft:Terminus:pixelsize=18:antialias=false\007\033]711;xft:Terminus:Bold:pixelsize=18:antialias=false\007 +!URxvt.keysym.Control-4: command:\033]710;xft:Terminus:Bold:pixelsize=20:antialias=false\007\033]711;xft:Terminus:Bold:pixelsize=20:antialias=false\007 +!URxvt.keysym.Control-5: command:\033]710;xft:Terminus:Bold:pixelsize=28:antialias=false\007\033]711;xft:Terminus:Bold:pixelsize=28:antialias=false\007 + + + + + + + +!URxvt.perl-ext-common: selection-to-clipboard +!URxvt.keysym.Shift-Control-V: eval:paste_clipboard +!URxvt.keysym.Shift-Control-C: eval:selection_to_clipboard + + +URxvt.iso14755: false +URxvt.iso14755_52: false + + +!URxvt.scrollBar: true +!URxvt.scrollBar_right: true +!URxvt.scrollBar_floating: true +!URxvt.searchable-scrollback: false +URxvt.url-select.underline: true +URxvt.url-select.autocopy: true +URxvt.cutchars: `""()''*<>[]{|} +URxvt.cursorBlink: True +URxvt.cursorColor: green +URxvt.colorBD: yellow +URxvt.colorUL: green +!URxvt.blurRadius: 5 + + +!! Copy Paste & Other Extensions +!URxvt.perl-ext-common: default,clipboard,url-select,keyboard-select +!URxvt.copyCommand: xclip -i -selection clipboard +!URxvt.pasteCommand: xclip -o -selection clipboard +!URxvt.keysym.M-c: perl:clipboard:copy +!URxvt.keysym.M-v: perl:clipboard:paste +!URxvt.keysym.M-C-v: perl:clipboard:paste_escaped +!URxvt.keysym.M-Escape: perl:keyboard-select:activate +!URxvt.keysym.M-s: perl:keyboard-select:search +!URxvt.keysym.M-u: perl:url-select:select_next +!URxvt.urlLauncher: firefox +!URxvt.underlineURLs: true +!URxvt.urlButton: 1 + + + + +URxvt.keysym.Control-v: eval:paste_clipboard +URxvt.keysym.Control-c: eval:selection_to_clipboard +URxvt.keysym.Control-Meta-c: builtin-string: +URxvt.keysym.Control-Meta-v: builtin-string: + + +URxvt.keysym.Control-k: command:\033]720;1\007 +URxvt.keysym.Control-j: command:\033]721;1\007 + + +URxvt.keysym.Meta-Page_Up: perl:pageup +URxvt.keysym.Meta-Page_Down: perl:pagedown +URxvt.perl-lib: /usr/local/lib/urxvt/perl +URxvt.perl-ext: custom.pl + + +!URxvt*loginShell: true +!URxvt*termName: screen-256color + +!URxvt*perl-ext-common: +!URxvt*perl-ext: + + +!URxvt.keysym.Control-B: eval:scroll_up_pages 1 +!URxvt.keysym.Control-F: eval:scroll_down_pages 1 + + +URxvt.perl-ext-common: default,matcher,clipboard,tabbed +URxvt.clipboard.autocopy: true +URxvt.keysym.M-c: perl:clipboard:copy +URxvt.keysym.M-v: perl:clipboard:paste + +!URxvt.url-launcher: /usr/bin/xdg-open +!URxvt.matcher.button: 1 +!URxvt.keysym.C-Delete: perl:matcher:last +!URxvt.keysym.M-Delete: perl:matcher:list +!URxvt.matcher.rend.0: Uline Bold fg5 + +!URxvt.perl-ext-common: ...,tabbed,... + + +!Key Description +!Shift+Down New tab +!Shift+Left Go to left tab +!Shift+Right Go to right tab +!Ctrl+Left Move tab to the left +!Ctrl+Right Move tab to the right +!Ctrl+d Close tab + + +!URxvt.keysym.Control-k: \033[1;5A +!URxvt.keysym.Control-j: \033[1;5B +!URxvt.keysym.Control-l: \033[1;5C +!URxvt.keysym.Control-h: \033[1;5D + +!^[[5~ + + +rofi.kb-row-up: Up,Control+k,Shift+Tab,Shift+ISO_Left_Tab +rofi.kb-row-down: Down,Control+j +rofi.kb-accept-entry: Control+m,Return,KP_Enter +rofi.terminal: st +rofi.kb-remove-to-eol: Control+Shift+e +rofi.kb-mode-next: Shift+Right,Control+Tab,Control+l +rofi.kb-mode-previous: Shift+Left,Control+Shift+Tab,Control+h +rofi.kb-remove-char-back: BackSpace + + + + +!! Set a default font and font size as below: +!*.font: monospace:size=10 +rofi.font: Noto Sans 11 + +/* name dark light */ +/* black 0 8 */ +/* red 1 9 */ +/* green 2 10 */ +/* yellow 3 11 */ +/* blue 4 12 */ +/* purple 5 13 */ +/* cyan 6 14 */ +/* white 7 15 */ + +/* !! gruvbox: */ +/* *.color0: #1d2021 */ +/* *.color1: #cc241d */ +/* *.color2: #98971a */ +/* *.color3: #d79921 */ +/* *.color4: #458588 */ +/* *.color5: #b16286 */ +/* *.color6: #689d6a */ +/* *.color7: #a89984 */ +/* *.color8: #928374 */ +/* *.color9: #fb4934 */ +/* *.color10: #b8bb26 */ +/* *.color11: #fabd2f */ +/* *.color12: #83a598 */ +/* *.color13: #d3869b */ +/* *.color14: #8ec07c */ +/* *.color15: #ebdbb2 */ +/* *.color256: #1d2021 */ +/* *.color257: #ebdbb2 */ + +* !! gruvbox light: */ +* *.color0: #fbf1c7 */ +* *.color1: #cc241d */ +* *.color2: #98971a */ +* *.color3: #d79921 */ +* *.color4: #458588 */ +* *.color5: #b16286 */ +* *.color6: #689d6a */ +* *.color7: #7c6f64 */ +* *.color8: #928374 */ +* *.color9: #9d0006 */ +* *.color10: #79740e */ +* *.color11: #b57614 */ +* *.color12: #076678 */ +* *.color13: #8f3f71 */ +* *.color14: #427b58 */ +* *.color15: #3c3836 */ +* *.background: #fbf1c7 */ +* *.foreground: #282828 */ +* st.alpha: 0.2 */ + +/* !! brogrammer: */ +/* *.foreground: #d6dbe5 */ +/* *.background: #131313 */ +/* *.color0: #1f1f1f */ +/* *.color8: #d6dbe5 */ +/* *.color1: #f81118 */ +/* *.color9: #de352e */ +/* *.color2: #2dc55e */ +/* *.color10: #1dd361 */ +/* *.color3: #ecba0f */ +/* *.color11: #f3bd09 */ +/* *.color4: #2a84d2 */ +/* *.color12: #1081d6 */ +/* *.color5: #4e5ab7 */ +/* *.color13: #5350b9 */ +/* *.color6: #1081d6 */ +/* *.color14: #0f7ddb */ +/* *.color7: #d6dbe5 */ +/* *.color15: #ffffff */ +/* *.colorBD: #d6dbe5 */ + +/* ! base16 */ +/* *.color0: #181818 */ +/* *.color1: #ab4642 */ +/* *.color2: #a1b56c */ +/* *.color3: #f7ca88 */ +/* *.color4: #7cafc2 */ +/* *.color5: #ba8baf */ +/* *.color6: #86c1b9 */ +/* *.color7: #d8d8d8 */ +/* *.color8: #585858 */ +/* *.color9: #ab4642 */ +/* *.color10: #a1b56c */ +/* *.color11: #f7ca88 */ +/* *.color12: #7cafc2 */ +/* *.color13: #ba8baf */ +/* *.color14: #86c1b9 */ +/* *.color15: #f8f8f8 */ + +/* !! solarized */ +/* *.color0: #073642 */ +/* *.color1: #dc322f */ +/* *.color2: #859900 */ +/* *.color3: #b58900 */ +/* *.color4: #268bd2 */ +/* *.color5: #d33682 */ +/* *.color6: #2aa198 */ +/* *.color7: #eee8d5 */ +/* *.color9: #cb4b16 */ +/* *.color8: #fdf6e3 */ +/* *.color10: #586e75 */ +/* *.color11: #657b83 */ +/* *.color12: #839496 */ +/* *.color13: #6c71c4 */ +/* *.color14: #93a1a1 */ +/* *.color15: #fdf6e3 */ + +/* !! xterm */ +/* *.color0: #000000 */ +/* *.color1: #cd0000 */ +/* *.color2: #00cd00 */ +/* *.color3: #cdcd00 */ +/* *.color4: #0000cd */ +/* *.color5: #cd00cd */ +/* *.color6: #00cdcd */ +/* *.color7: #e5e5e5 */ +/* *.color8: #4d4d4d */ +/* *.color9: #ff0000 */ +/* *.color10: #00ff00 */ +/* *.color11: #ffff00 */ +/* *.color12: #0000ff */ +/* *.color13: #ff00ff */ +/* *.color14: #00ffff */ +/* *.color15: #aabac8 */ +/* *.background: #000000 */ + +/* ! Dracula Xresources palette */ +/* *.foreground: #F8F8F2 */ +/* *.background: #282A36 */ +/* *.color0: #000000 */ +/* *.color8: #4D4D4D */ +/* *.color1: #FF5555 */ +/* *.color9: #FF6E67 */ +/* *.color2: #50FA7B */ +/* *.color10: #5AF78E */ +/* *.color3: #F1FA8C */ +/* *.color11: #F4F99D */ +/* *.color4: #BD93F9 */ +/* *.color12: #CAA9FA */ +/* *.color5: #FF79C6 */ +/* *.color13: #FF92D0 */ +/* *.color6: #8BE9FD */ +/* *.color14: #9AEDFE */ +/* *.color7: #BFBFBF */ +/* *.color15: #E6E6E6 */ + +/* *.background: .color0 */ +/* *.color256: 0#1d2021 */ +/* *.color257: 15#ebdbb2 */ diff --git a/.config/X11/.xbindkeysrc b/.config/X11/.xbindkeysrc new file mode 100644 index 0000000..481943d --- /dev/null +++ b/.config/X11/.xbindkeysrc @@ -0,0 +1,31 @@ +# # Up +# "xdotool mousemove_relative --sync -- 0 -24" +# alt + w +# +# # Left +# "xdotool mousemove_relative --sync -- -24 0" +# alt + a +# +# # Down +# "xdotool mousemove_relative --sync -- 0 24" +# alt + s +# +# # Right +# "xdotool mousemove_relative --sync -- 24 0" +# alt + d +# +# # left + up +# "xdotool mousemove_relative --sync -- -24 -24" +# Shift+alt + q +# +# # right + up +# "xdotool mousemove_relative --sync -- 24 -24" +# Shift+alt + e +# +# # right + down +# "xdotool mousemove_relative --sync -- 24 24" +# Shift+alt + d +# +# # left + down +# "xdotool mousemove_relative --sync -- -24 24" +# Shift+alt + a diff --git a/.config/X11/.xinitrc b/.config/X11/.xinitrc new file mode 100755 index 0000000..1bb2ba9 --- /dev/null +++ b/.config/X11/.xinitrc @@ -0,0 +1,32 @@ +#!/bin/sh +# +#░█▀▀░▀█▀░█▀█░█▀▄░▀█▀░█░█ +#░▀▀█░░█░░█▀█░█▀▄░░█░░▄▀▄ +#░▀▀▀░░▀░░▀░▀░▀░▀░░▀░░▀░▀ +# + +# xinitrc.d +if [ -d /etc/X11/xinit/xinitrc.d ]; then + for f in /etc/X11/xinit/xinitrc.d/*; do + [ -x "$f" ] && . "$f" + done + unset f +fi + +# xinitrc runs automatically when you run startx. + +# There are some small but important commands that need to be run when we start +# the graphical environment. There is a link to this file in ~/.xprofile +# because that file is run automatically if someone uses a display manager +# (login screen) and so they are needed there. To prevent doubling up commands, +# I source them here with the line below. + +# Profile +[[ -f /etc/profile ]] && source /etc/profile + +if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/X11/.xprofile" ]; then + . "${XDG_CONFIG_HOME:-$HOME/.config}/X11/.xprofile" +else + . "$HOME/.xprofile" +fi + diff --git a/.config/X11/.xprofile b/.config/X11/.xprofile new file mode 100644 index 0000000..939b7e1 --- /dev/null +++ b/.config/X11/.xprofile @@ -0,0 +1,23 @@ +#!/bin/sh + +# Xresources +[[ -f ~/.config/X11/.Xresources ]] && xrdb -merge ~/.config/X11/.Xresources + +# Xbindkeys +xbindkeys -f "$XDG_CONFIG_HOME"/X11/xbindkeysrc + +# XKB +setxkbmap -print | xkbcomp -I$HOME/.config/xkb - $DISPLAY + + +#export XAUTHORITY="$XDG_RUNTIME_DIR/.Xauthority" # This line will break some DMs. +export USERXSESSION="$XDG_CACHE_HOME/X11/xsession" +export USERXSESSIONRC="$XDG_CACHE_HOME/X11/xsessionrc" +export ALTUSERXSESSION="$XDG_CACHE_HOME/X11/Xsession" +export ERRFILE="$XDG_CACHE_HOME/X11/xsession-errors" + + +if [[ "$(tty)" = "/dev/tty1" ]]; then + pgrep bspwm || startx "$XDG_CONFIG_HOME/X11/.xinitrc" +# pgrep startxfce4 || startx "$XDG_CONFIG_HOME/X11/.xinitrc" +fi diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml new file mode 100644 index 0000000..b27b123 --- /dev/null +++ b/.config/alacritty/alacritty.yml @@ -0,0 +1,106 @@ +# ~/.config/alacritty/alacritty.yml + + +live_config_reload: true + +window: + opacity: 0.6 + dynamic_title: true + dimensions: + columns: 0 + lines: 0 + + + # startup_mode: Maximized + # position: + # x: 0 + # y: 0 + + padding: + x: 9 + y: 9 + + dynamic_padding: false + decorations: none + +scrolling: + history: 50000 + multiplier: 3 + + + +font: + normal: + family: JetBrains Mono Medium + #family: Fira Mono Regular + #family: UbuntuMono Nerd Font Regular + #family: monospace + size: 8.5 + offset: + x: 0 + y: 0 + glyph_offset: + x: 0 + y: 0 + builtin_box_drawing: true + #size: 8.5 + + # Glyph offset determines the locations of the glyphs within their cells with + # the default being at the bottom. Increase the x offset to move the glyph to + # the right, increase the y offset to move the glyph upward. + +key_bindings: +- { key: V, mods: Control, action: Paste } +- { key: C, mods: Control, action: Copy } +- { key: C, mods: Control|Shift, chars: "\x03" } +- { key: N, mods: Control|Shift, action: SpawnNewInstance } +- { key: O, mods: Control|Shift, command: { program: "opacity-change.sh", args: ["-"] } } +- { key: P, mods: Control|Shift, command: { program: "opacity-change.sh", args: ["+"] } } +save_to_clipboard: true + +colors: + primary: + background: '#000000' + foreground: '#FFFACD' + normal: + black: '#313539' + red: '#b02626' + green: '#40a62f' + yellow: '#f2e635' + blue: '#314ad0' + magenta: '#b30ad0' + cyan: '#32d0fc' + white: '#acadb1' + bright: + black: '#676f78' + red: '#b55454' + green: '#78a670' + yellow: '#faf380' + blue: '#707fd0' + magenta: '#c583d0' + cyan: '#8adaf1' + white: '#e0e3e7' + + +#colors: +# primary: +# background: '#0F111A' +# foreground: '#8F93A2' +# normal: +# black: '#0F111A' +# red: '#FF5370' +# green: '#99C794' +# yellow: '#C4E88D' +# blue: '#82AAFF' +# magenta: '#C792EA' +# cyan: '#89DDFF' +# white: '#464B5D' +# bright: +# black: '#0F111A' +# red: '#FF5370' +# green: '#99C794' +# yellow: '#C4E88D' +# blue: '#82AAFF' +# magenta: '#C792EA' + # cyan: '#89DDFF' + # white: '#8F93A2' diff --git a/.config/betterlockscreen/betterlockscreenrc b/.config/betterlockscreen/betterlockscreenrc new file mode 100644 index 0000000..4cdfbe8 --- /dev/null +++ b/.config/betterlockscreen/betterlockscreenrc @@ -0,0 +1,37 @@ +# ~/.config/betterlockscreenrc + +# default options +display_on=0 +span_image=false +lock_timeout=300 +fx_list=(dim blur dimblur pixel dimpixel color) +dim_level=40 +blur_level=1 +pixel_scale=10,1000 +solid_color=333333 +wallpaper_cmd="feh --bg-fill" +quiet=false +# i3lockcolor_bin="i3lock-color" # Manually set command for i3lock-color + +# default theme +loginbox=00000066 +loginshadow=00000000 +locktext="Type password to unlock..." +font="sans-serif" +ringcolor=ffffffff +insidecolor=00000000 +separatorcolor=00000000 +ringvercolor=ffffffff +insidevercolor=00000000 +ringwrongcolor=ffffffff +insidewrongcolor=d23c3dff +timecolor=ffffffff +time_format="%H:%M:%S" +greetercolor=ffffffff +layoutcolor=ffffffff +keyhlcolor=d23c3dff +bshlcolor=d23c3dff +verifcolor=ffffffff +wrongcolor=d23c3dff +modifcolor=d23c3dff +bgcolor=000000ff diff --git a/.config/bspwm/bspcmd b/.config/bspwm/bspcmd new file mode 100755 index 0000000..94bed26 --- /dev/null +++ b/.config/bspwm/bspcmd @@ -0,0 +1,37 @@ +#!/bin/bash + +CMD=${1:-help}; shift + +help() { + echo "Available commands:" + echo " * unhide - select and unhide window" +} + +unhide() { + action=${1:-list} + case $action in + "list") + selection=`for id in $(bspc query -N -n .hidden); do + title=$(xtitle $id) + [[ -z "$title" ]] && title="<unnamed>" + echo $id $title + done | rofi -dmenu -i -p "Hidden windows" | cut -f1 -d' '` + + [[ -z "$selection" ]] && exit 1 + + bspc node $selection -g hidden=off + ;; + esac +} + +case $CMD in + "help") + help + ;; + "unhide") + unhide $1 + ;; + *) + help + ;; +esac diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc new file mode 100755 index 0000000..af6fc1a --- /dev/null +++ b/.config/bspwm/bspwmrc @@ -0,0 +1,95 @@ +#! /bin/sh + +#░█▀▄░█▀▀░█▀█░█░█░█▄█ +#░█▀▄░▀▀█░█▀▀░█▄█░█░█ +#░▀▀░░▀▀▀░▀░░░▀░▀░▀░▀ + +bspc monitor LVDS-1 -d 1 2 3 4 5 +bspc monitor HDMI-1 -d 6 7 8 9 0 + +###---Global Settings---### +bspc config automatic_scheme alternate +bspc config initial_polarity second_child +bspc config pointer_action1 move +bspc config pointer_action2 resize_side +bspc config pointer_action2 resize_corner +bspc config focus_follows_pointer false +bspc config remove_disabled_monitors true +bspc config remove_unplugged_monitors true +bspc config merge_overlapping_monitors true +bspc config border_width 2 +bspc config window_gap 10 +bspc config split_ratio 0.52 +bspc config borderless_monocle true +bspc config gapless_monocle true +bspc config swallow_first_click false +bspc config pointer_modifier mod1 +#bspc config pointer_action1 resize_side +#bspc config pointer_action1 resize_corner +#bspc config pointer_action3 move +bspc config normal_border_color "#282828" +bspc config active_border_color "#ebdbb2" +bspc config focused_border_color "#77dd77" +bspc config presel_feedback_color "#BF616A" +#bspc config normal_border_color "#282828" +#bspc config active_border_color "#ebdbb2" +#bspc config focused_border_color "#fe8019" + +# remove all rules first +bspc rule -r *:* + +bspc rule -a Plank layer=above border=off + +###---Autostart---#### +pgrep -x sxhkd >/dev/null || sxhkd & +picom -b --experimental-backends & +if [[ $(xrandr -q | grep 'HDMI-1 connected') ]]; then + xrandr --output LVDS-1 --primary --mode 1366x768 --rotate normal --output HDMI-1 --mode 1920x1080 --rotate normal --right-of LVDS-1 +fi +xfce4-panel --disable-wm-check & +"$HOME"/.config/polybar/launch.sh & +dunst & # notification daemon +unclutter & # Remove mouse when idle +nitrogen --force-setter=xinerama --restore & +#bspc rule -a \* rectangle=680x700+340+40 +bspc rule -a '*:*:Picture-in-Picture' state=floating sticky=on layer=above +bspc rule -a '*:*:Picture in picture' state=floating sticky=on layer=above +bspc rule -a firefox:Toolkit focus=on state=floating sticky=on layer=above rectangle=522x320+830+280 +#320x190+1030+480 +#522x316-10+280 +bspc rule -a "https://www.youtube.com - Enhancer for YouTube™ — Mozilla Firefox" state=floating sticky=on layer=above +bspc rule -a Wezterm state=floating +bspc rule -a Zathura state=tiled + +#eww daemon & + +# SCRATCHPAD +bspc rule -a scratchpad sticky=on state=floating + +# Heads Up Display (scratchpad) +bspc rule -a Heads-Up-Display sticky=on state=floating rectangle=360x160+990+40 + +[ "$1" = 0 ] && { + nm-applet & + plank & +} + +pkill xfce4-power-manager +sleep 1 && nice -n 1 xfce4-power-manager & +pkill volumeicon +sleep 2 && nice -n 2 volumeicon & +pkill mictray +sleep 2 && nice -n 2 mictray & +pkill parcellite +sleep 2 && nice -n 2 parcellite & + +bspc subscribe node_state | while read -r _ _ _ _ state flag; do + if [[ "$state" != fullscreen ]]; then continue; fi + if [[ "$flag" == on ]]; then + xdo lower -N Plank + else + xdo raise -N Plank + fi +done & + +bspc config external_rules_command ~/.config/bspwm/scripts/external_rules.sh diff --git a/.config/bspwm/menu.sh b/.config/bspwm/menu.sh new file mode 100755 index 0000000..f678ae1 --- /dev/null +++ b/.config/bspwm/menu.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#1A237E" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun \ +-display-drun "Applications " -drun-display-format "{name}" \ +-hide-scrollbar true \ +-bw 0 \ +-lines 10 \ +-line-padding 10 \ +-padding 20 \ +-width 30 \ +-xoffset 27 -yoffset 60 \ +-location 1 \ +-columns 2 \ +-show-icons -icon-theme "Papirus" \ +-font "Fantasque Sans Mono 10" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/bspwm/noswallow b/.config/bspwm/noswallow new file mode 100644 index 0000000..139597f --- /dev/null +++ b/.config/bspwm/noswallow @@ -0,0 +1,2 @@ + + diff --git a/.config/bspwm/scripts/external_rules.sh b/.config/bspwm/scripts/external_rules.sh new file mode 100755 index 0000000..74fdaa0 --- /dev/null +++ b/.config/bspwm/scripts/external_rules.sh @@ -0,0 +1,39 @@ +#!/bin/env bash + +#instance=$3 +#[!-z"$3"] && xdo raise -a polybar-bottom_LVDS-1 +#[!-z"$3"] && xdo below -a polybar-bottom_LVDS-1 -t $(xdo id -N Bspwm -n root) + + +#bspc subscribe node_state | while read -r _ _ _ _ state flag; do +# if [[ "$state" != fullscreen ]]; then continue; fi +# if [[ "$flag" == on ]]; then +# xdo lower -N Plank +# else +# xdo raise -N Plank +# fi +#done & +# +#eval $4 +#bspc query -N -d ${desktop:-focused} -n .fullscreen >/dev/null && +# echo layer=above + + +#bspc subscribe node_state | while read -r _ _ _ _ state flag; do +# if [[ "$state" != fullscreen ]]; then continue; fi +# if [[ "$flag" == on ]]; then +# xdo lower -a polybar-bottom_LVDS-1 +# else +# xdo raise -a polybar-bottom_LVDS-1 +# fi +#done & + +# Allow any type of window to ignore fullscreen windows (allow fullscreen to +# stay) +wid="$1" +class="$2" +instance="$3" +eval "$4" + +[[ "$state" = floating ]] \ + && echo 'layer=above' diff --git a/.config/bspwm/swallow b/.config/bspwm/swallow new file mode 100644 index 0000000..21b7f00 --- /dev/null +++ b/.config/bspwm/swallow @@ -0,0 +1,3 @@ +sxiv +Sxiv +zathura diff --git a/.config/bspwm/sysmenu.sh b/.config/bspwm/sysmenu.sh new file mode 100755 index 0000000..1bdc35e --- /dev/null +++ b/.config/bspwm/sysmenu.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#1A237E" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +MENU="$(rofi -no-lazy-grab -sep "|" -dmenu -i -p 'System :' \ +-hide-scrollbar true \ +-bw 0 \ +-lines 4 \ +-line-padding 10 \ +-padding 20 \ +-width 15 \ +-xoffset -27 -yoffset 60 \ +-location 3 \ +-columns 1 \ +-show-icons -icon-theme "Papirus" \ +-font "Fantasque Sans Mono 10" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +<<< " Lock| Logout| Reboot| Shutdown")" +case "$MENU" in + *Lock) i3lock -c 282a36 -n ;; + *Logout) openbox --exit;; + *Reboot) sudo reboot ;; + *Shutdown) sudo shutdown -r now +esac + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/bspwm/terminals b/.config/bspwm/terminals new file mode 100644 index 0000000..414337e --- /dev/null +++ b/.config/bspwm/terminals @@ -0,0 +1 @@ +Alacritty diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc new file mode 100644 index 0000000..b9cf04f --- /dev/null +++ b/.config/dunst/dunstrc @@ -0,0 +1,500 @@ +# See dunst(5) for all configuration options + +[global] + ### Display ### + + # Which monitor should the notifications be displayed on. + monitor = 0 + + # Display notification on focused monitor. Possible modes are: + # mouse: follow mouse pointer + # keyboard: follow window with keyboard focus + # none: don't follow anything + # + # "keyboard" needs a window manager that exports the + # _NET_ACTIVE_WINDOW property. + # This should be the case for almost all modern window managers. + # + # If this option is set to mouse or keyboard, the monitor option + # will be ignored. + follow = mouse + + # The geometry of the window: + #[{width}]x{height}[+/-{x}+/-{y}] + # The geometry of the message window. + # The height is measured in number of notifications everything else + # in pixels. If the width is omitted but the height is given + # ("-geometry x2"), the message window expands over the whole screen + # (dmenu-like). If width is 0, the window expands to the longest + # message displayed. A positive x is measured from the left, a + # negative from the right side of the screen. Y is measured from + # the top and down respectively. + # The width can be negative. In this case the actual width is the + # screen width minus the width defined in within the geometry option. + geometry = "300x5-7+30" + + # Scale factor. It is auto-detected if value is 0. + scale = 0 + + # Turn on the progess bar. It appears when a progress hint is passed with + # for example dunstify -h int:value:12 + progress_bar = true + + # Set the progress bar height. This includes the frame, so make sure + # it's at least twice as big as the frame width. + progress_bar_height = 10 + + # Set the frame width of the progress bar + progress_bar_frame_width = 1 + + # Set the minimum width for the progress bar + progress_bar_min_width = 150 + + # Set the maximum width for the progress bar + progress_bar_max_width = 300 + + + # Show how many messages are currently hidden (because of geometry). + indicate_hidden = yes + + # Shrink window if it's smaller than the width. Will be ignored if + # width is 0. + shrink = no + + # The transparency of the window. Range: [0; 100]. + # This option will only work if a compositing window manager is + # present (e.g. xcompmgr, compiz, etc.). (X11 only) + transparency = 0 + + # The height of the entire notification. If the height is smaller + # than the font height and padding combined, it will be raised + # to the font height and padding. + notification_height = 45 + + # Draw a line of "separator_height" pixel height between two + # notifications. + # Set to 0 to disable. + separator_height = 2 + + # Padding between text and separator. + padding = 8 + + # Horizontal padding. + horizontal_padding = 15 + + # Padding between text and icon. + text_icon_padding = 12 + + # Defines width in pixels of frame around the notification window. + # Set to 0 to disable. + frame_width = 3 + + # Defines color of the frame around the notification window. + frame_color = "#f0f2f5" + #frame_color = "#2E3440" + + # Define a color for the separator. + # possible values are: + # * auto: dunst tries to find a color fitting to the background; + # * foreground: use the same color as the foreground; + # * frame: use the same color as the frame; + # * anything else will be interpreted as a X color. + separator_color = frame + + # Sort messages by urgency. + sort = yes + + # Don't remove messages, if the user is idle (no mouse or keyboard input) + # for longer than idle_threshold seconds. + # Set to 0 to disable. + # A client can set the 'transient' hint to bypass this. See the rules + # section for how to disable this if necessary + # idle_threshold = 120 + + ### Text ### + + font = UbuntuMono Nerd Font 9 + + # The spacing between lines. If the height is smaller than the + # font height, it will get raised to the font height. + line_height = 0 + + # Possible values are: + # full: Allow a small subset of html markup in notifications: + # <b>bold</b> + # <i>italic</i> + # <s>strikethrough</s> + # <u>underline</u> + # + # For a complete reference see + # <https://developer.gnome.org/pango/stable/pango-Markup.html>. + # + # strip: This setting is provided for compatibility with some broken + # clients that send markup even though it's not enabled on the + # server. Dunst will try to strip the markup but the parsing is + # simplistic so using this option outside of matching rules for + # specific applications *IS GREATLY DISCOURAGED*. + # + # no: Disable markup parsing, incoming notifications will be treated as + # plain text. Dunst will not advertise that it has the body-markup + # capability if this is set as a global setting. + # + # It's important to note that markup inside the format option will be parsed + # regardless of what this is set to. + markup = strip + show_indicators = false + + + # The format of the message. Possible variables are: + # %a appname + # %s summary + # %b body + # %i iconname (including its path) + # %I iconname (without its path) + # %p progress value if set ([ 0%] to [100%]) or nothing + # %n progress value if set without any extra characters + # %% Literal % + # Markup is allowed + format = "<b>%s</b>\n%b" + + # Alignment of message text. + # Possible values are "left", "center" and "right". + alignment = left + + # Vertical alignment of message text and icon. + # Possible values are "top", "center" and "bottom". + vertical_alignment = top + + # Show age of message if message is older than show_age_threshold + # seconds. + # Set to -1 to disable. + show_age_threshold = 60 + + # Split notifications into multiple lines if they don't fit into + # geometry. + word_wrap = yes + + # When word_wrap is set to no, specify where to make an ellipsis in long lines. + # Possible values are "start", "middle" and "end". + ellipsize = middle + + # Ignore newlines '\n' in notifications. + ignore_newline = no + + # Stack together notifications with the same content + stack_duplicates = true + + # Hide the count of stacked notifications with the same content + hide_duplicate_count = false + + # Display indicators for URLs (U) and actions (A). + show_indicators = false + + ### Icons ### + + # Align icons left/right/off + icon_position = left + + # Scale small icons up to this size, set to 0 to disable. Helpful + # for e.g. small files or high-dpi screens. In case of conflict, + # max_icon_size takes precedence over this. + min_icon_size = 0 + + # Scale larger icons down to this size, set to 0 to disable + max_icon_size = 32 + + # Paths to default icons. + icon_path = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/ + + ### History ### + + # Should a notification popped up from history be sticky or timeout + # as if it would normally do. + sticky_history = yes + + # Maximum amount of notifications kept in history + history_length = 20 + + ### Misc/Advanced ### + + # dmenu path. + dmenu = /usr/bin/dmenu -p dunst: + + # Browser for opening urls in context menu. + browser = /usr/bin/brave -new-tab + + # Always run rule-defined scripts, even if the notification is suppressed + always_run_script = true + + # Define the title of the windows spawned by dunst + title = Dunst + + # Define the class of the windows spawned by dunst + class = Dunst + + # Print a notification on startup. + # This is mainly for error detection, since dbus (re-)starts dunst + # automatically after a crash. + startup_notification = false + + # Manage dunst's desire for talking + # Can be one of the following values: + # crit: Critical features. Dunst aborts + # warn: Only non-fatal warnings + # mesg: Important Messages + # info: all unimportant stuff + # debug: all less than unimportant stuff + verbosity = mesg + + # Define the corner radius of the notification window + # in pixel size. If the radius is 0, you have no rounded + # corners. + # The radius will be automatically lowered if it exceeds half of the + # notification height to avoid clipping text and/or icons. + corner_radius = 0 + + # Ignore the dbus closeNotification message. + # Useful to enforce the timeout set by dunst configuration. Without this + # parameter, an application may close the notification sent before the + # user defined timeout. + ignore_dbusclose = false + + ### Wayland ### + # These settings are Wayland-specific. They have no effect when using X11 + + # Uncomment this if you want to let notications appear under fullscreen + # applications (default: overlay) + # layer = top + + # Set this to true to use X11 output on Wayland. + force_xwayland = false + + ### Legacy + + # Use the Xinerama extension instead of RandR for multi-monitor support. + # This setting is provided for compatibility with older nVidia drivers that + # do not support RandR and using it on systems that support RandR is highly + # discouraged. + # + # By enabling this setting dunst will not be able to detect when a monitor + # is connected or disconnected which might break follow mode if the screen + # layout changes. + force_xinerama = false + + ### mouse + + # Defines list of actions for each mouse event + # Possible values are: + # * none: Don't do anything. + # * do_action: Invoke the action determined by the action_name rule. If there is no + # such action, open the context menu. + # * open_url: If the notification has exactly one url, open it. If there are multiple + # ones, open the context menu. + # * close_current: Close current notification. + # * close_all: Close all notifications. + # * context: Open context menu for the notification. + # * context_all: Open context menu for all notifications. + # These values can be strung together for each mouse event, and + # will be executed in sequence. + mouse_left_click = close_current + mouse_middle_click = close_all + mouse_right_click = do_action + +# Experimental features that may or may not work correctly. Do not expect them +# to have a consistent behaviour across releases. +[experimental] + # Calculate the dpi to use on a per-monitor basis. + # If this setting is enabled the Xft.dpi value will be ignored and instead + # dunst will attempt to calculate an appropriate dpi value for each monitor + # using the resolution and physical size. This might be useful in setups + # where there are multiple screens with very different dpi values. + per_monitor_dpi = false + + +[urgency_low] + # IMPORTANT: colors have to be defined in quotation marks. + # Otherwise the "#" and following would be interpreted as a comment. + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + timeout = 5 + # Icon for notifications with low urgency, uncomment to enable + #icon = /path/to/icon + +[urgency_normal] + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + timeout = 10 + # Icon for notifications with normal urgency, uncomment to enable + #icon = /path/to/icon + +[urgency_critical] + background = "#00101212" + background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + frame_color = #a1dde7 + timeout = 30 + # Icon for notifications with critical urgency, uncomment to enable + #icon = /path/to/icon + +# Every section that isn't one of the above is interpreted as a rules to +# override settings for certain messages. +# +# Messages can be matched by +# appname (discouraged, see desktop_entry) +# body +# category +# desktop_entry +# icon +# match_transient +# msg_urgency +# stack_tag +# summary +# +# and you can override the +# background +# foreground +# format +# frame_color +# fullscreen +# new_icon +# set_stack_tag +# set_transient +# timeout +# urgency +# action_name +# +# Shell-like globbing will get expanded. +# +# Instead of the appname filter, it's recommended to use the desktop_entry filter. +# GLib based applications export their desktop-entry name. In comparison to the appname, +# the desktop-entry won't get localized. +# +# SCRIPTING +# You can specify a script that gets run when the rule matches by +# setting the "script" option. +# The script will be called as follows: +# script appname summary body icon urgency +# where urgency can be "LOW", "NORMAL" or "CRITICAL". +# +# NOTE: if you don't want a notification to be displayed, set the format +# to "". +# NOTE: It might be helpful to run dunst -print in a terminal in order +# to find fitting options for rules. + +# Disable the transient hint so that idle_threshold cannot be bypassed from the +# client +#[transient_disable] +# match_transient = yes +# set_transient = no +# +# Make the handling of transient notifications more strict by making them not +# be placed in history. +#[transient_history_ignore] +# match_transient = yes +# history_ignore = yes + +# fullscreen values +# show: show the notifications, regardless if there is a fullscreen window opened +# delay: displays the new notification, if there is no fullscreen window active +# If the notification is already drawn, it won't get undrawn. +# pushback: same as delay, but when switching into fullscreen, the notification will get +# withdrawn from screen again and will get delayed like a new notification +#[fullscreen_delay_everything] +# fullscreen = delay +#[fullscreen_show_critical] +# msg_urgency = critical +# fullscreen = show + +#[espeak] +# summary = "*" +# script = dunst_espeak.sh + +#[script-test] +# summary = "*script*" +# script = dunst_test.sh + +#[ignore] +# # This notification will not be displayed +# summary = "foobar" +# format = "" + +#[history-ignore] +# # This notification will not be saved in history +# summary = "foobar" +# history_ignore = yes + +#[skip-display] +# # This notification will not be displayed, but will be included in the history +# summary = "foobar" +# skip_display = yes + +#[signed_on] +# appname = Pidgin +# summary = "*signed on*" +# urgency = low +# +#[signed_off] +# appname = Pidgin +# summary = *signed off* +# urgency = low +# +#[says] +# appname = Pidgin +# summary = *says* +# urgency = critical +# +#[twitter] +# appname = Pidgin +# summary = *twitter.com* +# urgency = normal +[spotify] + appname = Spotify + Summary = *Song* + urgency = critical + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + +[Telegram] + appname = Telegram + summary = *New msg* + urgency = critical + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + +[Discord] + appname = Discord + Summary = *Ping* + urgency = critical + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + + + +[Brave] + appname = Brave + Summary = *Notification* + urgency = critical + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + + +# +#[stack-volumes] +# appname = "some_volume_notifiers" +# set_stack_tag = "volume" + +# +# vim: ft=cfg diff --git a/.config/eww/bar/main.yuck b/.config/eww/bar/main.yuck new file mode 100644 index 0000000..a379ace --- /dev/null +++ b/.config/eww/bar/main.yuck @@ -0,0 +1,193 @@ +(defwindow bar + :monitor 0 + :geometry (geometry :x -28 :y 0 :anchor "center right") +(bar)) + +(defwidget bar [] + (box + :class "bar" + :orientation "v" + :space-evenly false + (bar-group + (bar-item-center-window) + (bar-item-resize-ratio) + (bar-item-resize) + (bar-item-toggle-floaty) + (bar-item-close-window) + ) + (bar-group + (bar-item-balance) + (bar-item-rotate) + (bar-item-focus-parent) + ) + (bar-group + (bar-item-toggle-borders) + (bar-item-toggle-hidden) + (bar-item-toggle-monocle) + ) + (bar-group + (bar-item-empty-desktop) + (bar-item-cycle-desktops) + ) + (bar-group + ;(bar-item-clipboard) + (bar-item-screenshot) + (bar-item-power) + ) + ) +) + +(defwidget bar-group [] + (box + :class "bar-group" + :orientation "v" + (children) + ) +) + +(defwidget bar-item [icon ?color ?lclick ?rclick] + (box + :class "bar-item" + (eventbox + :onscroll "resize-window {}" + (button + :onclick lclick + :onrightclick rclick + ;:timeout 200 + (icon :name icon :color color) + ) + ) + ) +) + +(defwidget bar-item-balance [] + (bar-item + :icon "columns" + :color "yellow" + :lclick "bspc node @/ -B" + ) +) + +(defwidget bar-item-center-window [] + (bar-item + :icon "minimize" + :color "yellow" + :lclick "center-window" + ) +) + +(defwidget bar-item-clipboard [] + (bar-item + :icon "clipboard" + :color "yellow" + ) +) + +(defwidget bar-item-close-window [] + (bar-item + :icon "x-circle" + :color "red" + :lclick "close-window" + ) +) + +(defwidget bar-item-cycle-desktops [] + (bar-item + :icon "skip-forward" + :color "blue" + :lclick "show-desktop next" + :rclick "show-desktop prev" + ) +) + +(defwidget bar-item-empty-desktop [] + (bar-item + :icon "plus-circle" + :color "green" + :lclick "show-desktop empty" + ) +) + +(defwidget bar-item-focus-parent [] + (bar-item + :icon "arrow-up-circle" + :color "blue" + :lclick "bspc node -f @parent" + ) +) + +(defwidget bar-item-power [] + (bar-item + :icon "power" + :color "red" + :lclick "shut-down" + ) +) + +(defwidget bar-item-resize [] + (bar-item + :icon "maximize-2" + :color "blue" + :lclick "bspc node -z top_left -16 -9 \ + && bspc node -z bottom_right 16 9" + :rclick "bspc node -z top_left 16 9 \ + && bspc node -z bottom_right -16 -9" + ) +) + +(defwidget bar-item-resize-ratio [] + (bar-item + :icon "youtube" + :color "green" + :lclick "resize-ratio 16 9" + ) +) + +(defwidget bar-item-rotate [] + (bar-item + :icon "rotate-cw" + :color "green" + :lclick "bspc node -R 90" + ) +) + +(defwidget bar-item-screenshot [] + (bar-item + :icon "camera" + :color "purple" + :lclick "notify hello" + :rclick "scrot -s -l mode=edge,width=7,color=\"#FFFFFF\",opacity=20 -e 'mv $f ~/unsorted/screenshots'" + ) +) + +(defwidget bar-item-toggle-borders [] + (bar-item + :icon "maximize" + :icon {disableBorders ? "square" : "maximize"} + :color "purple" + :lclick "toggle-borders" + ) +) + +(defwidget bar-item-toggle-floaty [] + (bar-item + :icon {focusIsFloaty ? "corner-left-down" : "corner-right-up"} + :color "purple" + :lclick "toggle-floaty" + ) +) + +(defwidget bar-item-toggle-hidden [] + (bar-item + :icon "eye" + :color "red" + :lclick "toggle-hidden" + ) +) +(defwidget bar-item-toggle-monocle [] + (bar-item + :icon {monocleMode ? "zoom-out" : "zoom-in"} + :color "yellow" + :lclick "toggle-monocle" + ) +) diff --git a/.config/eww/bar/style.scss b/.config/eww/bar/style.scss new file mode 100644 index 0000000..121cd12 --- /dev/null +++ b/.config/eww/bar/style.scss @@ -0,0 +1,16 @@ +.bar { + background-color: $borderColor; + // border: $borderSize solid $borderColor; + padding: $borderSize 0 0 0; +} + +.bar-group { + background-color: $bgColor; + border-radius: $borderRadius; + margin: 0 $borderSize $borderSize $borderSize; + padding: 7; +} + +.bar-item { + padding: 7; +} diff --git a/.config/eww/dock/main.yuck b/.config/eww/dock/main.yuck new file mode 100644 index 0000000..a3ec73f --- /dev/null +++ b/.config/eww/dock/main.yuck @@ -0,0 +1,94 @@ +(defwindow dock + :monitor 0 + :geometry (geometry :x 0 :y -28 :anchor "bottom center") + (dock)) + +(defwidget dock [] + (box + :class "dock" + :space-evenly false + (dock-group + (dock-item + :icon "firefox" + :lclick "quick-app -c firefox -i Navigator&" + :rclick "firefox&" + ) + (dock-item + :icon "nautilus" + :lclick "quick-app -c Thunar -f thunar ~/unsorted" + ) + (dock-item + :icon "terminal" + :lclick "quick-app -c kitty -i quick -f kitty --name quick" + :rclick "cd ~ && kitty&" + ) + ) + (dock-group + (dock-item + :icon "email" + ) + (dock-item + :icon "telegram" + :lclick "quick-app -c TelegramDesktop -f telegram-desktop" + ) + (dock-item + :icon "weechat" + ) + (dock-item + :icon "discord-development" + :lclick "quick-app -c discord -f" + ) + ) + (dock-group + (dock-item + :icon "preferences-desktop-color" + ;:icon "openrgb" + ;:icon "gcolor3" + :lclick "quick-app -c Gcolor3 -f gcolor3" + ) + (dock-item + :icon "gnome-calculator" + :lclick "quick-app -c gnome-calculator -f" + ) + (dock-item + :icon "easyeffects" + :lclick "quick-app -c easyeffects -f" + ) + (dock-item + :icon "obs" + :lclick "quick-app -c obs -f" + ) + (dock-item + :icon "deepin-music-player" + ) + ) + (dock-group + (dock-item :icon "youtube" :lclick "quick-app -c mpv&") + (dock-item + :icon "steam" + :lclick "quick-app -c Steam steam&" + ) + (dock-item :icon "blender" :lclick "quick-app -c Blender blender&") + (dock-item :icon "godot" :lclick "quick-app -c Godot -f godot&") + (dock-item :icon "inkscape" :lclick "quick-app -c Inkscape inkscape&") + ) + ) +) + +(defwidget dock-group [] + (box + :class "dock-group" + (children) + ) +) + +(defwidget dock-item [icon ?lclick ?rclick] + (box + :class "dock-item" + (button + :onclick lclick + :onrightclick rclick + (image :path "${appIcons}${icon}.svg") + ) + ) +) diff --git a/.config/eww/dock/style.scss b/.config/eww/dock/style.scss new file mode 100644 index 0000000..4cc4515 --- /dev/null +++ b/.config/eww/dock/style.scss @@ -0,0 +1,16 @@ +.dock { + background-color: $borderColor; + // border: $borderSize solid $borderColor; + padding: 0 0 0 $borderSize; +} + +.dock-group { + background-color: $bgColor; + border-radius: $borderRadius; + margin: $borderSize $borderSize $borderSize 0; + padding: 5; +} + +.dock-item { + padding: 5; +} diff --git a/.config/eww/eww.scss b/.config/eww/eww.scss new file mode 100644 index 0000000..3c46de1 --- /dev/null +++ b/.config/eww/eww.scss @@ -0,0 +1,21 @@ +$borderColor: #24283b; +$borderRadius: 5px; +$borderSize: 5px; +$bgColor: #1a1b26; +$fgColor: #c0caf5; + +* { + all: unset; + color: $fgColor; +} + +// .window { +// background-color: $bgColor; +// border: $borderSize solid $borderColor; +// color: $fgColor; +// } + +@import "bar/style.scss"; +@import "dock/style.scss"; +@import "panel/style.scss"; +@import "status/style.scss"; diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck new file mode 100644 index 0000000..fbd1bc3 --- /dev/null +++ b/.config/eww/eww.yuck @@ -0,0 +1,26 @@ +(defvar appIcons "/usr/share/icons/Papirus-Dark/48x48/apps/") +(defvar barIcons "/home/sxrdusr/.local/share/icons/feather-icons/") + +(defvar disableBorders false) +(defvar externalMonitor false) +(defvar focusIsFloaty false) +(defvar monocleMode false) +(defvar ultrawide true) +(defvar brightness 10) +(defvar nightlight 0) +(defvar volume 10) + +(defpoll date :interval "1m" "date '+%B %d'") +(defpoll time :interval "2s" "date '+%H:%M'") + +(defwidget icon [name ?color ?size] + (image + :image-width {size?:20} + :path "${barIcons}/${color?:'white'}/${name}.svg" + ) +) + +(include "bar/main.yuck") +(include "dock/main.yuck") +(include "panel/main.yuck") +(include "status/main.yuck") diff --git a/.config/eww/panel/drives.yuck b/.config/eww/panel/drives.yuck new file mode 100644 index 0000000..122f0d8 --- /dev/null +++ b/.config/eww/panel/drives.yuck @@ -0,0 +1,77 @@ +(defwidget dock-drives [] + (box + :orientation "v" + (disk + :label "System" + :mount "/" + :space "100" + ) + (disk + :label "SSD 1" + :mount "/mnt/ssd250" + :space "250" + ) + (disk + :label "SSD 2" + :mount "/mnt/games" + :space "250" + ) + (disk + :label "HDD" + :mount "/mnt/hdd500" + :space "500" + ) + (disk + :label "RAID" + :mount "/mnt/raid" + :space "3000" + ) + ) +) + +(defwidget disk [label mount space] + (eventbox + :class "disk-wrapper" + (button + :onclick "quick file ${mount}" + (box + :class "disk" + :space-evenly false + (box + :class "disk-icon" + :width 30 + (image :path "/home/edwin/workspace/icons/hard-drive.svg") + ) + (box + :class "disk-usage" + :orientation "v" + :spacing 3 + :space-evenly false + (box + :class "disk-usage-text" + :width 140 + (box + :halign "start" + :valign "start" + label + ) + (box + :halign "end" + :valign "end" + :hexpand true + :vexpand true + "${round(EWW_DISK[mount].free/1000000000, 0)} GB" + ) + ) + (scale + :class "disk-usage-bar" + :marks "false" + :max 100 + :min 0 + :value {EWW_DISK[mount].used_perc} + ) + ) + ) + ) + ) +) diff --git a/.config/eww/panel/main.yuck b/.config/eww/panel/main.yuck new file mode 100644 index 0000000..ac8b559 --- /dev/null +++ b/.config/eww/panel/main.yuck @@ -0,0 +1,142 @@ +(defwindow panel + :monitor 0 + :geometry (geometry :x 28 :y 0 :anchor "center left") + (panel)) + +(defwidget panel [] + (box + :class "panel" + :orientation "v" + :space-evenly false + (panel-audio) + (panel-video) + ) +) + +; Panel Items + +(defwidget panel-buttons [] + (box + :class "panel-buttons" + :space-evenly false + (children) + ) +) + +(defwidget panel-checkbox [?change text ?value] + (button + :onclick change + (box + :class "panel-checkbox" + :space-evenly false + (icon :name {value ? "check-square" : "square"}) + text + ) + ) +) + +(defwidget panel-slider [icon ?setter ?value] + (eventbox + ;:onscroll setter + (box + :space-evenly false + (icon :name icon) + (scale + :class "panel-slider" + :min 0 + :max 11 + :onchange setter + :value value + ) + ) + ) +) + +; Panel Sections + +(defwidget panel-section [color icon title] + (box + :class "panel-section" + :orientation "v" + :space-evenly false + (box + :class "panel-header" + :spacing 10 + :space-evenly false + (icon :name icon :color color) + title + ) + (box + :orientation "v" + :space-evenly false + :spacing 14 + (children) + ) + ) +) + +(defwidget panel-audio [] + (panel-section + :color "green" + :icon "sliders" + :title "Audio" + + ; audio device + (panel-buttons + (button :onclick "set-output -a pci-0000_00_1b" "Bar") + (button :onclick "set-output -a stereo-game" "Headset") + (button :onclick "set-output -a HD3" "Speakers") + ) + + ; volume slider + (panel-slider + :icon "volume-2" + :setter "set-volume {}" + :value volume + ) + ) +) + +(defwidget panel-video [] + (panel-section + :color "red" + :icon "monitor" + :title "Video" + + ; wallpaper setter + (eventbox + :ondropped "set-wallpaper {}" + (button + :onclick "quick-app -c Thunar -f \ + && thunar /home/edwin/.local/share/backgrounds" + (image + :class "panel-wallpaper" + :path "/home/edwin/.config/wallpaper" + :image-height 108 + :image-width 256 + ) + ) + ) + + ; brightness slider + (panel-slider + :icon "sun" + :setter "set-brightness {}" + :value brightness + ) + + ; external monitor + (panel-checkbox + :change "set-output -e ${!externalMonitor}" + :text "External Monitor" + :value externalMonitor + ) + + ; ultrawide resolution + (panel-checkbox + :change "set-output -u ${!ultrawide}" + :text "Ultrawide Resolution" + :value ultrawide + ) + ) +) diff --git a/.config/eww/panel/style.scss b/.config/eww/panel/style.scss new file mode 100644 index 0000000..0f39959 --- /dev/null +++ b/.config/eww/panel/style.scss @@ -0,0 +1,69 @@ +.panel { + background-color: $borderColor; + padding: $borderSize; + + .button { + background-color: $borderColor; + border-radius: $borderRadius; + margin-left: 10; + padding: 8; + + &:first-child { + margin-left: 0; + } + } +} + +.panel-buttons { + button { + background-color: $borderColor; + border-radius: $borderRadius; + margin-left: 14; + padding: 7 9; + + &:first-child { + margin-left: 0; + } + } +} + +.panel-checkbox { + image { + margin-right: 10; + } +} + +.panel-header { + margin-bottom: 14; +} + +.panel-section { + background-color: $bgColor; + border-radius: $borderRadius; + margin-top: $borderSize; + padding: 14; + + &:first-child { + margin-top: 0; + } +} + +.panel-slider { + margin-left: 10; + + trough { + background-color: $borderColor; + border-radius: 5; + min-height: 10px; + min-width: 232px; + + highlight { + border-radius: 5; + background-color: #414868; + } + } +} + +.panel-wallpaper { + border: 3px solid $borderColor; +} diff --git a/.config/eww/status/main.yuck b/.config/eww/status/main.yuck new file mode 100644 index 0000000..c6ebd3e --- /dev/null +++ b/.config/eww/status/main.yuck @@ -0,0 +1,44 @@ +; windows +(defwindow status + :monitor 0 + :geometry (geometry :x 0 :y 28 :anchor "top center") + (status)) + +(defwidget status [] + (box + :class "status" + :space-evenly false + :spacing 5 + (status-item :color "green" :icon "clock" :text time) + (status-item :color "yellow" :icon "calendar" :text date) + (status-item + :color "red" + :icon "thermometer" + :text "${EWW_TEMPS["CPU"]}°" + ) + (status-item + :color "blue" + :icon "cpu" + :text "${round(EWW_CPU["avg"],0)}%" + ) + (status-item + :color "purple" + :icon "database" + :text "${round(EWW_RAM["used_mem_perc"],0)}%" + ) + ) +) + +(defwidget status-item [icon ?color text] + (box + :class "status-item" + :space-evenly false + :spacing 7 + (icon :color color :name icon) + text + ) +) + +(defwidget status-seperator [] + (box :class "status-seperator") +) diff --git a/.config/eww/status/style.scss b/.config/eww/status/style.scss new file mode 100644 index 0000000..a31257e --- /dev/null +++ b/.config/eww/status/style.scss @@ -0,0 +1,14 @@ +.status { + background-color: $borderColor; + border: $borderSize solid $borderColor; +} + +.status-item { + background-color: $bgColor; + border-radius: $borderRadius; + font-family: "Inter"; + font-size: 13; + font-weight: 700; + min-width: 60px; + padding: 7; +} diff --git a/.config/hypr/autostart b/.config/hypr/autostart new file mode 100644 index 0000000..c7a5932 --- /dev/null +++ b/.config/hypr/autostart @@ -0,0 +1,54 @@ +#!/usr/bin/bash + +# Policy Authentication Agent +/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 & + +eval $(/usr/bin/gnome-keyring-daemon --start --components=gpg,pkcs11,secrets,ssh) +export $(gnome-keyring-daemon --start --components=gpg,pkcs11,secrets,ssh) + +# https://wiki.hyprland.org/FAQ/#some-of-my-apps-take-a-really-long-time-to-open +# https://gist.github.com/PowerBall253/2dea6ddf6974ba4e5d26c3139ffb7580 +systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP & +dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP --all & + +export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh + +# variables +scripts=~/.scripts + +# gsettings +gsettings set org.gnome.desktop.interface gtk-theme 'Tokyonight-Dark-BL-LB' +gsettings set org.gnome.desktop.interface font-name 'CaskaydiaCove Nerd Font 9' +gsettings set org.gnome.desktop.interface icon-theme 'Tokyonight-Moon' +gsettings set org.gnome.desktop.interface cursor-theme 'Sweet-cursors' + +# For nemo +gsettings set org.cinnamon.desktop.default-applications.terminal exec kitty + +# notification daemon +swaync & + +# waybar +$scripts/launch_waybar & +# $scripts/dynamic & + +# wallpaper +$scripts/wall ~/.config/hypr/wallpapers/1.jpg & + +# effects +# $scripts/tools/rgb & + +# Applets +blueman-applet & +nm-applet --indicator & + +# music daemon +mpd & + +# other +hyprctl setcursor Sweet-cursors 24 +wl-paste --watch cliphist store & +notify-send -a aurora "hello $(whoami)" & + +sleep 2 +mpd-mpris & diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf new file mode 100644 index 0000000..0749272 --- /dev/null +++ b/.config/hypr/hyprland.conf @@ -0,0 +1,303 @@ +monitor=, 1920x1080@60, auto, 1 + +exec-once=$HOME/.config/hypr/autostart + +$term = kitty +$browser = firefox +$gmail = firefox --new-instance -P app "https://mail.google.com/" --class appProfile +$editor = code +$explorer = nemo +$music = g4music +$notepad = code --profile notepad --unity-launch ~/Templates +$launcher = wofi --show drun -n +$launcher_alt = wofi --show run -n +#$discord = discord + + +general { + gaps_in = 5 + gaps_out = 10 + border_size = 2 + col.active_border = rgba(cba6f7ff) rgba(89b4faff) rgba(94e2d5ff) 10deg + col.inactive_border = 0xff313244 + # whether to apply the sensitivity to raw input (e.g. used by games where you aim using your mouse) + apply_sens_to_raw = 0 +} + + +input { + # kb_file = + kb_layout = us + # kb_variant = + # kb_model = + # kb_options = ctrl:swapcaps + # kb_rules = + sensitivity = 0.75 # for mouse cursor + + follow_mouse = 1 + + scroll_method = 2fg + + touchpad { + natural_scroll = false + disable_while_typing = true + tap-to-click = true + } +} + + +decoration { + rounding = 16 + multisample_edges = true + + active_opacity = 0.95 + inactive_opacity = 0.9 + fullscreen_opacity = 0.95 + + dim_inactive = false + dim_strength = 0.05 + + blur = true + blur_size = 5 + blur_passes = 4 + blur_new_optimizations = true + blur_xray = true + blur_ignore_opacity = true + + drop_shadow = true + shadow_ignore_window = true + shadow_range = 20 + shadow_render_power = 3 + col.shadow = 0x55161925 + col.shadow_inactive = 0x22161925 + # Your blur "amount" is blur_size * blur_passes, but high blur_size (over around 5-ish) will produce artifacts. + # if you want heavy blur, you need to up the blur_passes. + # the more passes, the more you can up the blur_size without noticing artifacts. + + # Blurring layerSurfaces + # blurls = gtk-layer-shell + # blurls = waybar + # blurls = lockscreen + blurls = rofi + blurls = wofi +} + + +animations { + enabled = true + # bezier = overshot, 0.05, 0.9, 0.1, 1.1 + bezier = overshot, 0.13, 0.99, 0.29, 1.1 + animation = windows, 1, 4, overshot, slide + animation = border, 1, 10, default + animation = fade, 1, 10, default + animation = workspaces, 1, 6, overshot, slidevert +} + + +dwindle { + pseudotile = true # enable pseudotiling on dwindle + force_split = 0 + col.group_border = 0xff89dceb + col.group_border_active = 0xfff9e2af + preserve_split = true +} + + +master { + +} + + +gestures { + workspace_swipe = true + workspace_swipe_invert = false + workspace_swipe_fingers = 3 +} + + +misc { + disable_hyprland_logo = true + + focus_on_activate = true + + enable_swallow = true + swallow_regex = ^(kitty)$ +} + + +binds { + allow_workspace_cycles = true +} + + +custom { + rules { + # for windows named/classed as abc and xyz + # windowrule = move 69 420, abc + # windowrule = pseudo, abc + # windowrule = monitor 0, xyz + # windowrule = tile, xy + + windowrule = float, title:^(fly_is_kitty)$ + windowrule = size 800 500, title:^(fly_is_kitty)$ + windowrule = move center, title:^(fly_is_kitty)$ + windowrule = animation slide, title:^(fly_is_kitty)$ + + windowrule = float, title:^(all_is_kitty)$ + + windowrule = float, title:^(clock_is_kitty)$ + windowrule = size 325 180, title:^(clock_is_kitty)$ + + windowrule = float, title:^(donut_is_kitty)$ + windowrule = size 660 486, title:^(donut_is_kitty)$ + + windowrule = animation popin, title:^(donut_is_kitty)$ + + windowrule = float,^(rlr)$ + windowrule = float,^(pavucontrol)$ + windowrule = float,^(blueman-manager)$ + windowrule = float,^(nm-connection-editor)$ + windowrule = float,^(mediainfo-gui)$ + windowrule = tile,^(neovide)$ + windowrulev2 = float, class:^(firefox)$, title:^(Firefox — Sharing Indicator)$ + windowrulev2 = float, class:^(nemo)$, title:^(.*Properties)$ + windowrulev2 = float, class:^(Nemo-preview-start)$ + + windowrule = float,^(com.github.neithern.g4music)$ + windowrule = size 670 635,^(com.github.neithern.g4music)$ + windowrule = move center,^(com.github.neithern.g4music)$ + + windowrulev2 = animation slide, class:^(wofi)$ + windowrulev2 = move 100%-433 53, class:^(wofi)$, title:^(clippick)$ + + windowrulev2 = animation popin, class:^(wlogout)$, title:^(wlogout)$ + windowrulev2 = float, class:^(wlogout)$, title:^(wlogout)$ + } + + binds { + # Mouse binds + bindm = SUPER, mouse:272, movewindow + bindm = SUPER, mouse:273, resizewindow + + bind = SUPER, mouse_down, workspace, e-1 + bind = SUPER, mouse_up, workspace, e+1 + + # Kitty binds + bind = ALT, RETURN, exec, kitty --start-as=fullscreen --title all_is_kitty + bind = SUPER, RETURN, exec, kitty --title fly_is_kitty --single-instance + bind = SUPER, t, exec, $term + + # Screenshot binds + bind = , Print, exec,~/.scripts/screenshot_full + bind = ALT, Print, exec,~/.scripts/screenshot + + # Application binds + bind = SUPER, Q, killactive, + bind = SUPER, F, exec, $explorer + bind = SUPER, B, exec, $browser + bind = SUPER, E, exec, $gmail + bind = SUPER, G, exec, $notepad + + # Wofi and notification binds + bind = SUPER, V, exec, pkill wofi || cliphist list | wofi --dmenu -p clippick -l top_right -x -15 -y 10 -n | cliphist decode | wl-copy + bind = SUPER, N, exec, swaync-client -t -sw + bindr = SUPER, SUPER_L, exec, pkill wofi || $launcher + bind = SUPER, space, exec, pkill wofi || $launcher_alt + + # Other dispatchers + bind = ALT, Tab, cyclenext + bind = SUPER, M, fullscreen, + bind = SUPER, C, exec, hyprctl dispatch centerwindow none + bind = SUPER_SHIFT, M, fakefullscreen, + bind = SUPER, P, pseudo, + bind = SUPER, S, togglefloating, + bind = SUPER_SHIFT, G, togglegroup, + bind = SUPER, tab, changegroupactive, + + # Reload waybar + bind = SUPER_SHIFT, R, exec,~/.scripts/launch_waybar + + # Logout screen, lock, exit + bind = SUPER, escape, exec,~/.config/wlogout/launch.sh + bind = SUPER, L, exec,~/.scripts/lock + bind = SUPER_SHIFT, escape, exit + + + # Move window with SUPER + Shift + arrow keys + # [↑] + # [←] [↓] [→] + bind = SUPER_SHIFT, left, movewindow, l + bind = SUPER_SHIFT, right, movewindow, r + bind = SUPER_SHIFT, up, movewindow, u + bind = SUPER_SHIFT, down, movewindow, d + + # Move window focus with SUPER + arrow keys + # [↑] + # [←] [↓] [→] + bind = SUPER, left, movefocus, l + bind = SUPER, right, movefocus, r + bind = SUPER, up, movefocus, u + bind = SUPER, down, movefocus, d + + # Move To a workspaces + bind = SUPER, 1, workspace, 1 + bind = SUPER, 2, workspace, 2 + bind = SUPER, 3, workspace, 3 + bind = SUPER, 4, workspace, 4 + bind = SUPER, 5, workspace, 5 + bind = SUPER, 6, workspace, 6 + bind = SUPER, 7, workspace, 7 + bind = SUPER, 8, workspace, 8 + bind = SUPER, 9, workspace, 9 + + # Move windows between workspaces + bind = SUPER_SHIFT, 1, movetoworkspace, 1 + bind = SUPER_SHIFT, 2, movetoworkspace, 2 + bind = SUPER_SHIFT, 3, movetoworkspace, 3 + bind = SUPER_SHIFT, 4, movetoworkspace, 4 + bind = SUPER_SHIFT, 5, movetoworkspace, 5 + bind = SUPER_SHIFT, 6, movetoworkspace, 6 + bind = SUPER_SHIFT, 7, movetoworkspace, 7 + bind = SUPER_SHIFT, 8, movetoworkspace, 8 + bind = SUPER_SHIFT, 9, movetoworkspace, 9 + + # Ricing :p + bind = CTRL, 1, exec, kitty --title fly_is_kitty sh -c 'cava' + bind = CTRL, 2, exec, kitty --title donut_is_kitty sh -c '~/.local/bin/donut' + bind = CTRL, 3, exec, kitty --title clock_is_kitty sh -c 'tty-clock -C5 -c' + + # Use this to get thw XF86 bind (FN + Fx combination) for your keyboard + # xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p' + + # Volume Control + binde = , XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +1% + binde = , XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -1% + bind = , XF86AudioMute, exec, pactl set-sink-mute @DEFAULT_SINK@ toggle + bind = , XF86AudioMicMute, exec, pactl set-source-mute @DEFAULT_SOURCE@ toggle + + # Media Control + bind = , XF86AudioMedia, exec, playerctl play-pause + bind = , XF86AudioPlay, exec, playerctl play-pause + bind = , XF86AudioStop, exec, playerctl stop + bind = , XF86AudioPrev, exec, playerctl previous + bind = , XF86AudioNext, exec, playerctl next + + # Brightness Control + binde = , XF86MonBrightnessUp, exec, light -A 1 + binde = , XF86MonBrightnessDown, exec, light -U 1 + + # Screensaver key + bind = , XF86ScreenSaver, exec,~/.scripts/lock + + # Others + bind = , XF86Mail, exec,$gmail + bind = , XF86HomePage, exec, $explorer ~/ + bind = , XF86Calculator, exec, qalculate-gtk + bind = , XF86Search, exec, wofi + + # trigger when the switch is turning on + # bindl = , switch:on:Lid Switch, exec, hyprctl keyword monitor ", 1920x1080@60, auto, 1" + # trigger when the switch is turning off + bindl = , switch:off:Lid Switch, exec, playerctl --all-players stop; ~/.scripts/lock; systemctl suspend + } +} diff --git a/.config/inputrc b/.config/inputrc new file mode 100644 index 0000000..8d3920c --- /dev/null +++ b/.config/inputrc @@ -0,0 +1,43 @@ +$include /etc/inputrc + +set editing-mode vi +set keymap vi-insert +"\f": clear-screen +set show-mode-in-prompt on +set vi-cmd-mode-string "\1\e[2 q\2" +set vi-ins-mode-string "\1\e[6 q\2" + +# Reduce the delay between pressing escape and the cursor change +set keyseq-timeout 0 + +#set -o vi +#lset keymap vi +#$if mode=vi + # set show-mode-in-prompt on + # set vi-ins-mode-string \1\e[6 q\2 + # set vi-cmd-mode-string \1\e[2 q\2 + +# set keymap vi-command + # these are for vi-command mode +# Control-l: clear-screen +# Control-a: beginning-of-line + +# set keymap vi-insert +# # these are for vi-insert mode +# Control-l: clear-screen +# Control-a: beginning-of-line +# # exit insert mode using <jj> +# "jj" # remap escape +#$endif + +set bell-style none +#$if mode=vi +# set keymap vi-command +# "gg": beginning-of-history +# "G": end-of-history +# set keymap vi-insert #notice how the "jj" movement is +# "jj": vi-movement-mode #after 'set keymap vi-insert'? + # "\C-w": backward-kill-word +# "\C-p": history-search-backward +#$endif + diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf new file mode 100644 index 0000000..cbf9f70 --- /dev/null +++ b/.config/kitty/kitty.conf @@ -0,0 +1,827 @@ + +# vim:fileencoding=utf-8:ft=conf:foldmethod=marker + +#: Fonts {{{ + +#: kitty has very powerful font management. You can configure +#: individual font faces and even specify special fonts for particular +#: characters. + +font_family JetBrains Mono Medium +bold_font auto +italic_font auto +bold_italic_font auto + +#: You can specify different fonts for the bold/italic/bold-italic +#: variants. By default they are derived automatically, by the OSes +#: font system. Setting them manually is useful for font families that +#: have many weight variants like Book, Medium, Thick, etc. For +#: example: + +#: font_family Operator Mono Book +#: bold_font Operator Mono Medium +#: italic_font Operator Mono Book Italic +#: bold_italic_font Operator Mono Medium Italic + +font_size 9.0 + +#: Font size (in pts) + +# adjust_line_height 0 +# adjust_column_width 0 + +#: Change the size of each character cell kitty renders. You can use +#: either numbers, which are interpreted as pixels or percentages +#: (number followed by %), which are interpreted as percentages of the +#: unmodified values. You can use negative pixels or percentages less +#: than 100% to reduce sizes (but this might cause rendering +#: artifacts). + +# symbol_map U+E0A0-U+E0A2,U+E0B0-U+E0B3 PowerlineSymbols + +#: Map the specified unicode codepoints to a particular font. Useful +#: if you need special rendering for some symbols, such as for +#: Powerline. Avoids the need for patched fonts. Each unicode code +#: point is specified in the form U+<code point in hexadecimal>. You +#: can specify multiple code points, separated by commas and ranges +#: separated by hyphens. symbol_map itself can be specified multiple +#: times. Syntax is:: + +#: symbol_map codepoints Font Family Name + +# box_drawing_scale 0.001, 1, 1.5, 2 + +#: Change the sizes of the lines used for the box drawing unicode +#: characters These values are in pts. They will be scaled by the +#: monitor DPI to arrive at a pixel value. There must be four values +#: corresponding to thin, normal, thick, and very thick lines. + +#: }}} + +#: Cursor customization {{{ + +# cursor magenta +cursor white + +#: Default cursor color + +# cursor_shape block + +#: The cursor shape can be one of (block, beam, underline) + +cursor_blink_interval 0.5 +cursor_stop_blinking_after 15.0 + +#: The interval (in seconds) at which to blink the cursor. Set to zero +#: to disable blinking. Note that numbers smaller than repaint_delay +#: will be limited to repaint_delay. Stop blinking cursor after the +#: specified number of seconds of keyboard inactivity. Set to zero to +#: never stop blinking. + +#: }}} + +#: Scrollback {{{ + +scrollback_lines 20000 + +#: Number of lines of history to keep in memory for scrolling back. +#: Memory is allocated on demand. + +# scrollback_pager less --chop-long-lines --RAW-CONTROL-CHARS +INPUT_LINE_NUMBER + +#: Program with which to view scrollback in a new window. The +#: scrollback buffer is passed as STDIN to this program. If you change +#: it, make sure the program you use can handle ANSI escape sequences +#: for colors and text formatting. INPUT_LINE_NUMBER in the command +#: line above will be replaced by an integer representing which line +#: should be at the top of the screen. + +wheel_scroll_multiplier 5 + +#: Modify the amount scrolled by the mouse wheel or touchpad. Use +#: negative numbers to change scroll direction. + +#: }}} + +#: Mouse {{{ + +url_color #0087BD +url_style curly + +#: The color and style for highlighting URLs on mouse-over. url_style +#: can be one of: none, single, double, curly + +open_url_modifiers kitty_mod + +#: The modifier keys to press when clicking with the mouse on URLs to +#: open the URL + +open_url_with default + +#: The program with which to open URLs that are clicked on. The +#: special value default means to use the operating system's default +#: URL handler. + +copy_on_select yes + +#: Copy to clipboard on select. With this enabled, simply selecting +#: text with the mouse will cause the text to be copied to clipboard. +#: Useful on platforms such as macOS/Wayland that do not have the +#: concept of primary selectons. Note that this is a security risk, +#: as all programs, including websites open in your browser can read +#: the contents of the clipboard. + +# rectangle_select_modifiers ctrl+alt + +#: The modifiers to use rectangular selection (i.e. to select text in +#: a rectangular block with the mouse) + +# select_by_word_characters :@-./_~?&=%+# + +#: Characters considered part of a word when double clicking. In +#: addition to these characters any character that is marked as an +#: alpha-numeric character in the unicode database will be matched. + +click_interval 0.5 + +#: The interval between successive clicks to detect double/triple +#: clicks (in seconds) + +# mouse_hide_wait 3.0 + +#: Hide mouse cursor after the specified number of seconds of the +#: mouse not being used. Set to zero to disable mouse cursor hiding. + +# focus_follows_mouse no + +#: Set the active window to the window under the mouse when moving the +#: mouse around + +#: }}} + +#: Performance tuning {{{ + +repaint_delay 10 + +#: Delay (in milliseconds) between screen updates. Decreasing it, +#: increases frames-per-second (FPS) at the cost of more CPU usage. +#: The default value yields ~100 FPS which is more than sufficient for +#: most uses. Note that to actually achieve 100 FPS you have to either +#: set sync_to_monitor to no or use a monitor with a high refresh +#: rate. + +# input_delay 3 + +#: Delay (in milliseconds) before input from the program running in +#: the terminal is processed. Note that decreasing it will increase +#: responsiveness, but also increase CPU usage and might cause flicker +#: in full screen programs that redraw the entire screen on each loop, +#: because kitty is so fast that partial screen updates will be drawn. + +# sync_to_monitor yes + +#: Sync screen updates to the refresh rate of the monitor. This +#: prevents tearing (https://en.wikipedia.org/wiki/Screen_tearing) +#: when scrolling. However, it limits the rendering speed to the +#: refresh rate of your monitor. With a very high speed mouse/high +#: keyboard repeat rate, you may notice some slight input latency. If +#: so, set this to no. + +#: }}} + +#: Terminal bell {{{ + +enable_audio_bell no + +#: Enable/disable the audio bell. Useful in environments that require +#: silence. + +# visual_bell_duration 0.5 + +#: Visual bell duration. Flash the screen when a bell occurs for the +#: specified number of seconds. Set to zero to disable. + +window_alert_on_bell yes + +#: Request window attention on bell. Makes the dock icon bounce on +#: macOS or the taskbar flash on linux. + +bell_on_tab yes + +#: Show a bell symbol on the tab if a bell occurs in one of the +#: windows in the tab and the window is not the currently focused +#: window + +#: }}} + +#: Window layout {{{ + +# remember_window_size yes +# initial_window_width 640 +# initial_window_height 400 + +#: If enabled, the window size will be remembered so that new +#: instances of kitty will have the same size as the previous +#: instance. If disabled, the window will initially have size +#: configured by initial_window_width/height, in pixels. You can use a +#: suffix of "c" on the width/height values to have them interpreted +#: as number of cells instead of pixels. + +enabled_layouts * + +#: The enabled window layouts. A comma separated list of layout names. +#: The special value * means all layouts. The first listed layout will +#: be used as the startup layout. For a list of available layouts, see +#: the layouts. + +# window_resize_step_cells 2 +# window_resize_step_lines 2 + +#: The step size (in units of cell width/cell height) to use when +#: resizing windows. The cells value is used for horizontal resizing +#: and the lines value for vertical resizing. + +window_border_width 1 + +#: The width (in pts) of window borders. Will be rounded to the +#: nearest number of pixels based on screen resolution. Note that +#: borders are displayed only when more than one window is visible. +#: They are meant to separate multiple windows. + +window_margin_width 0 + +#: The window margin (in pts) (blank area outside the border) + +# single_window_margin_width -1000.0 + +#: The window margin (in pts) to use when only a single window is +#: visible. Negative values will cause the value of +#: window_margin_width to be used instead. + +window_padding_width 2 + +#: The window padding (in pts) (blank area between the text and the +#: window border) + +active_border_color #282c34 + +#: The color for the border of the active window + +inactive_border_color #22262d + +#: The color for the border of inactive windows + +# bell_border_color #ff5a00 + +#: The color for the border of inactive windows in which a bell has +#: occurred + +inactive_text_alpha .6 + +#: Fade the text in inactive windows by the specified amount (a number +#: between zero and one, with zero being fully faded). + +#: }}} + +#: Tab bar {{{ + +# tab_bar_edge bottom + +#: Which edge to show the tab bar on, top or bottom + +tab_bar_margin_width 4 + +#: The margin to the left and right of the tab bar (in pts) + +tab_bar_style fade + +#: The tab bar style, can be one of: fade or separator. In the fade +#: style, each tab's edges fade into the background color, in the +#: separator style, tabs are separated by a configurable separator. + +# tab_fade 0.25 0.5 0.75 1 +tab_fade 1 1 1 + +#: Control how each tab fades into the background when using fade for +#: the tab_bar_style. Each number is an alpha (between zero and one) +#: that controls how much the corresponding cell fades into the +#: background, with zero being no fade and one being full fade. You +#: can change the number of cells used by adding/removing entries to +#: this list. + +# tab_separator " " + +#: The separator between tabs in the tab bar when using separator as +#: the tab_bar_style. + +active_tab_foreground #282c34 +active_tab_background #abb2bf +active_tab_font_style bold +inactive_tab_foreground #5c6370 +inactive_tab_background #22262d +inactive_tab_font_style normal + +#: Tab bar colors and styles + +#: }}} + +#: Color scheme {{{ + +foreground #d8dee9 +#background #1d1f21 +background #000000 + +#: The foreground and background colors + +background_opacity 0.7 +dynamic_background_opacity yes +# Increase background opacity ctrl+shift+a>m + +# Decrease background opacity ctrl+shift+a>l + +# Full background opacity ctrl+shift+a>1 + +# Reset background opacity ctrl+shift+a>d + +#: The opacity of the background. A number between 0 and 1, where 1 is +#: opaque and 0 is fully transparent. This will only work if +#: supported by the OS (for instance, when using a compositor under +#: X11). Note that it only sets the default background color's +#: opacity. This is so that things like the status bar in vim, +#: powerline prompts, etc. still look good. But it means that if you +#: use a color theme with a background color in your editor, it will +#: not be rendered as transparent. Instead you should change the +#: default background color in your kitty config and not use a +#: background color in the editor color scheme. Or use the escape +#: codes to set the terminals default colors in a shell script to +#: launch your editor. Be aware that using a value less than 1.0 is a +#: (possibly significant) performance hit. If you want to dynamically +#: change transparency of windows set dynamic_background_opacity to +#: yes (this is off by default as it has a performance cost) + +dim_opacity 1.0 + +#: How much to dim text that has the DIM/FAINT attribute set. One +#: means no dimming and zero means fully dimmed (i.e. invisible). + +selection_foreground #000000 +selection_background #FFFACD + +#: The foreground and background for text selected with the mouse + + +#: The 16 terminal colors. There are 8 basic colors, each color has a +#: dull and bright version. You can also set the remaining colors from +#: the 256 color table as color16 to color255. + +#: black +color0 #313539 +color8 #676f78 + +#: red +color1 #b02626 +color9 #b55454 + +#: green +color2 #40a62f +color10 #78a670 + +#: yellow +color3 #f2e635 +color11 #faf380 + +#: blue +color4 #314ad0 +color12 #707fd0 + +#: magenta +color5 #b30ad0 +color13 #c583d0 + +#: cyan +color6 #32d0fc +color14 #8adaf1 + +#: white +color7 #acadb1 +color15 #e0e3e7 + + +#: }}} + +#: Advanced {{{ + +# shell zsh + +#: The shell program to execute. The default value of . means to use +#: whatever shell is set as the default shell for the current user. +#: Note that on macOS if you change this, you might need to add +#: --login to ensure that the shell starts in interactive mode and +#: reads its startup rc files. + +editor . + +#: The console editor to use when editing the kitty config file or +#: similar tasks. A value of . means to use the environment variable +#: EDITOR. Note that this environment variable has to be set not just +#: in your shell startup scripts but system-wide, otherwise kitty will +#: not see it. + +# Confirm when closing where 0 disables it; -1 enables it +confirm_os_window_close 0 + +# close_on_child_death nvim + +#: Close the window when the child process (shell) exits. If no (the +#: default), the terminal will remain open when the child exits as +#: long as there are still processes outputting to the terminal (for +#: example disowned or backgrounded processes). If yes, the window +#: will close as soon as the child process exits. Note that setting it +#: to yes means that any background processes still using the terminal +#: can fail silently because their stdout/stderr/stdin no longer work. + +# allow_remote_control no + +#: Allow other programs to control kitty. If you turn this on other +#: programs can control all aspects of kitty, including sending text +#: to kitty windows, opening new windows, closing windows, reading the +#: content of windows, etc. Note that this even works over ssh +#: connections. + +# startup_session none + +#: Path to a session file to use for all kitty instances. Can be +#: overridden by using the kitty --session command line option for +#: individual instances. See sessions in the kitty documentation for +#: details. Note that relative paths are interpreted with respect to +#: the kitty config directory. Environment variables in the path are +#: expanded. + +# clipboard_control write-clipboard write-primary +clipboard_control write-primary write-clipboard no-append + +#: Allow programs running in kitty to read and write from the +#: clipboard. You can control exactly which actions are allowed. The +#: set of possible actions is: write-clipboard read-clipboard write- +#: primary read-primary The default is to allow writing to the +#: clipboard and primary selection. Note that enabling the read +#: functionality is a security risk as it means that any program, even +#: one running on a remote server via SSH can read your clipboard. + +#term xterm-kitty + +#: The value of the TERM environment variable to set. Changing this +#: can break many terminal programs, only change it if you know what +#: you are doing, not because you read some advice on Stack Overflow +#: to change it. + +#: }}} + +#: OS specific tweaks {{{ + +# macos_titlebar_color #22262d + +#: Change the color of the kitty window's titlebar on macOS. A value +#: of system means to use the default system color, a value of +#: background means to use the background color of the currently +#: active window and finally you can use an arbitrary color, such as +#: #12af59 or red. WARNING: This option works by using a hack, as +#: there is no proper Cocoa API for it. It sets the background color +#: of the entire window and makes the titlebar transparent. As such it +#: is incompatible with background_opacity. If you want to use both, +#: you are probably better off just hiding the titlebar with +#: macos_hide_titlebar. + +# macos_hide_titlebar no + +#: Hide the kitty window's title bar on macOS. + +hide_window_decorations yes + +#: Hide the window decorations (title bar and window borders) on X11 +#: and Wayland. Whether this works and exactly what effect it has +#: depends on the window manager, as it is the job of the window +#: manager/compositor to draw window decorations. + +# macos_option_as_alt yes + +#: Use the option key as an alt key. With this set to no, kitty will +#: use the macOS native Option+Key = unicode character behavior. This +#: will break any Alt+key keyboard shortcuts in your terminal +#: programs, but you can use the macOS unicode input technique. + +# macos_hide_from_tasks no + +#: Hide the kitty window from running tasks (Option+Tab) on macOS. + +# macos_quit_when_last_window_closed no + +#: Have kitty quit when all the top-level windows are closed. By +#: default, kitty will stay running, even with no open windows, as is +#: the expected behavior on macOS. + +linux_display_server x11 + +#: Choose between Wayland and X11 backends. By default, an appropriate +#: backend based on the system state is chosen automatically. Set it +#: to x11 or wayland to force the choice. + +#: }}} + +#: Keyboard shortcuts {{{ + +#: For a list of key names, see: GLFW keys +#: <http://www.glfw.org/docs/latest/group__keys.html>. The name to use +#: is the part after the GLFW_KEY_ prefix. For a list of modifier +#: names, see: GLFW mods +#: <http://www.glfw.org/docs/latest/group__mods.html> + +#: On Linux you can also use XKB key names to bind keys that are not +#: supported by GLFW. See XKB keys +#: <https://github.com/xkbcommon/libxkbcommon/blob/master/xkbcommon/xkbcommon- +#: keysyms.h> for a list of key names. The name to use is the part +#: after the XKB_KEY_ prefix. Note that you should only use an XKB key +#: name for keys that are not present in the list of GLFW keys. + +#: You can use the special action no_op to unmap a keyboard shortcut +#: that is assigned in the default configuration. + +#: You can combine multiple actions to be triggered by a single +#: shortcut, using the syntax below:: + +#: map key combine <separator> action1 <separator> action2 <separator> action3 ... + +#: For example:: + +#: map kitty_mod+e combine : new_window : next_layout + +#: this will create a new window and switch to the next available +#: layout + +#: You can use multi-key shortcuts using the syntax shown below:: + +#: map key1>key2>key3 action + +#: For example:: + +#: map ctrl+f>2 set_font_size 20 + +# kitty_mod ctrl+shift + +#: The value of kitty_mod is used as the modifier for all default +#: shortcuts, you can change it in your kitty.conf to change the +#: modifiers for all the default shortcuts. + +# clear_all_shortcuts no + +#: You can have kitty remove all shortcut definition seen up to this +#: point. Useful, for instance, to remove the default shortcuts. + +#: Clipboard {{{ + +# map cmd+c copy_to_clipboard +#map kitty_mod+c copy_to_clipboard +# map cmd+v paste_from_clipboard +#map kitty_mod+v paste_from_clipboard +#map kitty_mod+s paste_from_selection +map shift+insert paste_from_selection +# map kitty_mod+o pass_selection_to_program +map ctrl+c copy_to_clipboard +map ctrl+v paste_from_clipboard + +#: You can also pass the contents of the current selection to any +#: program using pass_selection_to_program. By default, the system's +#: open program is used, but you can specify your own, for example:: + +#: map kitty_mod+o pass_selection_to_program firefox + +#: You can pass the current selection to a terminal program running in +#: a new kitty window, by using the @selection placeholder:: + +#: map kitty_mod+y new_window less @selection + +#: }}} + +#: Scrolling {{{ + +#map kitty_mod+up scroll_line_up +#map ctrl+k scroll_line_up +#map kitty_mod+k scroll_line_up +#map kitty_mod+down scroll_line_down +#map ctrl+j scroll_line_down +#map kitty_mod+j scroll_line_down +map kitty_mod+page_up scroll_page_up +map kitty_mod+page_down scroll_page_down +map kitty_mod+b scroll_page_up +map kitty_mod+f scroll_page_down +# map kitty_mod+home scroll_home +# map kitty_mod+end scroll_end +# map kitty_mod+h show_scrollback + +#: You can send the contents of the current screen + history buffer as +#: stdin to an arbitrary program using the placeholders @text (which +#: is the plain text) and @ansi (which includes text styling escape +#: codes). For only the current screen, use @screen or @ansi_screen. +#: For example, the following command opens the scrollback buffer in +#: less in a new window:: + +#: map kitty_mod+y new_window @ansi less +G -R + +#: }}} + +#: Window management {{{ + +# map kitty_mod+enter new_window +map kitty_mod+enter no_op +map kitty_mod+enter new_window_with_cwd + +#: You can open a new window running an arbitrary program, for +#: example:: + +#: map kitty_mod+y new_window mutt + +#: You can open a new window with the current working directory set to +#: the working directory of the current window using:: + +#: map ctrl+alt+enter new_window_with_cwd + +# map cmd+n new_os_window +# map kitty_mod+n new_os_window +# map kitty_mod+w close_window +# map kitty_mod+] next_window +# map kitty_mod+[ previous_window +map kitty_mod+j previous_window +map kitty_mod+k next_window +map kitty_mod+up move_window_forward +map kitty_mod+down move_window_backward +# map kitty_mod+f move_window_forward +# map kitty_mod+b move_window_backward +# map kitty_mod+` move_window_to_top +# map kitty_mod+r start_resizing_window +# map kitty_mod+1 first_window +# map kitty_mod+2 second_window +# map kitty_mod+3 third_window +# map kitty_mod+4 fourth_window +# map kitty_mod+5 fifth_window +# map kitty_mod+6 sixth_window +# map kitty_mod+7 seventh_window +# map kitty_mod+8 eighth_window +# map kitty_mod+9 ninth_window +# map kitty_mod+0 tenth_window +#: }}} + +#: Tab management {{{ + +# map kitty_mod+right next_tab +# map kitty_mod+left previous_tab +map kitty_mod+] no_op +map kitty_mod+] next_tab +map kitty_mod+[ no_op +map kitty_mod+[ previous_tab +# map kitty_mod+t new_tab +# map kitty_mod+q close_tab +# map kitty_mod+. move_tab_forward +# map kitty_mod+, move_tab_backward +map kitty_mod+right no_op +map kitty_mod+right move_tab_forward +map kitty_mod+left no_op +map kitty_mod+left move_tab_backward +# map kitty_mod+alt+t set_tab_title +map kitty_mod+t no_op +map kitty_mod+t new_tab_with_cwd + +#: You can also create shortcuts to go to specific tabs, with 1 being +#: the first tab:: + +#: map ctrl+alt+1 goto_tab 1 +#: map ctrl+alt+2 goto_tab 2 + +#: Just as with new_window above, you can also pass the name of +#: arbitrary commands to run when using new_tab and use +#: new_tab_with_cwd. +#: }}} + +#: Layout management {{{ + +# map kitty_mod+l next_layout + +#: You can also create shortcuts to switch to specific layouts:: + +map kitty_mod+0 no_op +map kitty_mod+0 goto_layout stack +map kitty_mod+9 no_op +map kitty_mod+9 goto_layout tall +map kitty_mod+8 no_op +map kitty_mod+8 goto_layout fat +#: map ctrl+alt+t goto_layout tall +#: map ctrl+alt+s goto_layout stack +#: }}} + +#: Font sizes {{{ + +#: You can change the font size for all top-level kitty windows at a +#: time or only the current one. + +map kitty_mod+equal change_font_size all +2.0 +map kitty_mod+minus change_font_size all -2.0 +map kitty_mod+backspace change_font_size all 0 + +#: To setup shortcuts for specific font sizes:: + +#: map kitty_mod+f6 change_font_size all 10.0 + +#: To setup shortcuts to change only the current window's font size:: + +#: map kitty_mod+f6 change_font_size current 10.0 +#: }}} + +#: Select and act on visible text {{{ + +#: Use the hints kitten to select text and either pass it to an +#: external program or insert it into the terminal or copy it to the +#: clipboard. + +# map kitty_mod+e kitten hints + +#: Open a currently visible URL using the keyboard. The program used +#: to open the URL is specified in open_url_with. + +# map kitty_mod+p>f kitten hints --type path --program - + +#: Select a path/filename and insert it into the terminal. Useful, for +#: instance to run git commands on a filename output from a previous +#: git command. + +# map kitty_mod+p>shift+f kitten hints --type path + +#: Select a path/filename and open it with the default open program. + +# map kitty_mod+p>l kitten hints --type line --program - + +#: Select a line of text and insert it into the terminal. Use for the +#: output of things like: ls -1 + +# map kitty_mod+p>w kitten hints --type word --program - + +#: Select words and insert into terminal. + +# map kitty_mod+p>h kitten hints --type hash --program - + +#: Select something that looks like a hash and insert it into the +#: terminal. Useful with git, which uses sha1 hashes to identify +#: commits + + +#: The hints kitten has many more modes of operation that you can map +#: to different shortcuts. For a full description see kittens/hints. +#: }}} + +#: Miscellaneous {{{ + + +# map kitty_mod+f11 toggle_fullscreen +# map kitty_mod+u input_unicode_character +# map kitty_mod+f2 edit_config_file +# map kitty_mod+escape kitty_shell window + +#: Open the kitty shell in a new window/tab/overlay/os_window to +#: control kitty using commands. + +# map kitty_mod+a>m set_background_opacity +0.1 +# map kitty_mod+a>l set_background_opacity -0.1 +# map kitty_mod+a>1 set_background_opacity 1 +# map kitty_mod+a>d set_background_opacity default +# +# map kitty_mod+a>m set_background_opacity +0.1 +# map kitty_mod+a>l set_background_opacity -0.1 +map kitty_mod+, set_background_opacity 1 +map kitty_mod+. set_background_opacity default + +#: You can tell kitty to send arbitrary (UTF-8) encoded text to the +#: client program when pressing specified shortcut keys. For example:: + +#: map ctrl+alt+a send_text all Special text + +#: This will send "Special text" when you press the ctrl+alt+a key +#: combination. The text to be sent is a python string literal so you +#: can use escapes like \x1b to send control codes or \u21fb to send +#: unicode characters (or you can just input the unicode characters +#: directly as UTF-8 text). The first argument to send_text is the +#: keyboard modes in which to activate the shortcut. The possible +#: values are normal or application or kitty or a comma separated +#: combination of them. The special keyword all means all modes. The +#: modes normal and application refer to the DECCKM cursor key mode +#: for terminals, and kitty refers to the special kitty extended +#: keyboard protocol. + +#: Another example, that outputs a word and then moves the cursor to +#: the start of the line (same as pressing the Home key):: + +#: map ctrl+alt+a send_text normal Word\x1b[H +#: map ctrl+alt+a send_text application Word\x1bOH + +#: }}} + +map ctrl+space send_text all \x10 + +# }}} diff --git a/.config/mimeapps.list b/.config/mimeapps.list new file mode 100644 index 0000000..a82f221 --- /dev/null +++ b/.config/mimeapps.list @@ -0,0 +1,3 @@ +[Added Associations] +image/x-xcf=nitrogen.desktop; +video/mp4=vlc.desktop; diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore new file mode 100644 index 0000000..f6f2fa2 --- /dev/null +++ b/.config/nvim/.gitignore @@ -0,0 +1,4 @@ +plugin/packer_compiled.lua +startup.log +tmp +*.log diff --git a/.config/nvim/README.md b/.config/nvim/README.md new file mode 100644 index 0000000..2849262 --- /dev/null +++ b/.config/nvim/README.md @@ -0,0 +1,33 @@ +## Neovim + +#### Dependencies + +nvm +nvm install --lts + +#### TODOS: + +- [ ] Markdown filetype plugin or autocommand to add two spaces each line +- [ ] Markdown filetype plugin or autocommand to make backtick auto-correct properly +- [x] Indent by filetype/fix global indent (2) +- [x] Check history or telescope history of last files edited or opened. +- [ ] - Windows native support configuration +- [ ] - Python debugger +- [ ] README file heirachcy +- [ ] Markdown snippet for code blocks with list, ie.- ``and -` ` +- [ ] Snippet for filler text with variations, ie. common sentences: The quick brown fox... and more and placeholder words +- [ ] Configure snippets.lua +- [ ] Documentation shortcuts for different languages quote in quote "locally" (preffered) or opening web browser +- [ ] Dictionary, an actual dictionary +- [ ] Null-ls/lsp keymap to check current buffer servers must check both same time + > NOTE: Different servers must be configured only to one or another, research null-ls being archived +- [ ] Don't highlight whitespaces in lazygit (maybe exclusively markdown) +- [ ] Configure prettier/prettierd servers to join a lot of different files (null-ls) +- [ ] Nvim-tree preview window similar to telescope +- [x] Nvim-tree behaviour when delete current buffer + > NOTE: One idea is to create an autocmd to make a blank window (hidden) as a secondary window but when creating a opening a new file it does not ask which split to open in +- [ ] Nvim-tree conditionally when open going in the opposite direction will go back to nvim-tree ie. going right then goes to nvim-tree but is conditionally because of tmux etc... +- [x] Substitute keybinding +- [ ] Snippet/filetype plugin for markdown tick boxes +- [ ] Delete lua/user/func.lua +- [ ] Clean entire config by prioritizing single quotation marks over double diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua new file mode 100644 index 0000000..718a871 --- /dev/null +++ b/.config/nvim/after/ftplugin/markdown.lua @@ -0,0 +1,16 @@ +vim.wo.spell = true +vim.bo.spelllang = "en" +vim.wo.wrap = true +vim.wo.linebreak = true +vim.wo.breakindent = true +vim.wo.colorcolumn = "0" +vim.wo.conceallevel = 3 +vim.opt.softtabstop = 2 -- Tab key indents by 2 spaces. +vim.opt.shiftwidth = 2 -- >> indents by 2 spaces. + +vim.b[0].undo_ftplugin = "setlocal nospell nowrap nolinebreak nobreakindent conceallevel=0" + +vim.cmd([[ + autocmd FileType markdown iabbrev <buffer> `` `` +]]) + diff --git a/.config/nvim/autoload/utils.vim b/.config/nvim/autoload/utils.vim new file mode 100644 index 0000000..23a9178 --- /dev/null +++ b/.config/nvim/autoload/utils.vim @@ -0,0 +1,237 @@ +" Toggle Zoom +function! utils#ZoomToggle() + if exists('t:zoomed') && t:zoomed + execute t:zoom_winrestcmd + let t:zoomed = 0 + else + let t:zoom_winrestcmd = winrestcmd() + resize + vertical resize + let t:zoomed = 1 + endif +endfunction +"command! ZoomToggle call ZoomToggle() + + +"------------------------------------------------- + +" Toggle DiagnosticsOpenFloat +function! utils#ToggleDiagnosticsOpenFloat() + " Switch the toggle variable + let g:DiagnosticsOpenFloat = !get(g:, 'DiagnosticsOpenFloat', 1) + + " Reset group + augroup OpenFloat + autocmd! + augroup END + + " Enable if toggled on + if g:DiagnosticsOpenFloat + augroup OpenFloat + autocmd! CursorHold * lua vim.diagnostic.open_float(nil, {focusable = false,}) + "autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) + "autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) print ("vim.diagnostic.open_float enabled...") + augroup END + endif +endfunction +"command! ToggleDiagonsticsOpenFloat call ToggleDiagnosticsOpenFloat() + + +"------------------------------------------------- + +" Toggle transparency +let t:is_transparent = 0 +function! utils#Toggle_transparent_background() + if t:is_transparent == 0 + hi Normal guibg=#111111 ctermbg=black + let t:is_transparent = 1 + else + hi Normal guibg=NONE ctermbg=NONE + let t:is_transparent = 0 + endif +endfunction +"nnoremap <leader>tb :call Toggle_transparent_background()<CR> + + +"------------------------------------------------- + +" Toggle statusline +let s:hidden_all = 0 +function! utils#ToggleHiddenAll() + if s:hidden_all == 0 + let s:hidden_all = 1 + set noshowmode + set noruler + set laststatus=0 + set noshowcmd + else + let s:hidden_all = 0 + set showmode + set ruler + set laststatus=2 + set showcmd + endif +endfunction +"nnoremap <S-h> :call ToggleHiddenAll()<CR> + + +"------------------------------------------------- + +" Open last closed buffer +function! OpenLastClosed() + let last_buf = bufname('#') + if empty(last_buf) + echo "No recently closed buffer found" + return + endif + let result = input("Open ". last_buf . " in (n)ormal (v)split, (t)ab or (s)plit ? (n/v/t/s) : ") + if empty(result) || (result !=# 'v' && result !=# 't' && result !=# 's' && result !=# 'n') + return + endif + if result ==# 't' + execute 'tabnew' + elseif result ==# 'v' + execute "vsplit" + elseif result ==# 's' + execute "split" + endif + execute 'b ' . last_buf +endfunction + + +"------------------------------------------------- + +" Toggle Diff +let g:diff_is_open = 0 + +function! utils#ToggleDiff() + if g:diff_is_open + windo diffoff + let g:diff_is_open = 0 + else + windo diffthis + let g:diff_is_open = 1 + endif +endfunction + + +"------------------------------------------------- + +" Verbose Toggle +function! utils#VerboseToggle() + if !&verbose + set verbosefile=~/.config/nvim/verbose.log + set verbose=15 + else + set verbose=0 + set verbosefile= + endif +endfunction + + +"------------------------------------------------- + +" Jump List +function! utils#GotoJump() + jumps + let j = input("Please select your jump: ") + if j != '' + let pattern = '\v\c^\+' + if j =~ pattern + let j = substitute(j, pattern, '', 'g') + execute "normal " . j . "\<c-i>" + else + execute "normal " . j . "\<c-o>" + endif + endif +endfunction + + +"------------------------------------------------- + +" Disable annoying auto line break +fu! utils#DisableBr() + set wrap + set linebreak + set nolist " list disables linebreak + set textwidth=0 + set wrapmargin=0 + set formatoptions-=t +endfu + +" Disable line breaks for all file types +autocmd! BufNewFile,BufRead *.* call utils#DisableBr() + + +"------------------------------------------------- + +" Annoying timestamp issue on write (The file has been changed since reading it...) +"function! utils#ProcessFileChangedShell() +" if v:fcs_reason == 'mode' || v:fcs_reason == 'time' +" let v:fcs_choice = '' +" else +" let v:fcs_choice = 'ask' +" endif +"endfunction +"autocmd FileChangedShell <buffer> call utils#ProcessFileChangedShell() +" +"let lastline = line('$') +"let bufcontents = getline(1, lastline) +"edit! +"call setline(1, bufcontents) +"if line('$') > lastline +" execute lastline+1.',$:d _' +"endif + +" Annoying timestamp issue on write (The file has been changed since reading it...) +function! utils#ProcessFileChangedShell() + if v:fcs_reason == 'mode' || v:fcs_reason == 'time' + let v:fcs_choice = '' + else + let v:fcs_choice = 'ask' + endif +endfunction + +" Triggered when the file is changed externally +autocmd FileChangedShell <buffer> call utils#ProcessFileChangedShell() + +" Triggered before writing the buffer to the file +autocmd BufWritePre <buffer> call utils#BeforeWrite() + +function! utils#BeforeWrite() + let lastline = line('$') + let bufcontents = getline(1, lastline) + edit! + call setline(1, bufcontents) + if line('$') > lastline + execute lastline+1.',$:d _' + endif +endfunction + + +"------------------------------------------------- + +" On The Fly Table mode +function! s:isAtStartOfLine(mapping) + let text_before_cursor = getline('.')[0 : col('.')-1] + let mapping_pattern = '\V' . escape(a:mapping, '\') + let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\') + return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$') +endfunction + + +"------------------------------------------------- + +" :Rename {newname} +function! utils#RenameFile() + let old_name = expand('%') + let new_name = input('New file name: ', expand('%'), 'file') + if new_name != '' && new_name != old_name + exec ':saveas ' . new_name + exec ':silent !rm ' . old_name + redraw! + endif +endfunction + + +"------------------------------------------------- diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..0ab542c --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,144 @@ +--[[ + ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ + ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ + ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ + ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ + ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + " ------------------------------------------------ + Author: srdusr + Email: trevorgray@srdusr.com + Url: https://github.com/srdusr/nvim.git + ------------------------------------------------ " +--]] +--[[init.]] +-- ========================================================================== -- +-- == DEPENDENCIES == -- +-- ========================================================================== -- + +-- ripgrep - https://github.com/BurntSushi/ripgrep +-- fd - https://github.com/sharkdp/fd +-- git - https://git-scm.com/ +-- make - https://www.gnu.org/software/make/ +-- c compiler - gcc or tcc or zig + +-- -------------------------------------------------------------------------- -- + +-- ================================== -- +-- == Install neovim-nightly == -- +-- ================================== -- + +-- Download nvim-linux64.tar.gz: +--$ curl -L -o nvim-linux64.tar.gz https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz +-- Extract: +--$ tar xzvf nvim-linux64.tar.gz --install-dir=/bin +-- Run: +--$ ./nvim-linux64/bin/nvim + +-- ---------------------------------- -- + +-- Initialize config with this one liner in the terminal +--$ nvim --headless -c 'call mkdir(stdpath("config"), "p") | exe "edit" stdpath("config") . "/init.lua" | write | quit' + +-- Command to see startup time +--$ nvim --startuptime startup.log -c exit && tail -100 startup.log + +-- Load impatient (Faster loading times) +local impatient_ok, impatient = pcall(require, 'impatient') +if impatient_ok then + impatient.enable_profile() +end + +-- Schedule reading shadafile to improve the startup time +vim.opt.shadafile = 'NONE' +vim.schedule(function() + vim.opt.shadafile = '' + vim.cmd('silent! rsh') +end) + +-- Load/reload modules +local modules = { + 'user.pack', -- Packer plugin manager + 'user.opts', -- Options + 'user.keys', -- Keymaps + 'user.mods', -- Modules/functions + 'user.view', -- Colorscheme/UI + 'plugins.treesitter', + 'plugins.neodev', + 'plugins.telescope', + 'plugins.nvim-tree', + 'plugins.web-devicons', + 'plugins.cmp', + 'plugins.quickfix', + --"plugins.snippets", + --"plugins.colorizer", + --"plugins.prettier", + --"plugins.git", + 'plugins.lsp', + --"plugins.fugitive", + 'plugins.gitsigns', + 'plugins.sniprun', + 'plugins.session', + 'plugins.neoscroll', + 'plugins.statuscol', + 'plugins.trouble', + 'plugins.goto-preview', + 'plugins.autopairs', + 'plugins.navic', + 'plugins.toggleterm', + 'plugins.zen-mode', + 'plugins.fidget', + 'plugins.dap', + 'plugins.neotest', + 'plugins.heirline', + 'plugins.dashboard', + 'plugins.which-key', + 'plugins.harpoon', + 'plugins.leetcode', + --'plugins.notify', + --"plugins.modify-blend", +} + +-- Refresh module cache +for k, v in pairs(modules) do + package.loaded[v] = nil + require(v) +end + +-- Improve speed by disabling some default plugins/modules +local builtins = { + 'gzip', + 'zip', + 'zipPlugin', + 'tar', + 'tarPlugin', + 'getscript', + 'getscriptPlugin', + 'vimball', + 'vimballPlugin', + '2html_plugin', + --"matchit", + --"matchparen", + 'logiPat', + 'rrhelper', + 'netrw', + 'netrwPlugin', + 'netrwSettings', + 'netrwFileHandlers', + 'tutor_mode_plugin', + 'fzf', + 'spellfile_plugin', + 'sleuth', +} + +for _, plugin in ipairs(builtins) do + vim.g['loaded_' .. plugin] = 1 +end +vim.g.do_filetype_lua = 1 +vim.g.did_load_filetypes = 0 + +-- Snippets +--vim.g.snippets = 'luasnip' + +-- Notifications +vim.notify = require('notify') -- Requires plugin "rcarriga/nvim-notify" diff --git a/.config/nvim/lua/plugins/autopairs.lua b/.config/nvim/lua/plugins/autopairs.lua new file mode 100644 index 0000000..90c6d35 --- /dev/null +++ b/.config/nvim/lua/plugins/autopairs.lua @@ -0,0 +1,42 @@ +local status_ok, npairs = pcall(require, "nvim-autopairs") +if not status_ok then + return +end + +npairs.setup { + check_ts = true, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + map = "<M-e>", + pairs_map = { +['<'] = '>', +}, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + disable_in_macro = true, + disable_in_visualblock = true, + enable_moveright = true, + enable_afterquote = true, -- add bracket pairs after quote + enable_check_bracket_line = false, --- check bracket in same line + enable_bracket_in_quote = true, -- + break_undo = true, -- switch for basic rule break undo sequence + fast_wrap = { + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, +} + +local cmp_autopairs = require "nvim-autopairs.completion.cmp" +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) diff --git a/.config/nvim/lua/plugins/cmp-gh-source.lua b/.config/nvim/lua/plugins/cmp-gh-source.lua new file mode 100644 index 0000000..4990c35 --- /dev/null +++ b/.config/nvim/lua/plugins/cmp-gh-source.lua @@ -0,0 +1,70 @@ +local ok, Job = pcall(require, 'plenary.job') +if not ok then + return +end + +local source = {} + +source.new = function() + local self = setmetatable({ cache = {} }, { __index = source }) + + return self +end + +source.complete = function(self, _, callback) + local bufnr = vim.api.nvim_get_current_buf() + + -- This just makes sure that we only hit the GH API once per session. + -- + -- You could remove this if you wanted, but this just makes it so we're + -- good programming citizens. + if not self.cache[bufnr] then + Job:new({ + -- Uses `gh` executable to request the issues from the remote repository. + 'gh', + 'issue', + 'list', + '--limit', + '1000', + '--json', + 'title,number,body', + + on_exit = function(job) + local result = job:result() + local ok, parsed = pcall(vim.json.decode, table.concat(result, '')) + if not ok then + vim.notify('Failed to parse gh result') + return + end + + local items = {} + for _, gh_item in ipairs(parsed) do + gh_item.body = string.gsub(gh_item.body or '', '\r', '') + + table.insert(items, { + label = string.format('#%s', gh_item.number), + documentation = { + kind = 'markdown', + value = string.format('# %s\n\n%s', gh_item.title, gh_item.body), + }, + }) + end + + callback({ items = items, isIncomplete = false }) + self.cache[bufnr] = items + end, + }):start() + else + callback({ items = self.cache[bufnr], isIncomplete = false }) + end +end + +source.get_trigger_characters = function() + return { '#' } +end + +source.is_available = function() + return vim.bo.filetype == 'gitcommit' +end + +require('cmp').register_source('gh_issues', source.new()) diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua new file mode 100644 index 0000000..edf57de --- /dev/null +++ b/.config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,332 @@ + +-- Setup nvim-cmp. +vim.opt.completeopt = "menu,menuone,noselect" +--vim.g.completeopt = "menu,menuone,noselect,noinsert" +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +--local WIDE_HEIGHT = 40 + +local opts = { + -- whether to highlight the currently hovered symbol + -- disable if your cpu usage is higher than you want it + -- or you just hate the highlight + -- default: true + highlight_hovered_item = true, + show_guides = true, +} +require("symbols-outline").setup(opts) + + +--local snippets_paths = function() +-- local plugins = { "friendly-snippets" } +-- local paths = {} +-- local path +-- local root_path = vim.env.HOME .. "/.vim/plugged/" +-- for _, plug in ipairs(plugins) do +-- path = root_path .. plug +-- if vim.fn.isdirectory(path) ~= 0 then +-- table.insert(paths, path) +-- end +-- end +-- return paths +--end +-- +--require("luasnip.loaders.from_vscode").lazy_load({ +-- paths = snippets_paths(), +-- include = nil, -- Load all languages +-- exclude = {}, +--}) + +--require("luasnip.loaders.from_vscode").lazy_load() +local lspkind = require("lspkind") +local kind_icons = { + Text = "", + Method = "m", --"", + Function = "", + Constructor = "", --"⚙️", + Field = "", + Variable = "", + Class = "ﴯ", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", +} +cmp.setup({ + snippet = { + --expand = function(args) + -- require("luasnip").lsp_expand(args.body) + --end, + expand = function(args) + local luasnip = require("luasnip") + if not luasnip then + return + end + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ +-- ["<CR>"] = cmp.mapping.confirm({ +-- behavior = cmp.ConfirmBehavior.Replace, +-- select = true, +-- }), + --["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), + --["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), + ['<C-y>'] = cmp.mapping.confirm({ select = true }), + --["<C-e>"] = cmp.mapping.close(), + --['<C-e>'] = cmp.mapping({ + -- i = cmp.mapping.abort(), + -- c = cmp.mapping.close(), + --}), + ["<C-e>"] = cmp.mapping({ + i = function() + if cmp.visible() then + cmp.abort() + require("user.mods").toggle_completion() + require("notify")("completion off") + else + cmp.complete() + require("user.mods").toggle_completion() + require("notify")("completion on") + end + end, + }), + --["<CR>"] = cmp.mapping({ + -- i = function(fallback) + -- if cmp.visible() then + -- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + -- require("user.mods").toggle_completion() + -- else + -- fallback() + -- end + -- end, + --}), + +-- ["<C-e>"] = cmp.mapping({ +-- i = function() +-- if cmp.visible() then +-- require("notify")("visible") +-- cmp.abort() +-- else +-- require("notify")("not visible") +-- cmp.complete() +-- end +-- end, +-- c = function() +-- if cmp.visible() then +-- require("notify")("visible") +-- cmp.close() +-- else +-- require("notify")("not visible") +-- cmp.complete() +-- end +-- end, +-- }), + --['<CR>'] = cmp.config.disable, + ["<C-u>"] = cmp.mapping.scroll_docs(-4), + ["<C-d>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), + --['<C-o>'] = function(fallback) + -- if cmp.visible() then + -- cmp.mapping.confirm({ select = true })(fallback) + -- else + -- cmp.mapping.complete()(fallback) + -- end + --end + }), + + sources = cmp.config.sources({ + --{ name = "nvim_lua" }, + { name = "luasnip" }, + --{ name = 'luasnip', option = { use_show_condition = false } }, + { name = "gh_issues" }, + { name = "nvim_lsp", max_item_count = 6 }, + { name = "nvim_lua" }, + --{ name = "luasnip" }, + --{ name = "luasnip", keyword_length = 4 }, + --{ name = "buffer", keyword_length = 3 }, + { name = "path" }, + { name = "buffer", max_item_count = 6 }, + --{ name = "buffer", option = { get_bufnrs = function() + -- return vim.api.nvim_list_bufs() + --end + --}}, + { name = "cmp_git"}, + { name = "spell"}, + { name = "zsh" }, + { name = "treesitter" }, + { name = "calc" }, + { name = "nvim_lsp_signature_help" }, + --{ name = "cmdline" }, + --{ name = 'treesitter' }, + --{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=] }, --exclamation mark hangs a bit without this + --{name = 'luasnip', keyword_length = 2}, + }), + formatting = { + --formatting = { + --local icons = kind_icons + --format = function(entry, vim_item) + ----vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + ----vim_item.kind = lspkind.presets.default[vim_item.kind] + --vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + ----vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) + --vim_item.menu = ({ + ----nvim_lsp = "LSP", + ----luasnip = "snip", + ----buffer = "buf", + ----path = "path", + ----cmdline = "cmd", + --buffer = "[buf]", + --nvim_lsp = "[LSP]", + --nvim_lua = "[api]", + --path = "[path]", + --luasnip = "[snip]", + --cmdline = "[cmd]", + --gh_issues = "[issues]", + --})[entry.source.name] + --return vim_item + --end, + format = lspkind.cmp_format { + with_text = true, + menu = { + nvim_lsp = "[LSP]", + luasnip = "[snip]", + buffer = "[buf]", + nvim_lua = "[api]", + path = "[path]", + gh_issues = "[issues]", + spell = "[spell]", + zsh = "[zsh]", + treesitter = "[treesitter]", + calc = "[calc]", + nvim_lsp_signature_help = "[signature]", + cmdline = "[cmd]" + + }, + }, + --}, + + -- + -- + --fields = { "abbr", "kind", "menu" }, + -- format = lspkind.cmp_format({ + -- mode = 'symbol_text', -- show only symbol annotations + -- maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + -- }) + --format = require('lspkind').cmp_format { + -- with_text = true, + -- menu = { + -- luasnip = "Snip", + -- buffer = "Buf", + -- nvim_lsp = "LSP", + -- path = "Path", + -- cmdline = "Cmd", + -- cmp_git = "Git", + -- }, + --}, + }, + --format = function(entry, vim_item) + -- -- Kind icons + -- --vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- vim_item.kind = lspkind.presets.default[vim_item.kind] + -- -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + -- vim_item.menu = ({ + -- nvim_lsp = "LSP", + -- luasnip = "Snip", + -- buffer = "Buf", + -- path = "Path", + -- cmdline = "Cmd", + -- })[entry.source.name] + -- return vim_item + --end, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + + + event = {}, + + experimental = { + ghost_text = true, -- this feature conflicts with copilot.vim's preview. + hl_group = 'Nontext', + --native_menu = false, + }, + + view = { + entries = { name = 'custom', selection_order = 'top_down' }, + }, + + window = { + --completion = cmp.config.window.bordered(), + completion = { + border = { '', '', '', ' ', '', '', '', ' ' }, + --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + --border = { '', '', '', '', '', '', '', '' }, + --border = "CmpBorder", + winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None', + --winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", + }, + --documentation = cmp.config.window.bordered(), + documentation = { + --max_height = math.floor(WIDE_HEIGHT * (WIDE_HEIGHT / vim.o.lines)), + --max_width = math.floor((WIDE_HEIGHT * 2) * (vim.o.columns / (WIDE_HEIGHT * 2 * 16 / 9))), + border = { '', '', '', ' ', '', '', '', ' ' }, + --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + winhighlight = 'FloatBorder:NormalFloat', + }, + }, +}) + + +cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, +}) + +cmp.setup.cmdline(":", { + mapping = { + ["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), + ["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), + ["<C-y>"] = cmp.mapping(cmp.mapping.confirm({ select = true }), { 'i', 'c' }), + ["<C-e>"] = cmp.mapping(cmp.mapping.close(), { 'i', 'c' }), + ["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + ["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + --["<C-k>"] = cmp.mapping.select_prev_item(), + --["<C-j>"] = cmp.mapping.select_next_item(), + --['<C-y>'] = cmp.mapping.confirm({ select = true }), + --["<C-e>"] = cmp.mapping.close(), + ----['<CR>'] = cmp.config.disable, + --["<C-u>"] = cmp.mapping.scroll_docs(-4), + --["<C-d>"] = cmp.mapping.scroll_docs(4), + --["<C-Space>"] = cmp.mapping.complete(), + }, + + sources = cmp.config.sources({ + { name = "path" }, + }, { + --{ name = "cmdline" }, + { name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=], keyword_length = 3 }, + }) +}) + + diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..be78ac8 --- /dev/null +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,344 @@ +--local function MyHighlights() +-- vim.cmd('highlight Visual cterm=NONE ctermbg=76 ctermfg=16 gui=NONE guibg=#5fd700 guifg=#000000') +-- vim.cmd('highlight StatusLine cterm=NONE ctermbg=231 ctermfg=160 gui=NONE guibg=#ffffff guifg=#d70000') +-- vim.cmd('highlight Normal cterm=NONE ctermbg=17 gui=NONE guibg=#00005f') +-- vim.cmd('highlight NonText cterm=NONE ctermbg=17 gui=NONE guibg=#00005f') +--end +-- +--local function setupMyColors() +-- vim.cmd('augroup MyColors') +-- vim.cmd('autocmd!') +-- vim.cmd('autocmd ColorScheme * call v:lua.MyHighlights()') +-- vim.cmd('augroup END') +--end +-- +--setupMyColors() + +--vim.api.nvim_command("highlight FoldColumn guibg=none") + +--vim.api.nvim_command("highlight SignColumn guifg=none guibg=none cterm=NONE ctermfg=none ctermbg=NONE gui=NONE") +--vim.api.nvim_command("highlight ColorColumn guifg=none guibg=none cterm=NONE ctermfg=none ctermbg=NONE gui=NONE") +--vim.api.nvim_command("highlight TabLineSel guibg=none guifg=none gui=bold") +--vim.api.nvim_command("highlight TabLineNC guibg=none gui=bold") +--vim.api.nvim_command("highlight StatusLine guibg=#333842 gui=bold") +--vim.api.nvim_command("highlight StatusLineNC guibg=none ctermfg=Cyan guifg=#80a0ff gui=bold") + +-- Custom colorscheme +--vim.cmd([[ +-- let g:terminal_color_0 = '#2e3436' +-- let g:terminal_color_1 = '#cc0000' +-- let g:terminal_color_2 = '#4e9a06' +-- let g:terminal_color_3 = '#c4a000' +-- let g:terminal_color_4 = '#3465a4' +-- let g:terminal_color_5 = '#75507b' +-- let g:terminal_color_6 = '#0b939b' +-- let g:terminal_color_7 = '#d3d7cf' +-- let g:terminal_color_8 = '#555753' +-- let g:terminal_color_9 = '#ef2929' +-- let g:terminal_color_10 = '#8ae234' +-- let g:terminal_color_11 = '#fce94f' +-- let g:terminal_color_12 = '#729fcf' +-- let g:terminal_color_13 = '#ad7fa8' +-- let g:terminal_color_14 = '#00f5e9' +-- let g:terminal_color_15 = '#eeeeec' +-- +-- set background=dark +-- execute "silent! colorscheme base16-eighties" +-- highlight Comment guifg=#585858 +-- highlight Normal guifg=#999999 +-- "highlight TabLine guifg=#333333 guibg=#777777 +-- "highlight TabLineSel guifg=#FA7F7F +-- highlight MatchParen gui=bold guibg=black guifg=limegreen +--]]) +--local colors = { +-- background = '#1c1c1c', +-- foreground = '#cacaca', +-- accent = '#fe5186', +-- blue = '#61afef', +-- cyan = '#3e8fb0', +-- dark_green = '#5faf5f', +-- dark_grey = '#222222', +-- dark_orange = '#ff5d62', +-- dark_red = '#bf1131', +-- dark_yellow = '#ffaf00', +-- green = '#98c379', +-- grey = '#2a2a2a', +-- light_grey = '#727169', +-- light_orange = '#ffa066', +-- light_pink = '#e46876', +-- light_yellow = '#e6db74', +-- magenta = '#c678dd', +-- orange = '#ff8700', +-- purple = '#af87d7', +-- red = '#c4384b', +-- violet = '#a9a1e1', +-- white = '#e3e3e3', +-- yellow = '#d7af5f', +--} +---- Base highlights to override themes to my preferences +--local base = { +-- CursorLine = { bg = 'none', fg = 'none' }, +-- -- Avoid changing the foreground color from the main theme +-- MatchParen = { fg = colors.accent, bg = 'none', bold = true }, +-- Visual = { bg = colors.grey, fg = 'none' }, +-- ActionPreviewBorder = { link = 'XMenuBorder' }, +-- ActionPreviewNormal = { link = 'XMenu' }, +-- CallHierarchyBorder = { link = 'XMenuBorder' }, +-- CallHierarchyNormal = { link = 'XMenu' }, +-- CodeActionBorder = { link = 'XMenuBorder' }, +-- CodeActionNormal = { link = 'XMenu' }, +-- DefinitionBorder = { link = 'XMenuBorder' }, +-- DefinitionNormal = { link = 'XMenu' }, +-- EndOfBuffer = { fg = colors.background }, +-- FinderBorder = { link = 'XMenuBorder' }, +-- FinderNormal = { link = 'XMenu' }, +-- FloatBorder = { link = 'XMenuBorder' }, +-- FloatNormal = { link = 'XMenu' }, +-- HoverBorder = { link = 'XMenuBorder' }, +-- HoverNormal = { link = 'XMenu' }, +-- NormalFloat = { link = 'XMenu' }, +-- OutlinePreviewBorder = { link = 'XMenuBorder' }, +-- OutlinePreviewNormal = { link = 'XMenu' }, +-- Pmenu = { link = 'XMenu' }, +-- RenameBorder = { link = 'XMenuBorder' }, +-- RenameNormal = { link = 'XMenu' }, +-- TerminalBorder = { link = 'XMenuBorder' }, +-- TerminalNormal = { link = 'XMenu' }, +-- Todo = { fg = colors.orange, bold = true }, +-- SagaNormal = { link = 'XMenu' }, +-- SagaBorder = { link = 'XMenuBorder' }, +-- StatusLine = { bg = colors.background, fg = colors.foreground }, +-- TitleString = { link = 'XMenu' }, +-- TitleIcon = { link = 'XMenu' }, +-- ActionPreviewTitle = { link = 'XMenu' }, +-- -- Mason +-- MasonHeader = { link = 'XMenu' }, +-- MasonNormal = { link = 'XMenu' }, +-- NvimTreeCursorColumn = { bg = 'none', fg = 'none' }, +-- --NvimTreeCursorLine = { bg = colors.dark_grey, fg = colors.accent }, +-- -- Telescope +-- TelescopeBorder = { link = 'XMenuBorder' }, +-- TelescopePromptBorder = { link = 'XMenuBorder' }, +-- TelescopePromptNormal = { link = 'XMenu', fg = colors.foreground }, +-- TelescopePromptPrefix = { link = 'XMenu', fg = colors.foreground }, +-- TelescopeNormal = { bg = colors.background }, +-- TelescopePreviewBorder = { link = 'XMenuBorder' }, +-- TelescopePreviewNormal = { link = 'XMenu', fg = colors.foreground }, +-- TelescopePreviewTitle = { fg = colors.background, bg = colors.light_orange }, +-- TelescopePreviewLine = { fg = colors.background, bg = colors.orange }, +-- TelescopePromptTitle = { fg = colors.background, bg = colors.light_orange }, +-- TelescopeResultsTitle = { fg = colors.background, bg = colors.light_orange }, +-- TelescopeResultsBorder = { link = 'XMenuBorder' }, +-- TelescopeResultsNormal = { link = 'XMenu' }, +--} +-- +--local theme = { +-- -- Transparent background +-- Conceal = { bg = 'none', fg = colors.foreground }, +-- FoldCoumn = { bg = 'none' }, +-- LineNr = { bg = 'none', fg = colors.grey }, +-- MsgArea = { bg = 'none', fg = colors.foreground }, +-- NonText = { bg = 'none', fg = colors.light_grey }, +-- Normal = { bg = 'none', fg = colors.foreground }, +-- NormalNC = { bg = 'none', fg = colors.foreground }, +-- SignColumn = { bg = 'none' }, +-- WinSeparator = { bg = 'none', fg = colors.grey }, +-- -- Language Syntax +-- Boolean = { fg = colors.grey }, +-- Character = { fg = colors.yellow }, +-- Comment = { fg = colors.light_grey }, +-- Conditional = { fg = colors.blue }, +-- Constant = { fg = colors.grey }, +-- Debug = { fg = colors.green }, +-- Define = { fg = colors.green }, +-- Delimiter = { fg = colors.grey }, +-- Error = { fg = colors.red }, +-- Exception = { fg = colors.dark_orange }, +-- Float = { fg = colors.light_pink }, +-- Function = { fg = colors.foreground }, +-- Identifier = { fg = colors.foreground }, +-- Ignore = { fg = colors.light_grey }, +-- Include = { fg = colors.dark_orange }, +-- Keyword = { fg = colors.blue }, +-- Label = { fg = colors.grey }, +-- Macro = { fg = colors.dark_orange }, +-- Number = { fg = colors.light_pink }, +-- Operator = { fg = colors.purple }, +-- PreCondit = { fg = colors.dark_orange }, +-- PreProc = { fg = colors.dark_orange }, +-- Repeat = { fg = colors.blue }, +-- Special = { fg = colors.dark_orange }, +-- SpecialChar = { fg = colors.dark_orange }, +-- SpecialComment = { fg = colors.orange }, +-- Statement = { fg = colors.blue }, +-- StorageClass = { fg = colors.light_orange }, +-- String = { fg = colors.yellow }, +-- Structure = { fg = colors.light_orange }, +-- Tag = { fg = colors.orange }, +-- Todo = { fg = colors.orange, bold = true }, +-- Type = { fg = colors.light_orange }, +-- Typedef = { fg = colors.foreground }, +-- Underlined = { fg = colors.foreground }, +-- -- Rest +-- ColorColumn = { bg = colors.dark_grey }, +-- Cursor = { bg = colors.accent }, +-- CursorColumn = { bg = 'none', fg = colors.accent }, +-- CursorLine = { bg = 'none', fg = 'none' }, +-- CursorLineNr = { bg = 'none', fg = colors.light_pink }, +-- Directory = { fg = colors.cyan, bold = true }, +-- ErrorMsg = { bg = 'none', fg = colors.red }, +-- IncSearch = { bg = colors.accent, fg = colors.foreground }, +-- MatchParen = { fg = colors.accent, bg = 'none', bold = true }, +-- Search = { bg = colors.accent }, +-- SpellBad = { bg = 'none', fg = 'none', undercurl = true, ctermbg = 'none', ctermfg = 'none' }, +-- SpellLocal = { bg = 'none', fg = 'none', undercurl = true, ctermbg = 'none', ctermfg = 'none' }, +-- SpellRare = { bg = 'none', fg = 'none', undercurl = true, ctermbg = 'none', ctermfg = 'none' }, +-- StatusLine = { fg = colors.foreground, bg = 'none' }, +-- StatusLineNC = { fg = 'none', bg = 'none' }, +-- Title = { fg = colors.blue, bg = '', bold = true }, +-- VertSplit = { bg = 'none', fg = colors.grey }, +-- Visual = { bg = colors.grey, fg = 'none' }, +-- -- Diagnostic +-- DiagnosticBorder = { link = 'XMenuBorder' }, +-- DiagnosticNormal = { link = 'XMenu' }, +-- DiagnosticError = { fg = colors.red }, +-- DiagnosticFloatingError = { link = 'XMenu' }, +-- DiagnosticFloatingHint = { link = 'XMenu' }, +-- DiagnosticFloatingInfo = { link = 'XMenu' }, +-- DiagnosticFloatingWarn = { link = 'XMenu' }, +-- DiagnosticSignHint = { fg = colors.grey, bold = true, bg = 'none' }, +-- DiagnosticUnderlineError = { undercurl = true }, +-- DiagnosticVirtualTextHint = { bg = 'none' }, +-- DiagnosticWarn = { fg = colors.yellow }, +-- -- nvim cmp +-- CmpItemAbbr = { fg = colors.foreground }, +-- CmpItemAbbrMatch = { fg = colors.dark_orange }, +-- CmpItemAbbrMatchFuzzy = { fg = colors.dark_orange }, +-- CmpBorder = { link = 'FloatBorder' }, +-- CmpDocBorder = { link = 'FloatBorder' }, +-- CmpItemMenuDefault = { link = 'NormalFloat' }, +-- CmpMenu = { link = 'NormalFloat' }, +-- -- cmp item kinds +-- CmpItemKindConstant = { fg = colors.light_pink }, +-- CmpItemKindFunction = { fg = colors.blue }, +-- CmpItemKindIdentifier = { fg = colors.purple }, +-- CmpItemKindField = { fg = colors.dark_orange }, +-- CmpItemKindVariable = { fg = colors.purple }, +-- CmpItemKindSnippet = { fg = colors.light_pink }, +-- CmpItemKindText = { fg = colors.foreground }, +-- CmpItemKindStructure = { fg = colors.blue }, +-- CmpItemKindType = { fg = colors.orange }, +-- CmpItemKindKeyword = { fg = colors.blue }, +-- CmpItemKindMethod = { fg = colors.purple }, +-- CmpItemKindConstructor = { fg = colors.blue }, +-- CmpItemKindFolder = { fg = colors.blue }, +-- CmpItemKindModule = { fg = colors.dark_orange }, +-- CmpItemKindProperty = { fg = colors.dark_orange }, +-- CmpItemKindEnum = { fg = colors.blue }, +-- CmpItemKindUnit = { fg = colors.green }, +-- CmpItemKindClass = { fg = colors.blue }, +-- CmpItemKindFile = { fg = colors.blue }, +-- CmpItemKindInterface = { fg = colors.blue }, +-- CmpItemKindColor = { fg = colors.yellow }, +-- CmpItemKindReference = { fg = colors.blue }, +-- CmpItemKindEnumMember = { fg = colors.green }, +-- CmpItemKindStruct = { fg = colors.blue }, +-- -- CmpItemKindValue = { fg = "" }, +-- -- CmpItemKindEvent = { fg = "" }, +-- CmpItemKindOperator = { fg = colors.purple }, +-- CmpItemKindTypeParameter = { fg = colors.light_pink }, +-- CmpItemKindCopilot = { fg = colors.green }, +-- -- LSPSaga +-- OutlinePreviewBorder = { link = 'NormalFloat' }, +-- OutlinePreviewNormal = { link = 'FloatBorder' }, +-- -- Diffview +-- DiffViewSignColumn = { bg = 'none' }, +-- -- Treesitter +-- -- ['@string'] = { fg = colors.yellow, bg = '' }, +-- ['@boolean'] = { fg = colors.dark_yellow }, +-- ['@character'] = { fg = colors.foreground }, +-- ['@character.special'] = { fg = colors.dark_orange }, +-- ['@comment'] = { link = 'Comment' }, +-- ['@conditional'] = { fg = colors.blue }, +-- ['@constant'] = { fg = colors.foreground }, +-- ['@constant.builtin'] = { fg = colors.dark_yellow }, +-- ['@constant.macro'] = { fg = colors.dark_orange }, +-- ['@constructor'] = { fg = colors.blue }, +-- ['@debug'] = { link = 'Debug' }, +-- ['@define'] = { link = "Define" }, +-- ['@exception'] = { fg = colors.dark_orange }, +-- ['@field'] = { link = 'Identifier' }, +-- ['@field.yaml'] = { fg = colors.light_orange }, +-- ['@float'] = { fg = colors.light_pink }, +-- ['@function'] = { link = 'Function' }, +-- ['@function.builtin'] = { fg = colors.dark_green }, +-- ['@function.macro'] = { fg = colors.dark_orange }, +-- ['@include'] = { fg = colors.dark_orange }, +-- ['@keyword'] = { link = 'Keyword' }, +-- ['@keyword.operator'] = { fg = colors.purple }, +-- ['@keyword.return'] = { fg = colors.dark_orange }, +-- ['@label'] = { fg = colors.blue }, +-- ['@macro'] = { fg = colors.dark_orange }, +-- ['@method'] = { fg = colors.foreground }, +-- ['@namespace'] = { fg = colors.foreground }, +-- ['@number'] = { link = 'Number' }, +-- ['@operator'] = { link = 'Operator' }, +-- ['@parameter'] = { fg = colors.foreground }, +-- ['@preproc'] = { link = 'PreProc' }, +-- ['@property'] = { fg = colors.foreground }, +-- ['@punctuation.Special'] = { fg = colors.purple }, +-- ['@punctuation.bracket'] = { fg = colors.purple }, +-- ['@punctuation.delimiter'] = { fg = colors.purple }, +-- ['@repeat'] = { link = 'Repeat' }, +-- ['@storageclass'] = { link = 'StorageClass' }, +-- ['@string.escape'] = { fg = colors.dark_orange }, +-- ['@string.regex'] = { fg = colors.green }, +-- ['@string.special'] = { fg = colors.dark_orange }, +-- ['@structure'] = { link = 'Structure' }, +-- ['@tag'] = { link = 'Tag' }, +-- ['@tag.attribute'] = { fg = colors.foreground }, +-- ['@tag.delimiter'] = { fg = colors.purple }, +-- ['@text.danger'] = { fg = colors.dark_orange }, +-- ['@text.literal'] = { link = 'String' }, +-- ['@text.reference'] = { fg = colors.green }, +-- ['@text.strong'] = { bold = true }, +-- ['@text.title'] = { link = 'Title' }, +-- ['@text.todo'] = { link = 'Todo' }, +-- ['@text.underline'] = { link = 'Underlined' }, +-- ['@text.uri'] = { fg = colors.blue }, +-- ['@text.warning'] = { link = 'Todo' }, +-- ['@type'] = { link = 'Type' }, +-- ['@type.definition'] = { link = 'Typedef' }, +-- ['@variable'] = { fg = colors.foreground }, +-- ['@variable.builtin'] = { fg = colors.light_orange }, +--} +-- +--local M = {} +-- +--local function _load(config) +-- for group, hl in pairs(config) do +-- if not vim.tbl_isempty(hl) then +-- vim.api.nvim_set_hl(0, group, hl) +-- end +-- end +--end +-- +-- +--function M.setup() +-- vim.api.nvim_set_hl(0, 'XMenu', { bg = colors.dark_grey, default = true }) +-- vim.api.nvim_set_hl(0, 'XMenuBorder', { bg = colors.dark_grey, fg = colors.dark_grey, default = true }) +-- vim.g.terminal_color_0 = colors.dark_grey +--end +-- +----function M.load(full) +---- _load(base) +---- +---- if not full then +---- _load_diagnostics() +---- return +---- end +---- +---- _load(theme) +----end +-- +--return M diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua new file mode 100644 index 0000000..3189f4f --- /dev/null +++ b/.config/nvim/lua/plugins/dap.lua @@ -0,0 +1,254 @@ +local dap = require('dap') + +-- options +dap.defaults.fallback.switchbuf = 'uselast' +dap.defaults.fallback.focus_terminal = true +dap.defaults.fallback.external_terminal = { + command = '/usr/bin/wezterm', + args = { '-e' }, +} + +-- Autocmds +vim.api.nvim_create_autocmd("FileType", { + pattern = { "dap-float" }, + callback = function(event) + vim.keymap.set("n", "<Tab>", "", { buffer = event.buf, silent = true }) + vim.keymap.set("n", "<S-Tab>", "", { buffer = event.buf, silent = true }) + end, +}) + +dap.adapters.cppdbg = { + id = 'cppdbg', + type = 'executable', + --command = vim.fn.stdpath('data') .. '/mason/bin/OpenDebugAD7', + command = os.getenv("HOME") .. '/apps/cpptools/extension/debugAdapters/bin/OpenDebugAD7', + --command = cpptools:get_install_path() .. '/extension/debugAdapters/bin/OpenDebugAD7' +} + +dap.adapters.codelldb = { + type = 'server', + port = '${port}', + --host = "localhost", + --host = '127.0.0.1', + --port = 13000, -- 💀 Use the port printed out or specified with `--port` + executable = { + --command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb', + command = os.getenv("HOME") .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", + args = { '--port', '${port}' }, + }, + --detached = true, +} + +dap.adapters.lldb = { + type = 'executable', + command = '/usr/bin/lldb-vscode', + name = "lldb" +} +dap.configurations.cpp = { + { + name = "Debugger", + --type = "lldb", + --type = "cppdbg", + type = "codelldb", + request = "launch", + cwd = '${workspaceFolder}', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + --program = '${file}', + --program = function() + -- -- First, check if exists CMakeLists.txt + -- local cwd = vim.fn.getcwd() + -- if (file.exists(cwd, "CMakeLists.txt")) then + -- -- Todo. Then invoke cmake commands + -- -- Then ask user to provide execute file + -- return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + -- else + -- local fileName = vim.fn.expand("%:t:r") + -- if (not file.exists(cwd, "bin")) then + -- -- create this directory + -- os.execute("mkdir " .. "bin") + -- end + -- local cmd = "!gcc -g % -o bin/" .. fileName + -- -- First, compile it + -- vim.cmd(cmd) + -- -- Then, return it + -- return "${fileDirname}/bin/" .. fileName + -- end + --end, + stopAtEntry = true, + args = {}, + --runInTerminal = true, + --runInTerminal = false, + --console = 'integratedTerminal', + + --MIMode = 'gdb', + --miDebuggerServerAddress = 'localhost:1234', + --miDebuggerPath = 'gdb-oneapi', + --miDebuggerPath = '/usr/bin/gdb', + externalConsole = true, + --setupCommands = { + -- { + -- text = '-enable-pretty-printing', + -- description = 'enable pretty printing', + -- ignoreFailures = false + -- } + --}, + }, +} + +-- If you want to use this for Rust and C, add something like this: +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp + +-- javascript +--dap.adapters.node2 = { +-- type = 'executable', +-- command = 'node-debug2-adapter', +-- args = {}, +--} + +--dap.configurations.javascript = { +-- { +-- name = 'Launch', +-- type = 'node2', +-- request = 'attach', +-- program = '${file}', +-- cwd = vim.fn.getcwd(), +-- sourceMaps = true, +-- protocol = 'inspector', +-- console = 'integratedTerminal', +-- }, +--} + +dap.adapters.python = { + type = 'executable', + command = vim.trim(vim.fn.system('which python')), + args = { '-m', 'debugpy.adapter' }, +} + +dap.configurations.python = { + { + -- The first three options are required by nvim-dap + type = 'python', -- the type here established the link to the adapter definition: `dap.adapters.python` + request = 'launch', + name = "Launch file", + -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options + program = "${file}", -- This configuration will launch the current file if used. + stopOnEntry = true, + }, +} + +local dapui = require('dapui') +--local dap_ui_status_ok, dapui = pcall(require, "dapui") +--if not dap_ui_status_ok then +-- return +--end + +-- setup repl +--dap.repl.commands = vim.tbl_extend('force', dap.repl.commands, { +-- exit = { 'q', 'exit' }, +-- custom_commands = { +-- ['.run_to_cursor'] = dap.run_to_cursor, +-- ['.restart'] = dap.run_last +-- } +--}) + +-- Load dapui configuration only if it hasn't been loaded before +if not vim.g.loaded_dapui then + require("dapui").setup({ + mappings = { + expand = "<CR>", + open = "o", + remove = "D", + edit = "e", + repl = "r", + toggle = "t", + }, + controls = { + enabled = true, + }, + layouts = { + { + elements = { + -- Elements can be strings or table with id and size keys. + { id = "watches", size = 0.25 }, + { id = "scopes", size = 0.25 }, + { id = "breakpoints", size = 0.25 }, + { id = "stacks", size = 0.25 }, + }, + size = 50, -- 40 columns + position = "left", + }, + { + elements = { + { id = "console", size = 0.6 }, + { id = "repl", size = 0.4 }, + }, + size = 0.3, + position = "bottom", + }, + }, + render = { + max_value_lines = 3, + }, + floating = { + max_height = nil, -- These can be integers or a float between 0 and 1. + max_width = nil, -- Floats will be treated as percentage of your screen. + border = "single", -- Border style. Can be "single", "double" or "rounded" + mappings = { + close = { "q", "<Esc>" }, + }, + }, + --icons = { expanded = "-", collapsed = "$" }, + icons = { + expanded = "", + collapsed = "", + current_frame = "", + }, + }) + vim.g.loaded_dapui = true +end + + +-- Signs +local sign = vim.fn.sign_define +sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" }) +sign("DapBreakpointCondition", { text = "◆", texthl = "DapBreakpointCondition", linehl = "", numhl = "" }) -- +sign("DapBreakpointRejected", { text = 'R', texthl = 'DiagnosticError', numhl = 'DiagnosticError' }) +sign("DapLogPoint", { text = "L", texthl = "DapLogPoint", linehl = "", numhl = "" }) +sign('DapStopped', { text = '', texthl = 'DiagnosticSignHint', numbhl = '', linehl = '' }) + +--sign('DapBreakpoint', { text = '', texthl = 'DiagnosticSignError', numbhl = '', linehl = '' }) +--sign("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) +--vim.fn.sign_define("DapBreakpointCondition", { text = '?>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) +--vim.fn.sign_define("DapStopped", { text = '=>', texthl = 'DiagnosticWarn', numhl = 'DiagnosticWarn' }) +--vim.fn.sign_define("DapBreakpoint", { text = '<>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.disconnect["dapui_config"] = function() + dapui.close() +end + +require("nvim-dap-virtual-text").setup { + enabled = true, + enabled_commands = true, + highlight_changed_variables = true, + highlight_new_as_changed = false, + show_stop_reason = true, + commented = true, + only_first_definition = true, + all_references = false, + filter_references_pattern = "<module", + virt_text_pos = "eol", + all_frames = false, + virt_text_win_col = nil +} diff --git a/.config/nvim/lua/plugins/dashboard.lua b/.config/nvim/lua/plugins/dashboard.lua new file mode 100644 index 0000000..e25d536 --- /dev/null +++ b/.config/nvim/lua/plugins/dashboard.lua @@ -0,0 +1,81 @@ +local db = require("dashboard") + +--vim.api.nvim_create_autocmd("VimEnter", { +-- callback = function() +-- -- disable line numbers +-- vim.opt_local.number = false +-- vim.opt_local.relativenumber = false +-- -- always start in insert mode +-- end, +--}) + +db.setup({ + theme = "hyper", + config = { + mru = { limit = 10, label = "" }, + project = { limit = 10 }, + header = { + [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], + [[ ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║]], + [[ ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║]], + [[ ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║]], + [[ ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║]], + [[ ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝]], + }, + disable_move = false, + shortcut = { + { desc = " Plugins", group = "Number", action = "PackerStatus", key = "p" }, + --{ desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, + { + desc = " Files", + group = "Number", + --group = "Label", + action = "Telescope find_files", + key = "f", + }, + { + desc = " Text", + group = "Number", + --group = "Label", + action = "enew", + key = "t", + }, + { + desc = " Grep", + group = "Number", + --group = "Label", + action = "Telescope live_grep", + key = "g", + }, + { + desc = " Scheme", + group = "Number", + --group = "Label", + action = "Telescope colorscheme", + key = "s", + }, + { + desc = " Config", + group = "Number", + --group = "Label", + action = ":edit ~/.config/nvim/init.lua", + key = "c", + }, + }, + footer = { "", "Hello World!" }, + }, + hide = { + statusline = false, + tabline = false, + winbar = false, + }, +}) + +--highlights +---- General +--DashboardHeader DashboardFooter +---- Hyper theme +--DashboardProjectTitle DashboardProjectTitleIcon DashboardProjectIcon +--DashboardMruTitle DashboardMruIcon DashboardFiles DashboardShotCutIcon +---- Doome theme +--DashboardDesc DashboardKey DashboardIcon DashboardShotCut diff --git a/.config/nvim/lua/plugins/fidget.lua b/.config/nvim/lua/plugins/fidget.lua new file mode 100644 index 0000000..d401c5f --- /dev/null +++ b/.config/nvim/lua/plugins/fidget.lua @@ -0,0 +1,34 @@ +require("fidget").setup({ + --event = "LspAttach", + text = { + --spinner = "pipe", -- (Default) animation shown when tasks are ongoing + --spinner = "hamburger", -- animation shown when tasks are ongoing + --spinner = "dots_pulse", -- animation shown when tasks are ongoing + spinner = "dots", -- animation shown when tasks are ongoing + done = "✔", -- character shown when all tasks are complete + commenced = "Started", -- message shown when task starts + completed = "Completed", -- message shown when task completes + }, + fmt = { + task = function(task_name, message, percentage) + if task_name == "diagnostics" then + return false + end + return string.format( + "%s%s [%s]", + message, + percentage and string.format(" (%s%%)", percentage) or "", + task_name + ) + end, + }, + --sources = { -- Sources to configure + --["null-ls"] = { -- Name of source + --ignore = true, -- Ignore notifications from this source + --}, + --}, + debug = { + logging = false, -- whether to enable logging, for debugging + strict = false, -- whether to interpret LSP strictly + }, +}) diff --git a/.config/nvim/lua/plugins/fzf.lua b/.config/nvim/lua/plugins/fzf.lua new file mode 100644 index 0000000..5675e9f --- /dev/null +++ b/.config/nvim/lua/plugins/fzf.lua @@ -0,0 +1,60 @@ +--vim.cmd([[ +-- let g:fzf_history_dir = '~/.local/share/fzf-history' +-- map <leader>z :FZF<CR> +-- map <leader>a :Files<CR> +-- map <leader>l :Lines<CR> +-- map <leader>L :BLines<CR> +-- map <leader>B :Buffers<CR> +-- map <leader>h :History:<CR> +-- nnoremap <leader>g :Rg<CR> +-- "nnoremap <leader>t :Tags<CR> +-- nnoremap <leader>m :Marks<CR> +-- " This is the default extra key bindings +-- let g:fzf_action = { +-- \ 'ctrl-t': 'tab split', +-- \ 'ctrl-x': 'split', +-- \ 'ctrl-y': 'vsplit' } +-- let g:fzf_tags_command = 'ctags -R' +-- " Border color +-- let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } } +-- let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' +-- let $FZF_DEFAULT_COMMAND="rg --files --hidden" +-- " Customize fzf colors to match your color scheme +-- let g:fzf_colors = +-- \ { 'fg': ['fg', 'Normal'], +-- \ 'bg': ['bg', 'Normal'], +-- \ 'hl': ['fg', 'Comment'], +-- \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], +-- \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], +-- \ 'hl+': ['fg', 'Statement'], +-- \ 'info': ['fg', 'PreProc'], +-- \ 'border': ['fg', 'Ignore'], +-- \ 'prompt': ['fg', 'Conditional'], +-- \ 'pointer': ['fg', 'Exception'], +-- \ 'marker': ['fg', 'Keyword'], +-- \ 'spinner': ['fg', 'Label'], +-- \ 'header': ['fg', 'Comment'] } +-- " Get Files +-- command! -bang -nargs=? -complete=dir Files +-- \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0) +-- " Get text in files with Rg +-- command! -bang -nargs=* Rg +-- \ call fzf#vim#grep( +-- \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1, +-- \ fzf#vim#with_preview(), <bang>0) +-- " Ripgrep advanced +-- function! RipgrepFzf(query, fullscreen) +-- let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' +-- let initial_command = printf(command_fmt, shellescape(a:query)) +-- let reload_command = printf(command_fmt, '{q}') +-- let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} +-- call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) +-- endfunction +-- command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0) +-- " Git grep +-- command! -bang -nargs=* GGrep +-- \ call fzf#vim#grep( +-- \ 'git grep --line-number '.shellescape(<q-args>), 0, +-- \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0) +-- command! -bang FM call fzf#run(fzf#wrap({'source': 'cat ~/.fzf-marks | sed "s/.*: \(.*\)$/\1/" | sed "s#~#${HOME}#"', 'sink': 'lcd'}, <bang>0)) +--]]) diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..8fbdae1 --- /dev/null +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,47 @@ +require("gitsigns").setup({ + signs = { + --add = { + -- hl = "GitSignsAdd", + -- text = "▍", --│ + -- numhl = "GitSignsAddNr", + -- linehl = "GitSignsAddLn", + --}, + --change = { + -- hl = "GitSignsChange", + -- text = "▍", --│ + -- numhl = "GitSignsChangeNr", + -- linehl = "GitSignsChangeLn", + --}, + delete = { + hl = "GitSignsDelete", + text = "▁", --_━─ + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + topdelete = { + hl = "GitSignsDelete", + text = "▔", --‾ + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + changedelete = { + hl = "GitSignsDelete", + text = "~", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + }, + current_line_blame = true, + }) + +vim.api.nvim_command("highlight DiffAdd guibg=none guifg=#21c7a8") +vim.api.nvim_command("highlight DiffModified guibg=none guifg=#82aaff") +vim.api.nvim_command("highlight DiffDelete guibg=none guifg=#fc514e") +vim.api.nvim_command("highlight DiffText guibg=none guifg=#fc514e") +vim.cmd([[ +hi link GitSignsAdd DiffAdd +hi link GitSignsChange DiffModified +hi link GitSignsDelete DiffDelete +hi link GitSignsTopDelete DiffDelete +hi link GitSignsChangedDelete DiffDelete +]]) diff --git a/.config/nvim/lua/plugins/goto-preview.lua b/.config/nvim/lua/plugins/goto-preview.lua new file mode 100644 index 0000000..d4d2c67 --- /dev/null +++ b/.config/nvim/lua/plugins/goto-preview.lua @@ -0,0 +1,18 @@ +require('goto-preview').setup { + width = 120; -- Width of the floating window + height = 15; -- Height of the floating window + border = {"↖", "─" ,"┐", "│", "┘", "─", "└", "│"}; -- Border characters of the floating window + default_mappings = false; -- Bind default mappings + debug = false; -- Print debug information + opacity = nil; -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false; -- Binds arrow keys to resizing the floating window. + post_open_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + references = { -- Configure the telescope UI for slowing the references cycling window. + telescope = require("telescope.themes").get_dropdown({ hide_preview = false }) + }; + -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. + focus_on_open = true; -- Focus the floating window when opening it. + dismiss_on_move = false; -- Dismiss the floating window when moving the cursor. + force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden +} diff --git a/.config/nvim/lua/plugins/harpoon.lua b/.config/nvim/lua/plugins/harpoon.lua new file mode 100644 index 0000000..784ee0b --- /dev/null +++ b/.config/nvim/lua/plugins/harpoon.lua @@ -0,0 +1,34 @@ +require("harpoon").setup({ + menu = { + width = vim.api.nvim_win_get_width(0) - 4, + }, + --keys = { + -- { "mt", function() require("harpoon.mark").toggle_file() end, desc = "Toggle File" }, + -- { "mm", function() require("harpoon.ui").toggle_quick_menu() end, desc = "Harpoon Menu" }, + -- { "mc", function() require("harpoon.cmd-ui").toggle_quick_menu() end, desc = "Command Menu" }, + -- --{ "<leader>1", function() require("harpoon.ui").nav_file(1) end, desc = "File 1" }, + -- --{ "<leader>2", function() require("harpoon.ui").nav_file(2) end, desc = "File 2" }, + -- --{ "<leader>3", function() require("harpoon.term").gotoTerminal(1) end, desc = "Terminal 1" }, + -- --{ "<leader>4", function() require("harpoon.term").gotoTerminal(2) end, desc = "Terminal 2" }, + -- --{ "<leader>5", function() require("harpoon.term").sendCommand(1,1) end, desc = "Command 1" }, + -- --{ "<leader>6", function() require("harpoon.term").sendCommand(1,2) end, desc = "Command 2" }, + --}, +}) +vim.api.nvim_set_keymap("n", "<leader>ma", ":lua require('harpoon.mark').add_file()<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mt", ":lua require('harpoon.mark').toggle_file()<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mq", ":lua require('harpoon.ui').toggle_quick_menu()<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mh", ":lua require('harpoon.ui').nav_file(1)<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mj", ":lua require('harpoon.ui').nav_file(2)<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mk", ":lua require('harpoon.ui').nav_file(3)<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>ml", ":lua require('harpoon.ui').nav_file(4)<CR>", {}) + +--local mark = require("harpoon.mark") +--local ui = require("harpoon.ui") +-- +--vim.keymap.set("n", "<leader>a", mark.add_file) +--vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu) +-- +--vim.keymap.set("n", "<C-h>", function() ui.nav_file(1) end) +--vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end) +--vim.keymap.set("n", "<C-n>", function() ui.nav_file(3) end) +--vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end) diff --git a/.config/nvim/lua/plugins/heirline.lua b/.config/nvim/lua/plugins/heirline.lua new file mode 100644 index 0000000..a5cd2bf --- /dev/null +++ b/.config/nvim/lua/plugins/heirline.lua @@ -0,0 +1,1284 @@ +local conditions = require('heirline.conditions') +local utils = require('heirline.utils') + +local colors = { + --bg = "#23232e", + bg = nil, + nobg = 'NONE', + white = '#f8f8f2', + black = '#000000', + darkgray = '#23232e', + gray = '#2d2b3a', + lightgray = '#d6d3ea', + pink = '#f92672', + green = '#50fa7b', + blue = '#39BAE6', + yellow = '#f1fa8c', + orange = '#ffb86c', + purple = '#BF40BF', + violet = '#7F00FF', + red = '#ff5555', + cyan = '#66d9eC', + diag = { + warn = utils.get_highlight('DiagnosticSignWarn').fg, + error = utils.get_highlight('DiagnosticSignError').fg, + hint = utils.get_highlight('DiagnosticSignHint').fg, + info = utils.get_highlight('DiagnosticSignInfo').fg, + }, + git = { + active = '#f34f29', + del = '#ff5555', + add = '#50fa7b', + change = '#ae81ff', + }, +} + +require('heirline').load_colors(colors) + +local Align = { provider = '%=', hl = { bg = colors.bg } } +local Space = { provider = ' ', hl = { bg = colors.bg } } +local Tab = { provider = ' ' } +local LeftSpace = { provider = '' } +local RightSpace = { provider = '' } + +local ViMode = { + init = function(self) + self.mode = vim.fn.mode(1) + --if not self.once then + -- vim.cmd("au ModeChanged *:*o redrawstatus") + --end + --self.once = true + end, + static = { + mode_names = { + n = ' NORMAL ', + no = 'PENDING ', + nov = ' N? ', + noV = ' N? ', + ['no\22'] = ' N? ', + niI = ' Ni ', + niR = ' Nr ', + niV = ' Nv ', + nt = 'TERMINAL', + v = ' VISUAL ', + vs = ' Vs ', + V = ' V·LINE ', + ['\22'] = 'V·BLOCK ', + ['\22s'] = 'V·BLOCK ', + s = ' SELECT ', + S = ' S·LINE ', + ['\19'] = 'S·BLOCK ', + i = ' INSERT ', + ix = 'insert x', + ic = 'insert c', + R = 'REPLACE ', + Rc = ' Rc ', + Rx = ' Rx ', + Rv = 'V·REPLACE ', + Rvc = ' Rv ', + Rvx = ' Rv ', + c = 'COMMAND ', + cv = ' VIM EX ', + ce = ' EX ', + r = ' PROMPT ', + rm = ' MORE ', + ['r?'] = 'CONFIRM ', + ['!'] = ' SHELL ', + t = 'TERMINAL', + }, + }, + provider = function(self) + return ' %2(' .. self.mode_names[self.mode] .. '%) ' + end, + hl = function(self) + return { fg = 'darkgray', bg = self.mode_color, bold = true } + end, + update = { + 'ModeChanged', + 'VimEnter', + pattern = '*:*', + callback = vim.schedule_wrap(function() + vim.cmd('redrawstatus') + end), + }, +} + +-- LSP +local LSPActive = { + condition = conditions.lsp_attached, + update = { 'LspAttach', 'LspDetach' }, + provider = function() + local buf_clients = vim.lsp.buf_get_clients() + local buf_client_names = {} + + -- add client + for _, client in pairs(buf_clients) do + if client.name ~= 'null-ls' then + table.insert(buf_client_names, client.name) + end + end + return '⚙️ ' .. table.concat(buf_client_names, '') + end, + hl = { fg = colors.lightgray, bold = false }, +} +local Navic = { + condition = function() + return require('nvim-navic').is_available() + end, + static = { + -- create a type highlight map + type_hl = { + File = 'Directory', + Module = '@include', + Namespace = '@namespace', + Package = '@include', + Class = '@structure', + Method = '@method', + Property = '@property', + Field = '@field', + Constructor = '@constructor', + Enum = '@field', + Interface = '@type', + Function = '@function', + Variable = '@variable', + Constant = '@constant', + String = '@string', + Number = '@number', + Boolean = '@boolean', + Array = '@field', + Object = '@type', + Key = '@keyword', + Null = '@comment', + EnumMember = '@field', + Struct = '@structure', + Event = '@keyword', + Operator = '@operator', + TypeParameter = '@type', + }, + -- bit operation dark magic, see below... + enc = function(line, col, winnr) + return bit.bor(bit.lshift(line, 16), bit.lshift(col, 6), winnr) + end, + -- line: 16 bit (65535); col: 10 bit (1023); winnr: 6 bit (63) + dec = function(c) + local line = bit.rshift(c, 16) + local col = bit.band(bit.rshift(c, 6), 1023) + local winnr = bit.band(c, 63) + return line, col, winnr + end, + }, + init = function(self) + local data = require('nvim-navic').get_data() or {} + local children = {} + -- create a child for each level + for i, d in ipairs(data) do + -- encode line and column numbers into a single integer + local pos = self.enc(d.scope.start.line, d.scope.start.character, self.winnr) + local child = { + { + provider = d.icon, + hl = self.type_hl[d.type], + }, + { + -- escape `%`s (elixir) and buggy default separators + provider = d.name:gsub('%%', '%%%%'):gsub('%s*->%s*', ''), + -- highlight icon only or location name as well + -- hl = self.type_hl[d.type], + + on_click = { + -- pass the encoded position through minwid + minwid = pos, + callback = function(_, minwid) + -- decode + local line, col, winnr = self.dec(minwid) + vim.api.nvim_win_set_cursor(vim.fn.win_getid(winnr), { line, col }) + end, + name = 'heirline_navic', + }, + }, + } + -- add a separator only if needed + if #data > 1 and i < #data then + table.insert(child, { + provider = ' > ', + hl = { fg = 'bright_fg' }, + }) + end + table.insert(children, child) + end + -- instantiate the new child, overwriting the previous one + self.child = self:new(children, 1) + end, + -- evaluate the children containing navic components + provider = function(self) + return self.child:eval() + end, + hl = { fg = 'gray' }, + update = 'CursorMoved', +} + +-- Diagnostics +local Diagnostics = { + condition = conditions.has_diagnostics, + static = { + error_icon = vim.fn.sign_getdefined('DiagnosticSignError')[1].text, + warn_icon = vim.fn.sign_getdefined('DiagnosticSignWarn')[1].text, + info_icon = vim.fn.sign_getdefined('DiagnosticSignInfo')[1].text, + hint_icon = vim.fn.sign_getdefined('DiagnosticSignHint')[1].text, + }, + init = function(self) + self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) + self.warnings = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) + self.hints = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }) + self.info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }) + end, + update = { 'DiagnosticChanged', 'BufEnter' }, + { + provider = function(self) + -- 0 is just another output, we can decide to print it or not! + return self.errors > 0 and (self.error_icon .. self.errors .. ' ') + end, + hl = { fg = colors.diag.error, bg = colors.bg }, + }, + { + provider = function(self) + return self.warnings > 0 and (self.warn_icon .. self.warnings .. ' ') + end, + hl = { fg = colors.diag.warn, bg = colors.bg }, + }, + { + provider = function(self) + return self.info > 0 and (self.info_icon .. self.info .. ' ') + end, + hl = { fg = colors.diag.info, bg = colors.bg }, + }, + { + provider = function(self) + return self.hints > 0 and (self.hint_icon .. self.hints) + end, + hl = { fg = colors.diag.hint, bg = colors.bg }, + }, + on_click = { + callback = function() + require('trouble').toggle({ mode = 'document_diagnostics' }) + -- or + -- vim.diagnostic.setqflist() + end, + name = 'heirline_diagnostics', + }, +} + +-- Git +-- For the ones who're not (too) afraid of changes! Uses gitsigns. +local Git = { + condition = conditions.is_git_repo, + init = function(self) + self.status_dict = vim.b.gitsigns_status_dict + self.has_changes = self.status_dict.added ~= 0 or self.status_dict.removed ~= 0 or self.status_dict.changed ~= 0 + end, + --{ + -- -- git branch name + -- provider = function(self) + -- --return ' ' .. self.status_dict.head + -- return ' ' .. self.status_dict.head + -- end, + -- --hl = { bold = true }, + -- hl = { fg = colors.git.active, bold = true, bg = colors.bg }, + --}, + -- You could handle delimiters, icons and counts similar to Diagnostics + { + -- git branch icon + provider = function() + return ' ' + end, + hl = { fg = colors.git.active, bg = colors.bg }, + }, + + { + -- git branch name + provider = function(self) + return self.status_dict.head + end, + hl = { fg = colors.white, bg = colors.bg }, + }, + + { + condition = function(self) + return self.has_changes + end, + --provider = "(" + provider = '', + }, + { + provider = function(self) + local count = self.status_dict.added or 0 + --return count > 0 and ("+" .. count) + return count > 0 and (' ' .. count) + end, + --hl = { fg = "git_add" }, + hl = { fg = colors.git.add, bg = colors.bg }, + }, + { + provider = function(self) + local count = self.status_dict.removed or 0 + --return count > 0 and ("-" .. count) + return count > 0 and (' ' .. count) + end, + --hl = { fg = "git_del" }, + hl = { fg = colors.git.del, bg = colors.bg }, + }, + { + provider = function(self) + local count = self.status_dict.changed or 0 + --return count > 0 and ("~" .. count) + return count > 0 and (' ' .. count) + end, + --hl = { fg = "git_change" }, + hl = { fg = colors.git.change, bg = colors.bg }, + }, + --{ + -- condition = function(self) + -- return self.has_changes + -- end, + -- provider = ")", + --}, + on_click = { + callback = function() + -- If you want to use Fugitive: + -- vim.cmd("G") + + -- If you prefer Lazygit + -- use vim.defer_fn() if the callback requires + -- opening of a floating window + -- (this also applies to telescope) + vim.defer_fn(function() + vim.cmd('Lazygit') + end, 100) + end, + name = 'heirline_git', + }, +} + +-- Debugger +-- Display informations from nvim-dap! +-- Note that we add spaces separately, so that only the icon characters will be clickable +--local DAPMessages = { +-- condition = function() +-- local session = require("dap").session() +-- return session ~= nil +-- end, +-- provider = function() +-- return " " .. require("dap").status() .. " " +-- end, +-- hl = "Debug", +-- { +-- provider = "", +-- on_click = { +-- callback = function() +-- require("dap").step_into() +-- end, +-- name = "heirline_dap_step_into", +-- }, +-- }, +-- { provider = " " }, +-- { +-- provider = "", +-- on_click = { +-- callback = function() +-- require("dap").step_out() +-- end, +-- name = "heirline_dap_step_out", +-- }, +-- }, +-- { provider = " " }, +-- { +-- provider = " ", +-- on_click = { +-- callback = function() +-- require("dap").step_over() +-- end, +-- name = "heirline_dap_step_over", +-- }, +-- }, +-- { provider = " " }, +-- { +-- provider = "ﰇ", +-- on_click = { +-- callback = function() +-- require("dap").run_last() +-- end, +-- name = "heirline_dap_run_last", +-- }, +-- }, +-- { provider = " " }, +-- { +-- provider = "", +-- on_click = { +-- callback = function() +-- require("dap").terminate() +-- require("dapui").close({}) +-- end, +-- name = "heirline_dap_close", +-- }, +-- }, +-- { provider = " " }, +-- -- icons: ﰇ +--} + +-- Tests +-- This requires the great ultest. +--local UltTest = { +-- condition = function() +-- return vim .api.nvim_call_function("ultest#is_test_file", {}) ~= 0 +-- end, +-- static = { +-- passed_icon = vim.fn.sign_getdefined("test_pass")[1].text, +-- failed_icon = vim.fn.sign_getdefined("test_fail")[1].text, +-- passed_hl = { fg = utils.get_highlight("UltestPass").fg }, +-- failed_hl = { fg = utils.get_highlight("UltestFail").fg }, +-- }, +-- init = function(self) +-- self.status = vim.api.nvim_call_function("ultest#status", {}) +-- end, +-- +-- -- again, if you'd like icons and numbers to be colored differently, +-- -- just split the component in two +-- { +-- provider = function(self) +-- return self.passed_icon .. self.status.passed .. " " +-- end, +-- hl = function(self) +-- return self.passed_hl +-- end, +-- }, +-- { +-- provider = function(self) +-- return self.failed_icon .. self.status.failed .. " " +-- end, +-- hl = function(self) +-- return self.failed_hl +-- end, +-- }, +-- { +-- provider = function(self) +-- return "of " .. self.status.tests - 1 +-- end, +-- }, +--} + +-- FileNameBlock: FileIcon, FileName and friends +local FileNameBlock = { + -- let's first set up some attributes needed by this component and it's children + init = function(self) + self.filename = vim.api.nvim_buf_get_name(0) + end, + --hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, + hl = { bg = colors.bg }, +} + +-- FileIcon, FileName, FileFlags and FileNameModifier +local FileIcon = { + init = function(self) + local filename = self.filename + local extension = vim.fn.fnamemodify(filename, ':e') + self.icon, self.icon_color = require('nvim-web-devicons').get_icon_color(filename, extension, { default = true }) + end, + provider = function(self) + return self.icon and (self.icon .. ' ') + end, + hl = function(self) + return { fg = self.icon_color, bg = colors.bg } + end, +} + +local FileName = { + provider = function(self) + -- first, trim the pattern relative to the current directory. For other + -- options, see :h filename-modifers + local filename = vim.fn.fnamemodify(self.filename, ':.') + if filename == '' then + return 'No Name' + end + -- now, if the filename would occupy more than 1/4th of the available + -- space, we trim the file path to its initials + -- See Flexible Components section below for dynamic truncation + if not conditions.width_percent_below(#filename, 0.25) then + filename = vim.fn.pathshorten(filename) + end + return filename + end, + --hl = { fg = utils.get_highlight("Statusline").fg, bold = false, bg = colors.bg }, + hl = { fg = colors.white, bold = false, bg = colors.bg }, +} + +local FileFlags = { + { + provider = function() + if vim.bo.modified then + return ' [+]' -- ±[+] + end + end, + hl = { fg = colors.green, bg = colors.bg }, + }, + { + provider = function() + if not vim.bo.modifiable or vim.bo.readonly then + return ' ' + end + end, + --hl = { fg = colors.orange }, + hl = { fg = colors.orange, bold = true, bg = colors.bg }, + }, +} + +local FileNameModifier = { + hl = function() + if vim.bo.modified then + return { fg = colors.green, bold = false, force = true } + end + end, +} + +-- FileType, FileEncoding and FileFormat +local FileType = { + provider = function() + return vim.bo.filetype + end, + hl = { fg = colors.white, bold = false, bg = colors.bg }, +} + +local FileEncoding = { + Space, + provider = function() + local enc = (vim.bo.fenc ~= '' and vim.bo.fenc) or vim.o.enc -- :h 'enc' + return enc:lower() + end, + --hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, + hl = { bg = colors.bg, bold = false }, +} + +local FileFormat = { + provider = function() + local fmt = vim.bo.fileformat + --return fmt ~= "unix" and fmt:upper() + return fmt ~= 'unix' and fmt:lower() + end, + hl = { fg = utils.get_highlight('Statusline').fg, bold = true, bg = colors.bg }, +} + +-- FileSize and FileLastModified +local FileSize = { + provider = function() + -- stackoverflow, compute human readable file size + local suffix = { 'b', 'k', 'M', 'G', 'T', 'P', 'E' } + local fsize = vim.fn.getfsize(vim.api.nvim_buf_get_name(0)) + fsize = (fsize < 0 and 0) or fsize + if fsize < 1024 then + return fsize .. suffix[1] + end + local i = math.floor((math.log(fsize) / math.log(1024))) + return string.format('%.2g%s', fsize / math.pow(1024, i), suffix[i + 1]) + end, + hl = { fg = utils.get_highlight('Statusline').fg, bold = true, bg = colors.bg }, +} + +local FileLastModified = { + -- did you know? Vim is full of functions! + provider = function() + local ftime = vim.fn.getftime(vim.api.nvim_buf_get_name(0)) + return (ftime > 0) and os.date('%c', ftime) + end, + hl = { fg = utils.get_highlight('Statusline').fg, bold = true, bg = colors.bg }, +} + +-- Spell +-- Add indicator when spell is set! +local Spell = { + condition = function() + return vim.wo.spell + end, + provider = ' 暈', + hl = { bold = true, fg = colors.yellow }, +} + +local HelpFileName = { + condition = function() + return vim.bo.filetype == 'help' + end, + provider = function() + local filename = vim.api.nvim_buf_get_name(0) + return vim.fn.fnamemodify(filename, ':t') + end, + hl = { fg = colors.blue }, +} + +local SearchCount = { + condition = function() + return vim.v.hlsearch ~= 0 and vim.o.cmdheight == 0 + end, + init = function(self) + local ok, search = pcall(vim.fn.searchcount) + if ok and search.total then + self.search = search + end + end, + provider = function(self) + local search = self.search + return string.format('[%d/%d]', search.current, math.min(search.total, search.maxcount)) + end, +} + +local MacroRec = { + condition = function() + return vim.fn.reg_recording() ~= '' and vim.o.cmdheight == 0 + end, + provider = ' ', + hl = { fg = 'orange', bold = true }, + utils.surround({ '[', ']' }, nil, { + provider = function() + return vim.fn.reg_recording() + end, + hl = { fg = 'green', bold = true }, + }), + update = { + 'RecordingEnter', + 'RecordingLeave', + }, +} + +local ShowCmd = { + condition = function() + return vim.o.cmdheight == 0 + end, + provider = ':%3.5(%S%)', +} + +local cursor_location = { + { provider = '%1(%4l:%-3(%c%)%) %*', hl = { fg = colors.black, bold = true } }, +} + +local Ruler = { cursor_location } + +--utils.make_flexible_component( +-- 3, +-- { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, +-- { provider = "%<" } +--), +--local cursor_location = { +-- { provider = "%7(%l:%c%) ", hl = { bold = true } }, +-- { +-- provider = " ", +-- hl = function(self) +-- local color = self:mode_color() +-- return { fg = color, bold = true } +-- end, +-- }, +--} + +local WordCount = { + condition = function() + return conditions.buffer_matches({ + filetype = { + 'markdown', + 'txt', + 'vimwiki', + }, + }) + end, + Space, + { + provider = function() + return 'W:' .. vim.fn.wordcount().words + end, + }, +} + +-- Working Directory +local WorkDir = { + init = function(self) + self.icon = (vim.fn.haslocaldir(0) == 1 and 'l' or 'g') .. ' ' .. ' ' + local cwd = vim.fn.getcwd(0) + self.cwd = vim.fn.fnamemodify(cwd, ':~') + end, + hl = { fg = 'colors.blue', bold = true }, + flexible = 1, + { + -- evaluates to the full-lenth path + provider = function(self) + local trail = self.cwd:sub(-1) == '/' and '' or '/' + return self.icon .. self.cwd .. trail .. ' ' + end, + }, + { + -- evaluates to the shortened path + provider = function(self) + local cwd = vim.fn.pathshorten(self.cwd) + local trail = self.cwd:sub(-1) == '/' and '' or '/' + return self.icon .. cwd .. trail .. ' ' + end, + }, + { + -- evaluates to "", hiding the component + provider = '', + }, +} + +-- Snippets Indicator +-- This requires ultisnips +--local Snippets = { +-- -- check that we are in insert or select mode +-- condition = function() +-- return vim.tbl_contains({'s', 'i'}, vim.fn.mode()) +-- end, +-- provider = function() +-- local forward = (vim.fn["UltiSnips#CanJumpForwards"]() == 1) and "" or "" +-- local backward = (vim.fn["UltiSnips#CanJumpBackwards"]() == 1) and " " or "" +-- return backward .. forward +-- end, +-- hl = { fg = "red", bold = true }, +--} + +-- let's add the children to our FileNameBlock component +FileNameBlock = utils.insert( + FileNameBlock, + FileIcon, + utils.insert(FileNameModifier, FileName), -- a new table where FileName is a child of FileNameModifier + unpack(FileFlags), -- A small optimisation, since their parent does nothing + { provider = '%<' } -- this means that the statusline is cut here when there's not enough space +) + +local FileInfoBlock = { + -- let's first set up some attributes needed by this component and it's children + init = function(self) + self.filename = vim.api.nvim_buf_get_name(0) + end, +} + +FileInfoBlock = utils.insert( + FileInfoBlock, + Space, + FileIcon, + FileType, + { provider = '%<' } -- this means that the statusline is cut here when there's not enough space +) + +LeftSpace = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { LeftSpace, hl = { fg = utils.get_highlight('statusline').bg, force = true } }) + +RightSpace = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { RightSpace, hl = { fg = utils.get_highlight('statusline').bg, force = true } }) + +LSPActive = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { Space, LSPActive, hl = { bg = colors.darkgray, force = true } }) + +FileInfoBlock = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { FileInfoBlock, Space, hl = { bg = colors.gray, force = true } }) + +Ruler = utils.surround({ '', '' }, colors.gray, { Ruler, hl = { fg = colors.gray, force = true } }) + +local left = { + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, + { Space, hl = { bg = colors.nobg, force = true } }, + { FileNameBlock, hl = { bg = colors.nobg, force = true } }, + { Space, hl = { bg = colors.nobg, force = true } }, + { Git, hl = { bg = colors.nobg, force = true } }, +} + +local middle = { + { Align, hl = { bg = colors.nobg, force = true } }, + --{ Navic, hl = { bg = colors.nobg, force = true } }, + --{ DAPMessages, hl = { bg = colors.nobg, force = true } }, + { Align, hl = { bg = colors.nobg, force = true } }, +} + +local right = { + --{ Space, hl = { bg = colors.nobg, force = true } }, + { Diagnostics, hl = { bg = colors.nobg, force = true } }, + { Space, hl = { bg = colors.nobg, force = true } }, + { LSPActive, hl = { bg = colors.nobg, force = true } }, + { Space, hl = { bg = colors.nobg, force = true } }, + { FileInfoBlock, hl = { bg = colors.nobg, force = true } }, + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, +} + +local sections = { left, middle, right } +local DefaultStatusline = { sections } + +local specialleft = { + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, +} + +local specialmiddle = { + { Align, hl = { bg = colors.nobg, force = true } }, + --{ DAPMessages, hl = { bg = colors.nobg, force = true } }, + { Align, hl = { bg = colors.nobg, force = true } }, +} + +local specialright = { + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, +} + +local specialsections = { specialleft, specialmiddle, specialright } + +local InactiveStatusline = { + condition = conditions.is_not_active, + --{ FileNameBlock, hl = { bg = colors.nobg, force = true } }, + --{ Align, hl = { bg = colors.nobg, force = true } }, + specialsections, +} + +local SpecialStatusline = { + condition = function() + return conditions.buffer_matches({ + buftype = { 'nofile', 'prompt', 'help', 'quickfix' }, + filetype = { '^git.*', 'fugitive', 'dashboard' }, + }) + end, + specialsections, +} + +--local InactiveStatusline = SpecialStatusline + +local TerminalStatusline = { + condition = function() + return conditions.buffer_matches({ buftype = { 'terminal' } }) + end, + specialsections, +} + +local StatusLine = { + static = { + --mode_colors = { + -- n = colors.blue, + -- i = colors.green, + -- v = colors.purple, + -- V = colors.purple, + -- ["\22"] = colors.purple, + -- c = colors.orange, + -- s = colors.purple, + -- S = colors.purple, + -- ["\19"] = colors.purple, + -- R = colors.red, + -- r = colors.red, + -- ["!"] = colors.orange, + -- t = colors.orange, + --}, + mode_colors = { + n = colors.blue, + no = colors.blue, + nov = colors.blue, + noV = colors.blue, + ['no\22'] = colors.blue, + niI = colors.blue, + niR = colors.blue, + niV = colors.blue, + nt = colors.blue, + v = colors.purple, + vs = colors.purple, + V = colors.purple, + ['\22'] = colors.purple, + ['\22s'] = colors.purple, + s = colors.purple, + S = colors.purple, + ['\19'] = colors.purple, + i = colors.green, + ix = colors.green, + ic = colors.green, + R = colors.red, + Rc = colors.red, + Rx = colors.red, + Rv = colors.red, + Rvc = colors.red, + Rvx = colors.red, + c = colors.orange, + cv = colors.orange, + ce = colors.orange, + r = colors.red, + rm = colors.red, + ['r?'] = colors.red, + ['!'] = colors.orange, + t = colors.orange, + }, + mode_color = function(self) + local mode = conditions.is_active() and vim.fn.mode() or 'n' + return self.mode_colors[mode] + end, + hl = function(self) + local color = self:mode_color() -- here! + return { bg = color } + end, + }, + fallthrough = false, + SpecialStatusline, + TerminalStatusline, + InactiveStatusline, + DefaultStatusline, +} + +-- +--- WinBar +-- +local WinbarFileNameBlock = { + -- let's first set up some attributes needed by this component and it's children + init = function(self) + self.filename = vim.api.nvim_buf_get_name(0) + end, + hl = { bg = colors.bg }, +} + +local WinbarFileName = { + provider = function(self) + -- first, trim the pattern relative to the current directory. For other + -- options, see :h filename-modifers + local filename = vim.fn.fnamemodify(self.filename, ':.') + if filename == '' then + return 'No Name' + end + -- now, if the filename would occupy more than 1/4th of the available + -- space, we trim the file path to its initials + -- See Flexible Components section below for dynamic truncation + if not conditions.width_percent_below(#filename, 0.25) then + filename = vim.fn.pathshorten(filename) + end + return filename + end, + --hl = { fg = utils.get_highlight("Statusline").fg, bold = false, bg = colors.bg }, + hl = { fg = colors.gray, bold = false, bg = colors.bg }, +} + +WinbarFileNameBlock = utils.insert( + WinbarFileNameBlock, + FileIcon, + utils.insert(WinbarFileName), -- a new table where FileName is a child of FileNameModifier + unpack(FileFlags), -- A small optimisation, since their parent does nothing + { provider = '%<' } -- this means that the statusline is cut here when there's not enough space +) + +vim.api.nvim_create_autocmd('User', { + pattern = 'HeirlineInitWinbar', + callback = function(args) + local buf = args.buf + local buftype = vim.tbl_contains({ 'prompt', 'nofile', 'help', 'quickfix' }, vim.bo[buf].buftype) + local filetype = vim.tbl_contains({ 'gitcommit', 'fugitive' }, vim.bo[buf].filetype) + if buftype or filetype then + vim.opt_local.winbar = nil + end + end, +}) + +On_click = { + -- get the window id of the window in which the component was evaluated + minwid = function() + return vim.api.nvim_get_current_win() + end, + callback = function(_, minwid) + -- winid is the window id of the window the component was clicked from + local winid = minwid + -- do something with the window id, e.g.: + local buf = vim.api.nvim_win_get_buf(winid) + -- ... + end, +} + +local CloseButton = { + condition = function(self) + return not vim.bo.modified + end, + -- a small performance improvement: + -- re register the component callback only on layout/buffer changes. + update = { 'WinNew', 'WinClosed', 'BufEnter' }, + { provider = ' ' }, + { + provider = '', + hl = { fg = 'gray' }, + On_click = { + minwid = function() + return vim.api.nvim_get_current_win() + end, + callback = function(_, minwid) + vim.api.nvim_win_close(minwid, true) + end, + name = 'heirline_winbar_close_button', + }, + }, +} + +local Center = { + fallthrough = false, + { + -- Hide the winbar for special buffers + condition = function() + return conditions.buffer_matches({ + buftype = { 'terminal', 'nofile', 'prompt', 'help', 'quickfix' }, + filetype = { 'dap-ui', 'NvimTree', '^git.*', 'fugitive', 'dashboard' }, + }) + end, + init = function() + vim.opt_local.winbar = nil + end, + }, + { + -- A special winbar for terminals + condition = function() + return conditions.buffer_matches({ buftype = { 'terminal' } }) + end, + FileType, + Space, + --TerminalName, + }, + { + -- An inactive winbar for regular files + condition = function() + return not conditions.is_active() + end, + --utils.surround({ "", "" }, colors.nobg, { FileIcon, { WinbarFileName, hl = { fg = colors.gray } }, FileFlags } ), + utils.surround({ '', '' }, colors.nobg, { WinbarFileNameBlock }), + }, + -- A winbar for regular files + utils.surround({ '', '' }, colors.nobg, { FileNameBlock }), +} + +--local WinBar = { Align, Center, Align } +local WinBar = { Space, Center } + +-- TabLine +--local TablineBufnr = { +-- provider = function(self) +-- return tostring(self.bufnr) .. "." +-- end, +-- hl = { fg = colors.white, bold = false }, +---- hl = "Comment", +--} + +-- we redefine the filename component, as we probably only want the tail and not the relative path +local TablineFileName = { + provider = function(self) + -- self.filename will be defined later, just keep looking at the example! + local filename = self.filename + filename = filename == '' and 'No Name' or vim.fn.fnamemodify(filename, ':t') + return filename + end, + hl = function(self) + return { fg = colors.white, bold = self.is_active or self.is_visible, italic = true } + end, +} + +local TablineFileFlags = { + { + provider = function(self) + if vim.bo[self.bufnr].modified then + return ' [+] ' + end + end, + hl = { fg = colors.green }, + }, + { + provider = function(self) + if not vim.bo[self.bufnr].modifiable or vim.bo[self.bufnr].readonly then + return ' ' + end + end, + hl = { fg = 'orange' }, + }, +} + +local TablineFileIcon = { + init = function(self) + local filename = self.filename + local extension = vim.fn.fnamemodify(filename, ':e') + self.icon, self.icon_color = require('nvim-web-devicons').get_icon_color(filename, extension, { default = true }) + end, + provider = function(self) + return self.icon and (' ' .. self.icon .. ' ') + end, + hl = function(self) + return { fg = self.icon_color } + end, +} + +-- Here the filename block finally comes together +local TablineFileNameBlock = { + init = function(self) + self.filename = vim.api.nvim_buf_get_name(self.bufnr) + end, + hl = function(self) + if self.is_active then + return 'TabLineSel' + -- why not? + --elseif not vim.api.nvim_buf_is_loaded(self.bufnr) then + --return { fg = "gray", bg = colors.bg } + else + return 'TabLineFill' + end + end, + on_click = { + callback = function(_, minwid, _, button) + if button == 'm' then -- close on mouse middle click + vim.api.nvim_buf_delete(minwid, { force = false }) + else + vim.api.nvim_win_set_buf(0, minwid) + end + end, + minwid = function(self) + return self.bufnr + end, + name = 'heirline_tabline_buffer_callback', + }, + --TablineBufnr, + TablineFileIcon, + TablineFileName, + TablineFileFlags, +} + +-- a nice "x" button to close the buffer +local TablineCloseButton = { + condition = function(self) + return not vim.api.nvim_buf_get_option(self.bufnr, 'modified') + end, + { provider = ' ' }, + { + provider = ' ', + --hl = { fg = "red", bg = colors.bg }, + hl = { fg = colors.red }, + on_click = { + callback = function(_, minwid) + vim.api.nvim_buf_delete(minwid, { force = false }) + end, + minwid = function(self) + return self.bufnr + end, + name = 'heirline_tabline_close_buffer_callback', + }, + }, +} + +-- The final touch! +local TablineBufferBlock = utils.surround({ '', '' }, function(self) + --local TablineBufferBlock = utils.surround({ "█", "█" }, function(self) + if self.is_active then + return utils.get_highlight('TabLineSel').bg + else + return utils.get_highlight('TabLineFill').bg + end +end, { Tab, TablineFileNameBlock, TablineCloseButton }) + +local BufferLine = utils.make_buflist( + TablineBufferBlock, + { provider = ' ', hl = { fg = colors.white } }, -- left truncation, optional (defaults to "<") + { provider = ' ', hl = { fg = colors.white } } -- right trunctation, also optional (defaults to ...... yep, ">") +-- by the way, open a lot of buffers and try clicking them ;) +) +-- TabList +local Tabpage = { + provider = function(self) + return '%' .. self.tabnr .. 'T ' .. self.tabnr .. ' %T' + end, + hl = function(self) + if not self.is_active then + return 'TabLineFill' + else + return 'TabLineSel' + end + end, +} + +local TabpageClose = { + provider = '%999X %X', + --hl = "TabLine", + hl = { fg = colors.red, bg = colors.bg }, +} + +local TabPages = { + -- only show this component if there's 2 or more tabpages + condition = function() + return #vim.api.nvim_list_tabpages() >= 2 + end, + { + provider = '%=', + }, + utils.make_tablist(Tabpage), + TabpageClose, +} + +-- TabLineOffset +local TabLineOffset = { + condition = function(self) + local win = vim.api.nvim_tabpage_list_wins(0)[1] + local bufnr = vim.api.nvim_win_get_buf(win) + self.winid = win + + if vim.api.nvim_buf_get_option(bufnr, 'filetype') == 'NvimTree' then + self.title = 'NvimTree' + return true + end + end, + provider = function(self) + local title = self.title + local width = vim.api.nvim_win_get_width(self.winid) + local pad = math.ceil((width - #title) / 2) + return string.rep(' ', pad) .. title .. string.rep(' ', pad) + end, + hl = { fg = colors.white, bg = '#333842', bold = true }, + + --hl = function(self) + -- if vim.api.nvim_get_current_win() == self.winid then + -- return 'TablineSel' + -- else + -- return 'TablineFill' + -- end + --end, +} + +local TabLine = { + TabLineOffset, + BufferLine, + TabPages, +} + +require('heirline').setup({ + statusline = StatusLine, + winbar = WinBar, + tabline = TabLine, + --statuscolumn = StatusColumn +}) + +-- Yep, with heirline we're driving manual! +vim.o.showtabline = 2 +vim.cmd([[au FileType * if index(['wipe', 'delete', 'unload'], &bufhidden) >= 0 | set nobuflisted | endif]]) + +local function get_bufs() + return vim.tbl_filter(function(bufnr) + return vim.api.nvim_buf_is_loaded(bufnr) and vim.bo[bufnr].buflisted + end, vim.api.nvim_list_bufs()) +end + +local function goto_buf(index) + local bufs = get_bufs() + if index > #bufs then + index = #bufs + end + vim.api.nvim_win_set_buf(0, bufs[index]) +end + +local function addKey(key, index) + vim.keymap.set('', '<A-' .. key .. '>', function() + goto_buf(index) + end, { noremap = true, silent = true }) +end + +for i = 1, 9 do + addKey(i, i) +end +addKey('0', 10) diff --git a/.config/nvim/lua/plugins/leetcode.lua b/.config/nvim/lua/plugins/leetcode.lua new file mode 100644 index 0000000..50369e1 --- /dev/null +++ b/.config/nvim/lua/plugins/leetcode.lua @@ -0,0 +1,68 @@ +---@alias lc.lang +---| "cpp" +---| "java" +---| "python" +---| "python3" +---| "c" +---| "csharp" +---| "javascript" +---| "typescript" +---| "php" +---| "swift" +---| "kotlin" +---| "dart" +---| "golang" +---| "ruby" +---| "scala" +---| "rust" +---| "racket" +---| "erlang" +---| "elixir" + +---@alias lc.sql_lang +---| "pythondata" +---| "mysql" +---| "mssql" +---| "oraclesql" + +---@alias lc.domain +---| "com" +---| "cn" + +---@class lc.UserConfig +local M = { + ---@type lc.domain + domain = 'com', -- For now "com" is the only one supported + + ---@type string + arg = 'leetcode.nvim', + + ---@type lc.lang + lang = 'cpp', + + ---@type lc.sql_lang + sql = 'mysql', + + ---@type string + directory = vim.fn.stdpath('data') .. '/leetcode/', + + ---@type boolean + logging = true, + + console = { + ---@type boolean + open_on_runcode = false, + + size = { + width = '75%', ---@type string | integer + height = '75%', ---@type string | integer + }, + dir = 'row', ---@type "col" | "row" + }, + + description = { + width = '40%', ---@type string | integer + }, +} + +return M diff --git a/.config/nvim/lua/plugins/loclist.lua b/.config/nvim/lua/plugins/loclist.lua new file mode 100644 index 0000000..9b72a94 --- /dev/null +++ b/.config/nvim/lua/plugins/loclist.lua @@ -0,0 +1,18 @@ +local M = {} + +function M.loclist_toggle() + for _, info in ipairs(vim.fn.getwininfo()) do + if info.loclist == 1 then + vim.cmd('lclose') + return + end + end + + if next(vim.fn.getloclist(0)) == nil then + print('loc list empty') + return + end + vim.cmd('lopen') +end + +return M diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..8884599 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,426 @@ +local lspconfig = require('lspconfig') +local mason_lspconfig = require('mason-lspconfig') +local null_ls = require('null-ls') +-- local lsp_lines = require('lsp_lines') +require('mason').setup() +require('mason-null-ls').setup({ handlers = {}, ensure_installed = nil, automatic_installation = true, automatic_setup = true }) + +local keymap = vim.keymap +local cmd = vim.cmd + +local border = { { '┌', 'FloatBorder' }, { '─', 'FloatBorder' }, { '┐', 'FloatBorder' }, { '│', 'FloatBorder' }, { '┘', 'FloatBorder' }, { '─', 'FloatBorder' }, { '└', 'FloatBorder' }, { '│', 'FloatBorder' } } + +-- Set up LSP servers if not done before +if not vim.g.lsp_setup_done then + -- Clear existing LSP clients + for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do + local clients = require('user.mods').get_lsp_clients(bufnr) + + for _, client in ipairs(clients) do + client.stop() + end + end + + local signs = { Error = ' ', Warn = '▲', Info = '', Hint = '⚑' } + -- + for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end + + -- lsp_lines.setup() + + -- vim.keymap.set("n", "g?", function() + -- local lines_enabled = not vim.diagnostic.config().virtual_lines + -- vim.diagnostic.config( + -- { + -- virtual_lines = lines_enabled, + -- virtual_text = not lines_enabled + -- } + -- ) + -- end, { noremap = true, silent = true }) + + vim.diagnostic.config({ + underline = false, + signs = true, + virtual_text = true, -- virtual_lines = { only_current_line = true }, + virtual_lines = false, + float = { + show_header = true, + source = 'if_many', -- border = 'rounded', + border = border, + focusable = true, + }, + update_in_insert = false, -- default to false + severity_sort = true, -- default to false + }) + + vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = false, virtual_text = false, signs = true, update_in_insert = false }) + + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' }) + vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded' }) + + -- Use an on_attach function to only map the following keys after the language server attaches to the current buffer + local on_attach = function(client, bufnr) + -- Enable completion triggered by <c-x><c-o> + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + local map = function(mode, l, r, opts) + opts = opts or {} + opts.silent = true + opts.noremap = true + opts.buffer = bufnr + keymap.set(mode, l, r, opts) + end + -- Mappings + map('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>') + -- map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>") + map('n', 'gd', "<cmd>lua require('goto-preview').goto_preview_definition()<CR>") + -- map("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>") + map('n', 'gi', "<cmd>lua require('goto-preview').goto_preview_implementation()<CR>") + -- map("n", "gr", "<Cmd>lua vim.lsp.buf.references()<CR>") + map('n', 'gr', "<cmd>lua require('goto-preview').goto_preview_references()<CR>") + map('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>') -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. + map('n', '<leader>k', '<Cmd>lua vim.lsp.buf.signature_help()<CR>') + -- map("n", "gt", "<Cmd>lua vim.lsp.buf.type_definition()<CR>") + map('n', 'gt', "<cmd>lua require('goto-preview').goto_preview_type_definition()<CR>") + map('n', 'gn', '<Cmd>lua vim.lsp.buf.rename()<CR>') + map('n', 'ga', '<Cmd>lua vim.lsp.buf.code_action()<CR>') + map('n', 'gf', '<Cmd>lua vim.lsp.buf.formatting()<CR>') + map('n', 'go', '<Cmd>lua vim.diagnostic.open_float()<CR>') + map('n', '<leader>go', ":call utils#ToggleDiagnosticsOpenFloat()<CR> | :echom ('Toggle Diagnostics Float open/close...')<CR> | :sl! | echo ('')<CR>") + map('n', 'gq', '<Cmd>lua vim.diagnostic.setloclist()<CR>') + map('n', '[d', '<Cmd>lua vim.diagnostic.goto_prev()<CR>') + map('n', ']d', '<Cmd>lua vim.diagnostic.goto_next()<CR>') + map('n', 'gs', '<Cmd>lua vim.lsp.buf.document_symbol()<CR>') + map('n', 'gw', '<Cmd>lua vim.lsp.buf.workspace_symbol()<CR>') + map('n', '<leader>wa', '<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>') + map('n', '<leader>wr', '<Cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>') + map('n', '<leader>wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end) + + -- TODO: Use the nicer new API for autocommands + cmd('augroup lsp_aucmds') + if client.server_capabilities.documentHighlightProvider then + cmd('au CursorHold <buffer> lua vim.lsp.buf.document_highlight()') + cmd('au CursorMoved <buffer> lua vim.lsp.buf.clear_references()') + end + cmd('augroup END') + end + + -- Toggle diagnostics visibility + vim.g.diagnostics_visible = true + function _G.toggle_diagnostics() + if vim.g.diagnostics_visible then + vim.g.diagnostics_visible = false + vim.diagnostic.disable() + else + vim.g.diagnostics_visible = true + vim.diagnostic.enable() + end + end + + -- Open float for diagnostics automatically + vim.cmd([[ +augroup OpenFloat + " autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) + autocmd CursorHold * lua vim.diagnostic.open_float(nil, {focusable = false,}) + +augroup END +]]) + + -- Suppress error messages from lang servers + vim.lsp.set_log_level('debug') + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = require('cmp_nvim_lsp').default_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities.offsetEncoding = { 'utf-16' } + + local function prefer_null_ls_fmt(client) + client.server_capabilities.documentHighlightProvider = true + client.server_capabilities.documentFormattingProvider = true + on_attach(client) + end + + local cmp_nvim_lsp = require('cmp_nvim_lsp') + local servers = { + asm_lsp = {}, + bashls = {}, + clangd = { + on_attach = on_attach, + capabilities = cmp_nvim_lsp.default_capabilities(), + cmd = { + 'clangd', + '--offset-encoding=utf-16', + }, + }, + cssls = { filetypes = { 'css', 'scss', 'less', 'sass' }, root_dir = lspconfig.util.root_pattern('package.json', '.git') }, -- ghcide = {}, + html = {}, + jsonls = { prefer_null_ls = true, cmd = { '--stdio' } }, + intelephense = {}, + julials = { + on_new_config = function(new_config, _) + local julia = vim.fn.expand('~/.julia/environments/nvim-lspconfig/bin/julia') + if lspconfig.util.path.is_file(julia) then + new_config.cmd[1] = julia + end + end, + settings = { julia = { format = { indent = 2 } } }, + }, + pyright = { settings = { python = { formatting = { provider = 'yapf' }, linting = { pytypeEnabled = true } } } }, + rust_analyzer = { + settings = { + ['rust-analyzer'] = { cargo = { allFeatures = true }, checkOnSave = { command = 'clippy', extraArgs = { '--no-deps' } } }, + }, + }, + dartls = { + cmd = { 'dart', 'language-server', '--protocol=lsp' }, + filetypes = { 'dart' }, + init_options = { + closingLabels = true, + flutterOutline = true, + onlyAnalyzeProjectsWithOpenFiles = true, + outline = true, + suggestFromUnimportedLibraries = true, + }, -- root_dir = root_pattern("pubspec.yaml"), + settings = { dart = { completeFunctionCalls = true, showTodos = true } }, + on_attach = function(client, bufnr) end, + }, + lua_ls = { + on_attach = on_attach, + capabilities = capabilities, + debounce_text_changes = 500, + settings = { + Lua = { + runtime = { version = 'LuaJIT', path = vim.split(package.path, ';') }, + diagnostics = { enable = true, globals = { 'vim' } }, + workspace = { maxPreload = 2000, preloadFileSize = 50000, checkThirdParty = false }, + }, + }, + }, + sqlls = {}, + tsserver = { + capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), + on_attach = function(client) + client.server_capabilities.document_formatting = false + client.server_capabilities.document_range_formatting = false + end, + filetypes = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx' }, + }, + vimls = {}, + yamlls = {}, + } + + mason_lspconfig.setup({ + ensure_installed = servers, -- will be installed by mason + automatic_installation = true, + }) + + -- Your other configurations ... + -- require("lspconfig").dartls.setup({ capabilities = capabilities }) + -- local installed_lsp = mason_lspconfig.ensure_installed + -- local mason_lspconfig = require("mason-lspconfig").ensure_installed + + -- require("lspconfig").setup({ + -- function() + -- for _, lsp in ipairs(installed_lsp) do + -- if + -- lsp ~= "sqls" + -- --and lsp ~= "sumneko_lua" + -- --and lsp ~= "stylelint_lsp" + -- --and lsp ~= "rust_analyzer" + -- --and lsp ~= "sourcekit" + -- and lsp ~= "dartls" + -- then + -- lspconfig[lsp].setup({ + -- on_attach = on_attach, + -- capabilities = capabilities, + -- }) + -- end + -- end + -- end, + -- }) + + for server, config in pairs(servers) do + if config.prefer_null_ls then + if config.on_attach then + local old_on_attach = config.on_attach + config.on_attach = function(client, bufnr) + old_on_attach(client, bufnr) + prefer_null_ls_fmt(client) + end + else + config.on_attach = prefer_null_ls_fmt + end + elseif not config.on_attach then + config.on_attach = on_attach + end + + lspconfig[server].setup(config) + end + + -- null_ls setup + local builtins = null_ls.builtins + local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) + + -- local eslint_opts = { + -- -- condition = function(utils) + -- -- return utils.root_has_file ".eslintrc.js" or utils.root_has_file ".eslintrc" or utils.root_has_file ".eslintrc.json" + -- -- end, + -- -- diagnostics_format = "#{m} [#{c}]", + -- prefer_local = true, + -- } + + -- null_ls.setup({ + local sources = { + -- Diagnostics + builtins.diagnostics.chktex, + -- null_ls.builtins.code_actions.eslint_d, + -- null_ls.builtins.diagnostics.eslint_d, + -- null_ls.builtins.formatting.eslint_d, + -- null_ls.builtins.diagnostics.cppcheck, + -- null_ls.builtins.diagnostics.proselint, + -- null_ls.builtins.diagnostics.pylint, + -- builtins.diagnostics.selene, + builtins.diagnostics.dotenv_linter, + builtins.diagnostics.shellcheck.with({ -- shell script diagnostics + diagnostic_config = { -- see :help vim.diagnostic.config() + underline = true, + virtual_text = false, + signs = true, + update_in_insert = false, + severity_sort = true, + }, + diagnostics_format = '[#{c}] #{m} (#{s})', -- this will run every time the source runs, + -- so you should prefer caching results if possible + }), + builtins.diagnostics.zsh.with({ filetypes = 'zsh', 'sh' }), + builtins.diagnostics.todo_comments, + builtins.diagnostics.teal, + -- null_ls.builtins.diagnostics.vale, + builtins.diagnostics.vint, + builtins.diagnostics.tidy, + builtins.diagnostics.php, + builtins.diagnostics.phpcs, + builtins.diagnostics.flake8, + builtins.diagnostics.eslint_d.with({ + condition = function(utils) + return utils.root_has_file('.eslintrc.json') + end, + }), + builtins.formatting.eslint_d, + -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, + + -- Formatting + builtins.formatting.shfmt.with({ filetypes = { 'bash', 'zsh', 'sh' }, extra_args = { '-i', '2', '-ci' } }), + builtins.formatting.shellharden, + builtins.formatting.trim_whitespace.with({ filetypes = { 'tmux', 'teal', 'zsh' } }), -- builtins.formatting.beautysh, + builtins.formatting.beautysh.with({ filetypes = 'zsh' }), + builtins.formatting.clang_format, + builtins.formatting.rustfmt, + builtins.formatting.sql_formatter, + -- null_ls.builtins.formatting.cmake_format, + builtins.formatting.isort, + builtins.formatting.htmlbeautifier, -- null_ls.builtins.formatting.prettier, + builtins.formatting.prettierd, + builtins.formatting.prettier.with({ + filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'json', 'yaml', 'markdown', 'html', 'css', 'scss', 'less', 'graphql', 'vue', 'svelte' }, + extra_args = { '--single-quote', '--tab-width 4', '--print-width 200' }, + }), + builtins.formatting.rustfmt, + -- builtins.formatting.stylua, + -- builtins.formatting.lua_format, + builtins.formatting.stylua.with({ + filetypes = { 'lua' }, + command = 'stylua', + args = { '--quote_style', 'AutoPreferSingle', '--indent-width', '2', '--column-width', '160', '--indent-type', 'Spaces', '-' }, + }), + -- builtins.formatting.dart_format, + builtins.formatting.dart_format.with({ filetypes = { 'dart' } }), + builtins.formatting.trim_whitespace, + builtins.formatting.yapf, + -- null_ls.builtins.formatting.black + + -- Code Actions + builtins.code_actions.shellcheck, -- shell script code actions + -- builtins.code_actions.eslint_d.with(eslint_opts), + -- null_ls.builtins.code_actions.refactoring.with { filetypes = { 'javascript', 'typescript', 'lua', 'python', 'c', 'cpp' } }, + builtins.code_actions.gitsigns, + builtins.code_actions.gitrebase, -- Hover + builtins.hover.dictionary, + builtins.hover.printenv, + } + -- }) + -- Linters/Formatters ensure installed + -- for _, pkg_name in ipairs({ + -- "dart-debug-Adaptor", + -- "stylua", + -- "prettier", + -- "prettierd", + -- }) do + + -- Import the builtins table from the null-ls module and store it in the null_ls_sources variable + null_ls.setup({ + sources = sources, + update_in_insert = true, + on_attach = function(client, bufnr) + if client.supports_method('textDocument/formatting') then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd('BufWritePre', { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format() + end, + }) + end + end, + }) + + -- Install all the null-ls sources using Mason + local registry = require('mason-registry') + for _, source_name in ipairs(sources) do + local ok, pkg = pcall(registry.get_package, source_name) + if ok then + if not pkg:is_installed() then + pkg:install() + end + end + end + -- Loop through the null_ls_sources table and install the packages + -- Install all sources for null-ls + -- local null_ls_sources = require("null-ls").builtins + + -- for _, source_name in ipairs(null_ls_sources) do + -- local ok, pkg = pcall(mason.get_package, source_name) + -- if ok then + -- if not pkg:is_installed() then + -- pkg:install() + -- end + -- end + -- end + vim.api.nvim_create_user_command('NullLsToggle', function() + -- you can also create commands to disable or enable sources + require('null-ls').toggle({}) + end, {}) + + local null_ls_stop = function() + local null_ls_client + local clients = require('user.mods').get_lsp_clients(bufnr) + + for _, client in ipairs(clients) do + if client.name == 'null-ls' then + null_ls_client = client + end + end + if not null_ls_client then + return + end + + null_ls_client.stop() + end + + vim.api.nvim_create_user_command('NullLsStop', null_ls_stop, {}) + + vim.g.lsp_setup_done = true +end diff --git a/.config/nvim/lua/plugins/modify-blend.lua b/.config/nvim/lua/plugins/modify-blend.lua new file mode 100644 index 0000000..1b2c6d5 --- /dev/null +++ b/.config/nvim/lua/plugins/modify-blend.lua @@ -0,0 +1,43 @@ +local ui = vim.api.nvim_list_uis()[1] + +local bufnr = vim.api.nvim_create_buf(true, true) +local win = vim.api.nvim_open_win(bufnr, true, { + relative = "editor", + --relative = "cursor", + width = ui.width, + height = ui.height, + anchor = "NE", + row = 10, + col = 10, + style = "minimal", + zindex = 50, +}) + +vim.api.nvim_win_set_option(win, "winblend", 1) + +local blend_start = 15 +local offset = 1 + +CANCEL = false +local timer = vim.loop.new_timer() +timer:start( + 0, + 50, + vim.schedule_wrap(function() + blend_start = blend_start + offset + + if blend_start > 90 then + offset = -1 + elseif blend_start < 10 then + offset = 1 + end + + if CANCEL or not vim.api.nvim_win_is_valid(win) then + timer:close() + timer:stop() + return + end + + vim.cmd([[highlight NormalFloat blend=]] .. tostring(blend_start)) + end) +) diff --git a/.config/nvim/lua/plugins/navic.lua b/.config/nvim/lua/plugins/navic.lua new file mode 100644 index 0000000..a95485d --- /dev/null +++ b/.config/nvim/lua/plugins/navic.lua @@ -0,0 +1,50 @@ +local navic = require("nvim-navic") +--local on_attach = function(client, bufnr) +-- if client.server_capabilities.documentSymbolProvider then +-- navic.attach(client, bufnr) +-- end +--end + +--require("lspconfig").clangd.setup { +-- on_attach = on_attach +--} + +navic.setup { + icons = { + File = " ", + Module = " ", + Namespace = " ", + Package = " ", + Class = " ", + Method = " ", + Property = " ", + Field = " ", + Constructor = " ", + Enum = "練", + Interface = "練", + Function = " ", + Variable = " ", + Constant = " ", + String = " ", + Number = " ", + Boolean = "◩ ", + Array = " ", + Object = " ", + Key = " ", + Null = "ﳠ ", + EnumMember = " ", + Struct = " ", + Event = " ", + Operator = " ", + TypeParameter = " ", + }, + lsp = { + auto_attach = true, + --preference = nil, + }, + highlight = false, + separator = " > ", + depth_limit = 0, + depth_limit_indicator = "..", + safe_output = true +} diff --git a/.config/nvim/lua/plugins/neodev.lua b/.config/nvim/lua/plugins/neodev.lua new file mode 100644 index 0000000..f820422 --- /dev/null +++ b/.config/nvim/lua/plugins/neodev.lua @@ -0,0 +1,29 @@ +require("neodev").setup({ + --library = { plugins = { "nvim-dap-ui" }, types = true }, + --library = { plugins = { "neotest" }, types = true }, + library = { + enabled = true, -- when not enabled, neodev will not change any settings to the LSP server + -- these settings will be used for your Neovim config directory + runtime = true, -- runtime path + types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others + --plugins = { "neotest" }, + --{ "nvim-dap-ui" }, + --plugins = true, -- installed opt or start plugins in packpath + -- you can also specify the list of plugins to make available as a workspace library + -- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }, + plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim", "neotest", "nvim-dap-ui" }, + }, + setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files + -- for your Neovim config directory, the config.library settings will be used as is + -- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled + -- for any other directory, config.library.enabled will be set to false + override = function(root_dir, options) + end, + -- With lspconfig, Neodev will automatically setup your lua-language-server + -- If you disable this, then you have to set {before_init=require("neodev.lsp").before_init} + -- in your lsp start options + lspconfig = true, + -- much faster, but needs a recent built of lua-language-server + -- needs lua-language-server >= 3.6.0 + pathStrict = true, +}) diff --git a/.config/nvim/lua/plugins/neoscroll.lua b/.config/nvim/lua/plugins/neoscroll.lua new file mode 100644 index 0000000..d122584 --- /dev/null +++ b/.config/nvim/lua/plugins/neoscroll.lua @@ -0,0 +1,21 @@ +require("neoscroll").setup({ + easing_function = "quadratic", +}) + +local t = {} +-- Syntax: t[keys] = {function, {function arguments}} +-- Use the "sine" easing function +t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "20", [['cubic']] } } +t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "20", [['cubic']] } } +-- Use the "circular" easing function +t["<C-b>"] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } } +t["<C-f>"] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } } +-- Pass "nil" to disable the easing animation (constant scrolling speed) +t["<C-y>"] = { "scroll", { "-0.10", "false", "100", nil } } +t["<C-e>"] = { "scroll", { "0.10", "false", "100", nil } } +-- When no easing function is provided the default easing function (in this case "quadratic") will be used +t["zt"] = { "zt", { "10" } } +t["zz"] = { "zz", { "10" } } +t["zb"] = { "zb", { "10" } } + +require("neoscroll.config").set_mappings(t) diff --git a/.config/nvim/lua/plugins/neotest.lua b/.config/nvim/lua/plugins/neotest.lua new file mode 100644 index 0000000..aa73899 --- /dev/null +++ b/.config/nvim/lua/plugins/neotest.lua @@ -0,0 +1,11 @@ +require("neotest").setup({ + adapters = { + require("neotest-python")({ + dap = { justMyCode = false }, + }), + require("neotest-plenary"), + require("neotest-vim-test")({ + ignore_file_types = { "python", "vim", "lua" }, + }), + }, +}) diff --git a/.config/nvim/lua/plugins/notify.lua b/.config/nvim/lua/plugins/notify.lua new file mode 100644 index 0000000..dcb496a --- /dev/null +++ b/.config/nvim/lua/plugins/notify.lua @@ -0,0 +1,18 @@ +require('notify').setup({ + background_colour = '#000000', + icons = { + ERROR = '', + WARN = '', + INFO = '', + DEBUG = '', + TRACE = '✎', + }, +}) + +vim.api.nvim_command('hi default link NotifyERRORBody Normal') +vim.api.nvim_command('hi default link NotifyWARNBody Normal') +vim.api.nvim_command('hi default link NotifyINFOBody Normal') +vim.api.nvim_command('hi default link NotifyDEBUGBody Normal') +vim.api.nvim_command('hi default link NotifyTRACEBody Normal') +vim.api.nvim_command('hi default link NotifyLogTime Comment') +vim.api.nvim_command('hi default link NotifyLogTitle Special') diff --git a/.config/nvim/lua/plugins/nvim-tree.lua b/.config/nvim/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..f82a327 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-tree.lua @@ -0,0 +1,403 @@ +----------------------------------------------------------- +-- Neovim File Tree Configuration +----------------------------------------------------------- + +--- To see mappings `g?` on nvim-tree +--- To see default mappings `:nvim-tree-default-mappings` + +local icons = { + webdev_colors = true, + git_placement = 'signcolumn', + modified_placement = 'after', + padding = ' ', + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + modified = true, + }, + + glyphs = { + default = '', + symlink = '', + folder = { + arrow_open = '', + arrow_closed = '', + default = ' ', + open = ' ', + empty = ' ', + empty_open = ' ', + symlink = '', + symlink_open = '', + }, + + git = { + deleted = '', + unmerged = '', + untracked = '', + unstaged = '', + staged = '', + renamed = '➜', + ignored = '◌', + }, + }, + web_devicons = { + folder = { + enable = true, + color = true, + }, + }, +} + +local renderer = { + group_empty = true, -- default: true. Compact folders that only contain a single folder into one node in the file tree. + highlight_git = false, + full_name = false, + highlight_opened_files = 'icon', -- "none" (default), "icon", "name" or "all" + highlight_modified = 'icon', -- "none", "name" or "all". Nice and subtle, override the open icon + root_folder_label = ':~:s?$?/..?', + indent_width = 2, + indent_markers = { + enable = true, + inline_arrows = true, + icons = { + corner = '└', + edge = '│', + item = '│', + bottom = '─', + none = ' ', + }, + }, + icons = icons, +} + +local system_open = { cmd = 'zathura' } + +local HEIGHT_RATIO = 0.8 +local WIDTH_RATIO = 0.15 + +local float = { + enable = false, + open_win_config = function() + local screen_w = vim.opt.columns:get() + local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get() + local window_w = screen_w * WIDTH_RATIO + local window_h = screen_h * HEIGHT_RATIO + local window_w_int = math.floor(window_w) + local window_h_int = math.floor(window_h) + local center_x = (screen_w - window_w) / 2 + local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get() + return { + border = 'rounded', + relative = 'editor', + row = center_y, + col = center_x, + width = window_w_int, + height = window_h_int, + } + end, +} + +local view = { + cursorline = true, + float = float, + --signcolumn = 'no', + width = function() + return math.floor(vim.opt.columns:get() * WIDTH_RATIO) + end, + side = 'left', +} + +local api = require('nvim-tree.api') +local function on_attach(bufnr) + local function opts(desc) + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + local mappings = { + ['<C-]>'] = { api.tree.change_root_to_node, 'CD' }, + ['<C-e>'] = { api.node.open.replace_tree_buffer, 'Open: In Place' }, + ['<C-k>'] = { api.node.show_info_popup, 'Info' }, + ['<C-r>'] = { api.fs.rename_sub, 'Rename: Omit Filename' }, + ['<C-t>'] = { api.node.open.tab, 'Open: New Tab' }, + ['<C-v>'] = { api.node.open.vertical, 'Open: Vertical Split' }, + ['<C-x>'] = { api.node.open.horizontal, 'Open: Horizontal Split' }, + ['<BS>'] = { api.node.navigate.parent_close, 'Close Directory' }, + -- ["<CR>"] = { api.node.open.edit, "Open" }, + ['<Tab>'] = { api.node.open.preview, 'Open Preview' }, + ['>'] = { api.node.navigate.sibling.next, 'Next Sibling' }, + ['<'] = { api.node.navigate.sibling.prev, 'Previous Sibling' }, + ['.'] = { api.node.run.cmd, 'Run Command' }, + ['-'] = { api.tree.change_root_to_parent, 'Up' }, + ['a'] = { api.fs.create, 'Create' }, + ['bmv'] = { api.marks.bulk.move, 'Move Bookmarked' }, + ['B'] = { api.tree.toggle_no_buffer_filter, 'Toggle No Buffer' }, + ['c'] = { api.fs.copy.node, 'Copy' }, + -- ["C"] = { api.tree.toggle_git_clean_filter, "Toggle Git Clean" }, + ['[c'] = { api.node.navigate.git.prev, 'Prev Git' }, + [']c'] = { api.node.navigate.git.next, 'Next Git' }, + ['d'] = { api.fs.remove, 'Delete' }, + ['D'] = { api.fs.trash, 'Trash' }, + ['E'] = { api.tree.expand_all, 'Expand All' }, + ['e'] = { api.fs.rename_basename, 'Rename: Basename' }, + [']e'] = { api.node.navigate.diagnostics.next, 'Next Diagnostic' }, + ['[e'] = { api.node.navigate.diagnostics.prev, 'Prev Diagnostic' }, + ['F'] = { api.live_filter.clear, 'Clean Filter' }, + ['f'] = { api.live_filter.start, 'Filter' }, + ['g?'] = { api.tree.toggle_help, 'Help' }, + ['gy'] = { api.fs.copy.absolute_path, 'Copy Absolute Path' }, + ['H'] = { api.tree.toggle_hidden_filter, 'Toggle Dotfiles' }, + ['I'] = { api.tree.toggle_gitignore_filter, 'Toggle Git Ignore' }, + ['J'] = { api.node.navigate.sibling.last, 'Last Sibling' }, + ['K'] = { api.node.navigate.sibling.first, 'First Sibling' }, + ['m'] = { api.marks.toggle, 'Toggle Bookmark' }, + -- ["o"] = { api.node.open.edit, "Open" }, + ['O'] = { api.node.open.no_window_picker, 'Open: No Window Picker' }, + ['p'] = { api.fs.paste, 'Paste' }, + ['P'] = { api.node.navigate.parent, 'Parent Directory' }, + ['q'] = { api.tree.close, 'Close' }, + ['r'] = { api.fs.rename, 'Rename' }, + ['R'] = { api.tree.reload, 'Refresh' }, + ['s'] = { api.node.run.system, 'Run System' }, + ['S'] = { api.tree.search_node, 'Search' }, + ['U'] = { api.tree.toggle_custom_filter, 'Toggle Hidden' }, + ['W'] = { api.tree.collapse_all, 'Collapse' }, + ['x'] = { api.fs.cut, 'Cut' }, + ['y'] = { api.fs.copy.filename, 'Copy Name' }, + ['Y'] = { api.fs.copy.relative_path, 'Copy Relative Path' }, + ['<2-LeftMouse>'] = { api.node.open.edit, 'Open' }, + ['<2-RightMouse>'] = { api.tree.change_root_to_node, 'CD' }, + + -- Mappings migrated from view.mappings.list + ['l'] = { api.node.open.edit, 'Open' }, + ['<CR>'] = { api.node.open.edit, 'Open' }, + ['o'] = { api.node.open.edit, 'Open' }, + ['h'] = { api.node.navigate.parent_close, 'Close Directory' }, + ['v'] = { api.node.open.vertical, 'Open: Vertical Split' }, + ['C'] = { api.tree.change_root_to_node, 'CD' }, + } + for keys, mapping in pairs(mappings) do + vim.keymap.set('n', keys, mapping[1], opts(mapping[2])) + end +end +--api.events.subscribe(api.events.Event.FileCreated, function(file) +-- vim.cmd('edit' .. file.fname) +--end) + +require('nvim-tree').setup({ + --auto_reload_on_write = true, + --create_in_closed_folder = false, + --hijack_cursor = true, + --disable_netrw = true, + --hijack_netrw = true, + --hijack_unnamed_buffer_when_opening = false, + --ignore_buffer_on_setup = false, + update_focused_file = { + enable = true, + update_cwd = true, + update_root = true, + ignore_list = {}, + }, + root_dirs = {}, + --prefer_startup_root = true, + --hijack_directories = { + -- enable = false, + --}, + --respect_buf_cwd = false, + sync_root_with_cwd = true, + --reload_on_bufenter = false, + view = view, + system_open = system_open, + renderer = renderer, + on_attach = on_attach, + notify = { + threshold = vim.log.levels.ERROR, + }, + git = { ignore = false }, + diagnostics = { + enable = true, + show_on_dirs = true, + icons = { + hint = '⚑', + info = '', + warning = '▲', + error = '', + }, + }, + trash = { + cmd = 'gio trash', + require_confirm = true, + }, + modified = { + enable = true, + show_on_dirs = true, + show_on_open_dirs = true, + }, + --filters = { + -- dotfiles = false, + -- git_clean = false, + -- no_buffer = false, + -- custom = {}, + -- exclude = {}, + --}, + actions = { + use_system_clipboard = true, + change_dir = { + enable = true, + global = false, + restrict_above_cwd = false, + }, + remove_file = { + close_window = true, + }, + open_file = { + quit_on_open = true, + --eject = true, + resize_window = false, + window_picker = { + enable = true, + chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', + exclude = { + filetype = { 'notify', 'packer', 'qf', 'diff', 'fugitive', 'fugitiveblame' }, + buftype = { 'nofile', 'terminal', 'help' }, + }, + }, + }, + }, +}) + +local api = require('nvim-tree.api') +local event = api.events.Event +--api.events.subscribe(event.TreeOpen, function(_) +-- vim.cmd([[setlocal statuscolumn=\ ]]) +-- vim.cmd([[setlocal cursorlineopt=number]]) +-- vim.cmd([[setlocal fillchars+=vert:🮇]]) +-- vim.cmd([[setlocal fillchars+=horizup:🮇]]) +-- vim.cmd([[setlocal fillchars+=vertright:🮇]]) +--end) + +local function open_nvim_tree(data) + vim.cmd.cd(data.file:match('(.+)/[^/]*$')) + local directory = vim.fn.isdirectory(data.file) == 1 + if not directory then + return + end + require('nvim-tree.api').tree.open() +end +vim.api.nvim_create_autocmd({ 'VimEnter' }, { callback = open_nvim_tree }) + +-- Change Root To Global Current Working Directory +local function change_root_to_global_cwd() + local api = require('nvim-tree.api') + local global_cwd = vim.fn.getcwd(-1, -1) + api.tree.change_root(global_cwd) +end + +local function copy_file_to(node) + local file_src = node['absolute_path'] + -- The args of input are {prompt}, {default}, {completion} + -- Read in the new file path using the existing file's path as the baseline. + local file_out = vim.fn.input('COPY TO: ', file_src, 'file') + -- Create any parent dirs as required + local dir = vim.fn.fnamemodify(file_out, ':h') + vim.fn.system({ 'mkdir', '-p', dir }) + -- Copy the file + vim.fn.system({ 'cp', '-R', file_src, file_out }) +end + +local function edit_and_close(node) + api.node.open.edit(node, {}) + api.tree.close() +end + +--vim.api.nvim_create_augroup('NvimTreeRefresh', {}) +--vim.api.nvim_create_autocmd('BufEnter', { +-- pattern = 'NvimTree_1', +-- command = 'NvimTreeRefresh', +-- group = 'NvimTreeRefresh', +--}) + +vim.api.nvim_create_autocmd({ 'CursorHold' }, { + pattern = 'NvimTree*', + callback = function() + local def = vim.api.nvim_get_hl_by_name('Cursor', true) + vim.api.nvim_set_hl( + 0, + 'Cursor', + vim.tbl_extend('force', def, { + blend = 100, + }) + ) + vim.opt.guicursor:append('a:Cursor/lCursor') + end, +}) + +vim.api.nvim_create_autocmd({ 'BufLeave', 'WinClosed', 'WinLeave' }, { + pattern = 'NvimTree*', + callback = function() + local def = vim.api.nvim_get_hl_by_name('Cursor', true) + vim.api.nvim_set_hl( + 0, + 'Cursor', + vim.tbl_extend('force', def, { + blend = 0, + }) + ) + vim.opt.guicursor = 'n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20' + end, +}) + +-- Highlight Groups +vim.api.nvim_command('highlight NvimTreeNormal guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeNormalNC guibg=NONE ctermbg=NONE guifg=NONE') +vim.api.nvim_command('highlight NvimTreeNormalFloat guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeEndOfBuffer guibg=NONE ctermbg=NONE') --(NonText) +vim.api.nvim_command('highlight NvimTreeCursorLine guibg=#50fa7b guifg=#000000') +vim.api.nvim_command('highlight NvimTreeSymlinkFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeRootFolder guifg=#f8f8f2 guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeEmptyFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') --(Directory) +vim.api.nvim_command('highlight NvimTreeOpenedFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') --(Directory) +vim.api.nvim_command('highlight NvimTreeOpenedFile guifg=#50fa7b guibg=NONE ctermbg=NONE') + +--vim.api.nvim_command("highlight NvimTreeSymlink ") +--vim.api.nvim_command("highlight NvimTreeSymlinkFolderName ") --(Directory) +--vim.api.nvim_command("highlight NvimTreeFolderName ") --(Directory) +--vim.api.nvim_command("highlight NvimTreeRootFolder ") +--vim.api.nvim_command("highlight NvimTreeFolderIcon ") +--vim.api.nvim_command("highlight NvimTreeOpenedFolderIcon ") --(NvimTreeFolderIcon) +--vim.api.nvim_command("highlight NvimTreeClosedFolderIcon ") --(NvimTreeFolderIcon) +--vim.api.nvim_command("highlight NvimTreeFileIcon ") +--vim.api.nvim_command("highlight NvimTreeEmptyFolderName ") --(Directory) +--vim.api.nvim_command("highlight NvimTreeOpenedFolderName ") --(Directory) +--vim.api.nvim_command("highlight NvimTreeExecFile ") +--vim.api.nvim_command("highlight NvimTreeOpenedFile ") +--vim.api.nvim_command("highlight NvimTreeModifiedFile ") +--vim.api.nvim_command("highlight NvimTreeSpecialFile ") +--vim.api.nvim_command("highlight NvimTreeImageFile ") +--vim.api.nvim_command("highlight NvimTreeIndentMarker ") +--vim.api.nvim_command("highlight NvimTreeLspDiagnosticsError ") --(DiagnosticError) +--vim.api.nvim_command("highlight NvimTreeLspDiagnosticsWarning ") --(DiagnosticWarn) +--vim.api.nvim_command("highlight NvimTreeLspDiagnosticsInformation ") --(DiagnosticInfo) +--vim.api.nvim_command("highlight NvimTreeLspDiagnosticsHint ") --(DiagnosticHint) +--vim.api.nvim_command("highlight NvimTreeGitDirty ") +--vim.api.nvim_command("highlight NvimTreeGitStaged ") +--vim.api.nvim_command("highlight NvimTreeGitMerge ") +--vim.api.nvim_command("highlight NvimTreeGitRenamed ") +--vim.api.nvim_command("highlight NvimTreeGitNew ") +--vim.api.nvim_command("highlight NvimTreeGitDeleted ") +--vim.api.nvim_command("highlight NvimTreeGitIgnored ") --(Comment) +--vim.api.nvim_command("highlight NvimTreeNormal ") +--vim.api.nvim_command("highlight NvimTreeEndOfBuffer ") --(NonText) +--vim.api.nvim_command("highlight NvimTreeCursorColumn ") --(CursorColumn) +--vim.api.nvim_command("highlight NvimTreeFileDirty ") --(NvimTreeGitDirty) +--vim.api.nvim_command("highlight NvimTreeFileStaged ") --(NvimTreeGitStaged) +--vim.api.nvim_command("highlight NvimTreeFileMerge ") --(NvimTreeGitMerge) +--vim.api.nvim_command("highlight NvimTreeFileRenamed ") --(NvimTreeGitRenamed) +--vim.api.nvim_command("highlight NvimTreeFileNew ") --(NvimTreeGitNew) +--vim.api.nvim_command("highlight NvimTreeFileDeleted ") --(NvimTreeGitDeleted) +--vim.api.nvim_command("highlight NvimTreeFileIgnored ") --(NvimTreeGitIgnored) +--vim.api.nvim_command("highlight NvimTreeLiveFilterPrefix ") +--vim.api.nvim_command("highlight NvimTreeLiveFilterValue ") +--vim.api.nvim_command("highlight NvimTreeBookmark ") diff --git a/.config/nvim/lua/plugins/quickfix.lua b/.config/nvim/lua/plugins/quickfix.lua new file mode 100644 index 0000000..4a76da0 --- /dev/null +++ b/.config/nvim/lua/plugins/quickfix.lua @@ -0,0 +1,15 @@ +local M = {} + +M.close = function() + vim.cmd.cclose() +end + +M.open = function() + if vim.tbl_count(vim.fn.getqflist()) == 0 then + vim.notify('Nothing in quickfix list; not opening.', vim.log.levels.WARN) + else + vim.cmd.copen() + end +end + +return M diff --git a/.config/nvim/lua/plugins/session.lua b/.config/nvim/lua/plugins/session.lua new file mode 100644 index 0000000..0c84625 --- /dev/null +++ b/.config/nvim/lua/plugins/session.lua @@ -0,0 +1,5 @@ +require('auto-session').setup({ + log_level = 'error', + auto_session_suppress_dirs = { '~/', '~/projects', '~/downloads', '/' }, +}) +require('session-lens').setup({}) diff --git a/.config/nvim/lua/plugins/snippets.lua b/.config/nvim/lua/plugins/snippets.lua new file mode 100644 index 0000000..7df6b2f --- /dev/null +++ b/.config/nvim/lua/plugins/snippets.lua @@ -0,0 +1,68 @@ +local ls = require "luasnip" -- + +require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) +--local options = { +ls.config.set_config { + history = true, + updateevents = "TextChanged,TextChangedI", + -- Autosnippets: + enable_autosnippets = true, -- + region_check_events = "InsertEnter", + delete_check_events = "TextChanged", + update_events = "TextChanged,TextChangedI", + store_selection_keys = "<Tab>", + ext_opts = { -- + [require("luasnip.util.types").choiceNode] = { + active = { + virt_text = { { "«", "GruvboxOrange" } }, + }, + }, + }, +} + +--local keymap = vim.keymap +--local keymap = vim.api.nvim_set_keymap +local keymap = vim.keymap.set +--keymap('i', '<c-f>', 'luasnip#expand_or_jumpable() ? "<Plug>luasnip-expand-or-jump" : "<Tab>"', {expr = true, silent = true}) +keymap({ "i", "s"}, "<c-f>", function() + if ls.expand_or_jumpable() then + ls.expand() + end +end) + +keymap({ "i", "s"}, "<c-j>", function() + if ls.jumpable(1) then + ls.jump(1) + end +end) + +keymap({ "i", "s"}, "<c-k>", function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end) + +keymap({ "i", "s"}, "<c-c>", function() + if ls.choice_active() then + ls.change_choice(1) + end +end) + +keymap({ "i", "s"}, "<a-c>", function() + if ls.choice_active() then + ls.change_choice(-1) + end +end) + +-- Character class Matching +-- %a letters (A-Z, a-z) +-- %c control characters (\n, \t, \r, ...) +-- %d digits (0-9) +-- %l lower-case letter (a-z) +-- %p punctuation characters (!, ?, &, ...) +-- %s space characters +-- %u upper-case letters +-- %w alphanumeric characters (A-Z, a-z, 0-9) +-- %x hexadecimal digits (\3, \4, ...) +-- %z the character with representation 0 +-- . Matches any character diff --git a/.config/nvim/lua/plugins/sniprun.lua b/.config/nvim/lua/plugins/sniprun.lua new file mode 100644 index 0000000..2556c24 --- /dev/null +++ b/.config/nvim/lua/plugins/sniprun.lua @@ -0,0 +1,57 @@ +local status_ok, sniprun = pcall(require, 'sniprun') +if not status_ok then + return +end + +sniprun.setup({ + -- selected_interpreters = {}, --# use those instead of the default for the current filetype + -- repl_enable = { "Python3_original" }, --# enable REPL-like behavior for the given interpreters + -- repl_disable = {}, --# disable REPL-like behavior for the given interpreters + + -- interpreter_options = { --# intepreter-specific options, see docs / :SnipInfo <name> + -- GFM_original = { + -- use_on_filetypes = { "markdown.pandoc" }, --# the 'use_on_filetypes' configuration key is + -- --# available for every interpreter + -- }, + -- }, + + --# you can combo different display modes as desired + display = { + -- "Classic", --# display results in the command-line area + 'VirtualTextOk', --# display ok results as virtual text (multiline is shortened) + -- "VirtualTextErr", --# display error results as virtual text + -- "TempFloatingWindow", --# display results in a floating window + -- "LongTempFloatingWindow", --# same as above, but only long results. To use with VirtualText__ + -- "Terminal", --# display results in a vertical split + -- "TerminalWithCode", --# display results and code history in a vertical split + -- "NvimNotify", --# display with the nvim-notify plugin + -- "Api" --# return output to a programming interface + }, + + display_options = { + terminal_width = 45, --# change the terminal display option width + notification_timeout = 5, --# timeout for nvim_notify output + }, + + --# You can use the same keys to customize whether a sniprun producing + --# no output should display nothing or '(no output)' + show_no_output = { + 'Classic', + 'TempFloatingWindow', --# implies LongTempFloatingWindow, which has no effect on its own + }, + + --# customize highlight groups (setting this overrides colorscheme) + -- snipruncolors = { + -- SniprunVirtualTextOk = { bg = "NONE", fg = "#66eeff", ctermbg = "Black", cterfg = "Cyan" }, + -- SniprunFloatingWinOk = { fg = "NONE", ctermfg = "Cyan" }, + -- SniprunVirtualTextErr = { bg = "#881515", fg = "#000000", ctermbg = "DarkRed", cterfg = "Black" }, + -- SniprunFloatingWinErr = { fg = "#881515", ctermfg = "DarkRed" }, + -- }, + + --# miscellaneous compatibility/adjustement settings + inline_messages = 0, --# inline_message (0/1) is a one-line way to display messages + --# to workaround sniprun not being able to display anything + + borders = 'single', --# display borders around floating windows + --# possible values are 'none', 'single', 'double', or 'shadow' +}) diff --git a/.config/nvim/lua/plugins/statuscol.lua b/.config/nvim/lua/plugins/statuscol.lua new file mode 100644 index 0000000..24a2308 --- /dev/null +++ b/.config/nvim/lua/plugins/statuscol.lua @@ -0,0 +1,28 @@ +local status, statuscol = pcall(require, "statuscol") + +if not status then + vim.notify("statuscol not found") + return +end + +local builtin = require("statuscol.builtin") + +statuscol.setup({ + segments = { + { text = { builtin.lnumfunc }, click = "v:lua.ScLa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + }, + ft_ignore = { + "NvimTree", + "packer", + "NeogitStatus", + "toggleterm", + "dapui_scopes", + "dapui_breakpoints", + "dapui_stacks", + "dapui_watches", + "dapui_console", + "dapui_repl", + }, +}) diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..cf0864a --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,618 @@ +local M = {} + +-- Shorten function names +local actions = require('telescope.actions') +local fb_actions = require('telescope').extensions.file_browser.actions +--local builtin = require("telescope.builtin") +--local utils = require("telescope.utils") +--local layout_actions = require("telescope.actions.layout") +--local themes = require('telescope.themes') +local actions_set = require('telescope.actions.set') +local actions_state = require('telescope.actions.state') +local finders = require('telescope.finders') +local pickers = require('telescope.pickers') +local config = require('telescope.config').values + +require('telescope').setup({ + defaults = { + vimgrep_arguments = { + 'rg', + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + '--smart-case', + '--hidden', + '--fixed-strings', + '--trim', + }, + prompt_prefix = ' ', + selection_caret = ' ', + entry_prefix = ' ', + path_display = { 'tail' }, + --path_display = { "truncate" }, + --path_display = { "smart" }, + file_ignore_patterns = { + 'packer_compiled.lua', + '~/.config/zsh/plugins', + 'zcompdump', + '%.DS_Store', + '%.git/', + '%.spl', + --"%.log", + '%[No Name%]', -- new files / sometimes folders (netrw) + '/$', -- ignore folders (netrw) + 'node_modules', + '%.png', + '%.zip', + '%.pxd', + --"^.vim/", + '^.local/', + '^.cache/', + '^downloads/', + '^music/', + --"^node_modules/", + --"^undodir/", + }, + mappings = { + i = { + ['<C-n>'] = actions.cycle_history_next, + ['<C-p>'] = actions.cycle_history_prev, + + ['<C-j>'] = actions.move_selection_next, + ['<C-k>'] = actions.move_selection_previous, + + --["<C-c>"] = actions.close, + ['<Esc>'] = actions.close, -- close w/ one esc + --["<Esc>"] = "close", -- close w/ one esc + ['<?>'] = actions.which_key, -- keys from pressing <C-/> + + ['<Down>'] = actions.move_selection_next, + ['<Up>'] = actions.move_selection_previous, + + ['<CR>'] = actions.select_default, + ['<C-x>'] = actions.select_horizontal, + ['<C-y>'] = actions.select_vertical, + ['<C-t>'] = actions.select_tab, + + ['<C-u>'] = actions.preview_scrolling_up, + ['<C-d>'] = actions.preview_scrolling_down, + + ['<PageUp>'] = actions.results_scrolling_up, + ['<PageDown>'] = actions.results_scrolling_down, + + ['<Tab>'] = actions.toggle_selection + actions.move_selection_worse, + ['<S-Tab>'] = actions.toggle_selection + actions.move_selection_better, + ['<C-q>'] = actions.send_to_qflist + actions.open_qflist, + ['<M-q>'] = actions.send_selected_to_qflist + actions.open_qflist, + ['<C-l>'] = actions.complete_tag, + ['<C-_>'] = actions.which_key, -- keys from pressing <C-/> + --["<C-o>"] = function(prompt_bufnr) + -- local selection = require("telescope.actions.state").get_selected_entry() + -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") + -- require("telescope.actions").close(prompt_bufnr) + -- -- Depending on what you want put `cd`, `lcd`, `tcd` + -- vim.cmd(string.format("silent lcd %s", dir)) + --end, + }, + n = { + --["cd"] = function(prompt_bufnr) + -- local selection = require("telescope.actions.state").get_selected_entry() + -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") + -- require("telescope.actions").close(prompt_bufnr) + -- -- Depending on what you want put `cd`, `lcd`, `tcd` + -- vim.cmd(string.format("silent lcd %s", dir)) + --end, + ['<esc>'] = actions.close, + ['<q>'] = actions.close, + ['<CR>'] = actions.select_default, + ['<C-x>'] = actions.select_horizontal, + ['<C-y>'] = actions.select_vertical, + ['<C-t>'] = actions.select_tab, + + ['<Tab>'] = actions.toggle_selection + actions.move_selection_worse, + ['<S-Tab>'] = actions.toggle_selection + actions.move_selection_better, + ['<C-q>'] = actions.send_to_qflist + actions.open_qflist, + ['<M-q>'] = actions.send_selected_to_qflist + actions.open_qflist, + + ['j'] = actions.move_selection_next, + ['k'] = actions.move_selection_previous, + ['H'] = actions.move_to_top, + ['M'] = actions.move_to_middle, + ['L'] = actions.move_to_bottom, + + ['<Down>'] = actions.move_selection_next, + ['<Up>'] = actions.move_selection_previous, + ['gg'] = actions.move_to_top, + ['G'] = actions.move_to_bottom, + + ['<C-u>'] = actions.preview_scrolling_up, + ['<C-d>'] = actions.preview_scrolling_down, + + ['<PageUp>'] = actions.results_scrolling_up, + ['<PageDown>'] = actions.results_scrolling_down, + ['cd'] = function(prompt_bufnr) + local selection = require('telescope.actions.state').get_selected_entry() + local dir = vim.fn.fnamemodify(selection.path, ':p:h') + require('telescope.actions').close(prompt_bufnr) + -- Depending on what you want put `cd`, `lcd`, `tcd` + vim.cmd(string.format('silent lcd %s', dir)) + end, + ['?'] = actions.which_key, + --["<C-o>"] = function(prompt_bufnr) + -- local selection = require("telescope.actions.state").get_selected_entry() + -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") + -- require("telescope.actions").close(prompt_bufnr) + -- -- Depending on what you want put `cd`, `lcd`, `tcd` + -- vim.cmd(string.format("silent lcd %s", dir)) + --end, + }, + }, + }, + preview = { + filesize_limit = 3, + timeout = 250, + }, + selection_strategy = 'reset', + sorting_strategy = 'ascending', + scroll_strategy = 'limit', + color_devicons = true, + layout_strategy = 'horizontal', + layout_config = { + horizontal = { + height = 0.95, + preview_cutoff = 70, + width = 0.92, + preview_width = { 0.55, max = 50 }, + }, + bottom_pane = { + height = 12, + preview_cutoff = 70, + prompt_position = 'bottom', + }, + }, + find_files = { + --cwd = '%:p:h', + cwd = vim.fn.getcwd(), + prompt_prefix = ' ', + --hidden = true, + --no_ignore = false, + follow = true, + }, + --pickers = { + -- live_grep = { + -- disable_coordinates = true, + -- layout_config = { + -- horizontal = { + -- preview_width = 0.55, + -- }, + -- }, + -- }, + --}, + --pickers = { + -- live_grep = { + -- mappings = { + -- i = { + -- ["<C-f>"] = ts_select_dir_for_grep, + -- }, + -- n = { + -- ["<C-f>"] = ts_select_dir_for_grep, + -- }, + -- }, + -- }, + --}, + --pickers = { + --lsp_references = { + -- prompt_prefix='⬅️', + -- show_line=false, + -- trim_text=true, + -- include_declaration=false, + -- initial_mode = "normal", + --}, + --lsp_definitions = { + -- prompt_prefix='➡️', + -- show_line=false, + -- trim_text=true, + -- initial_mode = "normal", + --}, + --lsp_document_symbols = { + -- prompt_prefix='* ', + -- show_line = false, + --}, + --treesitter = { + -- prompt_prefix=' ', + -- show_line = false, + --}, + --keymaps = { prompt_prefix='? ' }, + --oldfiles = { prompt_prefix=' ' }, + --highlights = { prompt_prefix=' ' }, + --git_files = { + -- prompt_prefix=' ', + -- show_untracked = true, + -- path_display = { "tail" }, + --}, + --buffers = { + -- prompt_prefix=' ', + -- ignore_current_buffer = true, + -- initial_mode = "normal", + -- sort_mru = true, + --}, + --live_grep = { + -- cwd='%:p:h', + -- disable_coordinates=true, + -- prompt_title='Search in Folder', + -- prompt_prefix=' ', + --}, + --spell_suggest = { + -- initial_mode = "normal", + -- prompt_prefix = "暈", + -- theme = "cursor", + -- layout_config = { cursor = { width = 0.3 } } + --}, + --colorscheme = { + -- enable_preview = true, + -- prompt_prefix = '', + -- results_title = '', + -- layout_strategy = "bottom_pane", + --}, + --}, + + extensions = { + file_browser = { + theme = 'dropdown', + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = false, + mappings = { + -- your custom insert mode mappings + ['i'] = { + ['<C-w>'] = function() + vim.cmd('normal vbd') + end, + ['<C-h>'] = fb_actions.goto_parent_dir, + }, + ['n'] = { + -- your custom normal mode mappings + ['N'] = fb_actions.create, + ['<C-h>'] = fb_actions.goto_parent_dir, + --["/"] = function() + -- vim.cmd("startinsert") + --end, + }, + }, + }, + }, +}) + +-------------------------------------------------------------------------------- + +-- Load extensions: +-- have to be loaded after telescope setup/config +require('telescope').load_extension('fzf') +require('telescope').load_extension('ui-select') +require('telescope').load_extension('file_browser') +require('telescope').load_extension('changed_files') +require('telescope').load_extension('media_files') +require('telescope').load_extension('notify') +require('telescope').load_extension('dap') +require('telescope').load_extension('session-lens') +require('telescope').load_extension('flutter') +require('telescope').load_extension('recent_files') +--require('telescope').load_extension('projects') + +--M.curbuf = function(opts) +-- opts = opts +-- or themes.get_dropdown({ +-- previewer = false, +-- shorten_path = false, +-- border = true, +-- }) +-- require("telescope.builtin").current_buffer_fuzzy_find(opts) +--end + +function M.find_configs() + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = false, + prompt_title = ' Find Configs', + results_title = 'Config Files', + path_display = { 'smart' }, + search_dirs = { + '~/.vim', + '~/.config/nvim', + '~/.config/zsh', + '~/.config/tmux', + '~/.config/X11', + '~/.config/alacritty', + '~/.config/kitty', + '~/.config/wezterm', + '~/.config/bspwm', + '~/.config/sxhkd', + '~/.config/picom', + '~/.config/polybar', + '~/.bashrc', + '~/.profile', + '~/.zprofile', + '~/.gitconfig', + '~/.gitsubtrees', + '~/.gitignore', + '~/.editorconfig', + '~/.prettierrc.yml', + '~/.ssh', + '~/README.md', + '~/.config/inputrc', + }, + file_ignore_patterns = { + '/nvim/startup.log', + 'zsh/plugins', + 'packer_compiled.lua', + 'resurrect', + 'tmux/plugins', + --"^~/.config/tmux/plugins", + '%.txt', + '.git/', + 'autoload/plugged', + 'plug.vim', + 'zcompdump', + }, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65, width = 0.75 }, + }) +end + +function M.find_scripts() + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = true, + prompt_title = ' Find Scripts', + path_display = { 'smart' }, + search_dirs = { + '~/.local/bin/scripts', + }, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65, width = 0.75 }, + }) +end + +--function M.find_projects() -- aka Workspaces +-- require('telescope.builtin').find_files({ +-- hidden = true, +-- no_ignore = true, +-- prompt_title = ' Find Projects', +-- path_display = { 'smart' }, +-- search_dirs = { +-- '~/projects', +-- }, +-- layout_strategy = 'horizontal', +-- layout_config = { preview_width = 0.65, width = 0.75 }, +-- }) +--end + +function M.find_projects() + local search_dir = '~/projects' + pickers + .new({}, { + prompt_title = 'Find Projects', + finder = finders.new_oneshot_job({ + 'find', + vim.fn.expand(search_dir), + '-type', + 'd', + '-maxdepth', + '1', + }), + previewer = require('telescope.previewers').vim_buffer_cat.new({}), + sorter = config.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + actions_set.select:replace(function() + local entry = actions_state.get_selected_entry() + if entry ~= nil then + local dir = entry.value + actions.close(prompt_bufnr, false) + vim.fn.chdir(dir) + vim.cmd('e .') + vim.cmd("echon ''") + print('cwd: ' .. vim.fn.getcwd()) + end + end) + return true + end, + }) + :find() +end + +function M.grep_notes() + local opts = {} + opts.hidden = false + opts.search_dirs = { + '~/documents/notes/', + } + opts.prompt_prefix = ' ' + opts.prompt_title = ' Grep Notes' + opts.path_display = { 'smart' } + require('telescope.builtin').live_grep(opts) +end + +function M.find_notes() + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = false, + prompt_title = ' Find Notes', + path_display = { 'smart' }, + search_dirs = { + '~/documents/notes/private/', + '~/documents/notes', + '~/notes/private', + '~/notes', + }, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65, width = 0.75 }, + }) +end + +function M.find_books() + local search_dir = '~/documents/books' + + pickers + .new({}, { + prompt_title = 'Find Books', + finder = finders.new_oneshot_job({ + 'find', + vim.fn.expand(search_dir), + '-type', + 'd', + '-o', + '-type', + 'f', + '-maxdepth', + '1', + }), + previewer = require('telescope.previewers').vim_buffer_cat.new({}), + sorter = config.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + actions_set.select:replace(function() + local entry = actions_state.get_selected_entry() + if entry ~= nil then + local path = entry.value + actions.close(prompt_bufnr, false) + + -- Determine whether it's a directory or a file + local is_directory = vim.fn.isdirectory(path) + + if is_directory then + -- It's a directory, navigate to it + vim.fn.chdir(path) + vim.cmd('e .') + print('Selected directory: ' .. path) + else + -- It's a file, do something with it (open it, for example) + print('Selected file: ' .. path) + end + end + end) + return true + end, + }) + :find() +end + +function M.grep_current_dir() + local buffer_dir = require('telescope.utils').buffer_dir() + local opts = { + prompt_title = 'Live Grep in ' .. buffer_dir, + cwd = buffer_dir, + } + require('telescope.builtin').live_grep(opts) +end + +-------------------------------------------------------------------------------- + +local dropdown = require('telescope.themes').get_dropdown({ + hidden = true, + no_ignore = true, + previewer = false, + prompt_title = '', + preview_title = '', + results_title = '', + layout_config = { + --anchor = "S", + prompt_position = 'top', + }, +}) + +-- File browser always relative to buffer +--local opts_file_browser = vim.tbl_extend('force', dropdown, { +-- path_display = { '%:p:h' }, +--}) + +-- Set current folder as prompt title +local with_title = function(opts, extra) + extra = extra or {} + local path = opts.cwd or opts.path or extra.cwd or extra.path or nil + local title = '' + local buf_path = vim.fn.expand('%:p:h') + local cwd = vim.fn.getcwd() + if path ~= nil and buf_path ~= cwd then + title = require('plenary.path'):new(buf_path):make_relative(cwd) + else + title = vim.fn.fnamemodify(cwd, ':t') + end + + return vim.tbl_extend('force', opts, { + prompt_title = title, + }, extra or {}) +end + +-- Find here +function M.findhere() + -- Open file browser if argument is a folder + local arg = vim.api.nvim_eval('argv(0)') + if arg and (vim.fn.isdirectory(arg) ~= 0 or arg == '') then + vim.defer_fn(function() + require('telescope.builtin').find_files(with_title(dropdown)) + -- require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ + -- hidden = true, + -- results_title = '', + -- layout_config = { prompt_position = 'top' }, + -- })) + end, 10) + end +end + +-- Define the custom command findhere/startup +vim.cmd('command! Findhere lua require("plugins.telescope").findhere()') +--vim.cmd('command! Startup lua require("plugins.telescope").findhere()') +--vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").findhere()') + +-- Find dirs +function M.find_dirs() + local root_dir = vim.fn.input('Enter the root directory: ') + + -- Check if root_dir is empty + if root_dir == '' then + print('No directory entered. Aborting.') + return + end + + local entries = {} + + -- Use vim.fn.expand() to get an absolute path + local root_path = vim.fn.expand(root_dir) + + local subdirs = vim.fn.readdir(root_path) + if subdirs then + for _, subdir in ipairs(subdirs) do + if vim.fn.isdirectory(root_path .. '/' .. subdir) == 1 then + table.insert(entries, subdir) + end + end + end + + pickers + .new({}, { + prompt_title = 'Change Directory', + finder = finders.new_table({ + results = entries, + }), + previewer = config.file_previewer({}), + sorter = config.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + actions_set.select:replace(function() + local entry = actions_state.get_selected_entry() + if entry ~= nil then + local selected_subdir = entry.value + actions.close(prompt_bufnr, false) + local selected_path = root_path .. '/' .. selected_subdir + vim.fn.chdir(selected_path) + vim.cmd('e .') + vim.cmd("echon ''") + print('cwd: ' .. vim.fn.getcwd()) + end + end) + return true + end, + }) + :find() +end + +return M diff --git a/.config/nvim/lua/plugins/toggleterm.lua b/.config/nvim/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..2f978a4 --- /dev/null +++ b/.config/nvim/lua/plugins/toggleterm.lua @@ -0,0 +1,176 @@ +local status_ok, toggleterm = pcall(require, "toggleterm") +if not status_ok then + return +end +toggleterm.setup({ + --open_mapping = [[<leader>tt]], + autochdir = true, + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 1, + start_in_insert = true, + insert_mappings = true, + terminal_mappings = true, + persist_size = true, + direction = "float", + --direction = "vertical", + --direction = "horizontal", + close_on_exit = true, + shell = vim.o.shell, + highlights = { + -- highlights which map to a highlight group name and a table of it's values + -- NOTE: this is only a subset of values, any group placed here will be set for the terminal window split + --Normal = { + -- background = "#000000", + --}, + Normal = { guibg = 'Black', guifg = 'DarkGray' }, + FloatBorder = { guibg = 'Black', guifg = 'DarkGray' }, + NormalFloat = { guibg = 'Black' }, + --float_opts = { + -- border = as.style.current.border, + -- winblend = 3, + --}, + }, + size = function(term) + if term.direction == 'horizontal' then + return 7 + elseif term.direction == 'vertical' then + return math.floor(vim.o.columns * 0.4) + end + end, + float_opts = { + width = 70, + height = 15, + winblend = 3, + border = "curved", + --winblend = 0, + highlights = { + border = "Normal", + background = "Normal", + }, + }, +}) +local mods = require("user.mods") +local float_handler = function(term) + if not mods.empty(vim.fn.mapcheck('jk', 't')) then + vim.keymap.del('t', 'jk', { buffer = term.bufnr }) + vim.keymap.del('t', '<esc>', { buffer = term.bufnr }) + end +end + +function _G.set_terminal_keymaps() + local opts = { noremap = true } + --local opts = {buffer = 0} + --vim.api.nvim_buf_set_keymap(0, "i", ";to", "[[<Esc>]]<cmd>Toggleterm", opts) + vim.api.nvim_buf_set_keymap(0, "t", "<C-c>", [[<Esc>]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "<esc>", [[<C-\><C-n>]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "jk", [[<C-\><C-n>]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "<C-h>", [[<C-\><C-n><C-W>h]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "<C-j>", [[<C-\><C-n><C-W>j]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "<C-k>", [[<C-\><C-n><C-W>k]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "<C-l>", [[<C-\><C-n><C-W>l]], opts) +end + +-- if you only want these mappings for toggle term use term://*toggleterm#* instead +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') +local Terminal = require("toggleterm.terminal").Terminal + +local horizontal_term = Terminal:new({ hidden = true, direction = "horizontal" }) +local vertical_term = Terminal:new({ hidden = true, direction = "vertical" }) + +function Horizontal_term_toggle() + horizontal_term:toggle(8, "horizontal") +end +function Vertical_term_toggle() + horizontal_term:toggle(math.floor(vim.o.columns * 0.5), "vertical") +end + +local lazygit = Terminal:new({ + cmd = "lazygit", + count = 5, + id = 1000, + dir = "git_dir", + direction = "float", + on_open = float_handler, + hidden = true, + float_opts = { + border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, + width = 150, + height = 40 + }, + + ---- Function to run on opening the terminal + --on_open = function(term) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', 'q', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', '<esc>', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', '<C-\\>', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + --end, + ---- Function to run on closing the terminal + --on_close = function(term) + -- vim.cmd("startinsert!") + --end +}) + +function Lazygit_toggle() + -- cwd is the root of project. if cwd is changed, change the git. + local cwd = vim.fn.getcwd() + if cwd ~= Cur_cwd then + Cur_cwd = cwd + lazygit:close() + lazygit = Terminal:new({ + cmd = "zsh --login -c 'lazygit'", + dir = "git_dir", + direction = "float", + hidden = true, + on_open = float_handler, + float_opts = { + border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, + width = 150, + height = 40 + }, + }) + end + lazygit:toggle() +end + +local node = Terminal:new({ cmd = "node", hidden = true }) + +function _NODE_TOGGLE() + node:toggle() +end + +local ncdu = Terminal:new({ cmd = "ncdu", hidden = true }) + +function _NCDU_TOGGLE() + ncdu:toggle() +end + +local htop = Terminal:new({ cmd = "htop", hidden = true }) + +function _HTOP_TOGGLE() + htop:toggle() +end + +local python = Terminal:new({ cmd = "python", hidden = true }) + +function _PYTHON_TOGGLE() + python:toggle() +end + +function Gh_dash() +Terminal:new({ + cmd = 'gh dash', + hidden = true, + direction = 'float', + on_open = float_handler, + float_opts = { + height = function() return math.floor(vim.o.lines * 0.8) end, + width = function() return math.floor(vim.o.columns * 0.95) end, + }, +}) + Gh_dash:toggle() +end diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..7f481d3 --- /dev/null +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,31 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the four listed parsers should always be installed) + + ensure_installed = { + "c", + "bash", + "lua", + "rust", + }, + --ensure_installed = "all", -- one of "all" or a list of languages + --ignore_install = { "" }, -- List of parsers to ignore installing + sync_install = false, + auto_install = true, + highlight = { + enable = false, + disable = {}, + }, + indent = { + enable = true, + disable = {}, + --disable = { "python", "css" } + }, + autotag = { + enable = true, + }, +} +--vim.opt.foldmethod = "expr" +--vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + +--local parser_config = require "nvim-treesitter.parsers".get_parser_configs() +--parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" } diff --git a/.config/nvim/lua/plugins/trouble.lua b/.config/nvim/lua/plugins/trouble.lua new file mode 100644 index 0000000..7d74730 --- /dev/null +++ b/.config/nvim/lua/plugins/trouble.lua @@ -0,0 +1,47 @@ +require('trouble').setup({ + position = 'bottom', -- position of the list can be: bottom, top, left, right + height = 10, -- height of the trouble list when position is top or bottom + width = 50, -- width of the list when position is left or right + icons = true, -- use devicons for filenames + mode = 'document_diagnostics', -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" + fold_open = '', -- icon used for open folds + fold_closed = '', -- icon used for closed folds + group = true, -- group results by file + padding = true, -- add an extra new line on top of the list + action_keys = { -- key mappings for actions in the trouble list + -- map to {} to remove a mapping, for example: + -- close = {}, + close = 'q', -- close the list + cancel = '<esc>', -- cancel the preview and get back to your last window / buffer / cursor + refresh = 'r', -- manually refresh + jump = { '<cr>', '<tab>' }, -- jump to the diagnostic or open / close folds + open_split = { '<c-x>' }, -- open buffer in new split + open_vsplit = { '<c-v>' }, -- open buffer in new vsplit + open_tab = { '<c-t>' }, -- open buffer in new tab + jump_close = { 'o' }, -- jump to the diagnostic and close the list + toggle_mode = 'm', -- toggle between "workspace" and "document" diagnostics mode + toggle_preview = 'P', -- toggle auto_preview + hover = 'K', -- opens a small popup with the full multiline message + preview = 'p', -- preview the diagnostic location + close_folds = { 'zM', 'zm' }, -- close all folds + open_folds = { 'zR', 'zr' }, -- open all folds + toggle_fold = { 'zA', 'za' }, -- toggle fold of current file + previous = 'k', -- previous item + next = 'j', -- next item + }, + indent_lines = true, -- add an indent guide below the fold icons + auto_open = false, -- automatically open the list when you have diagnostics + auto_close = false, -- automatically close the list when you have no diagnostics + auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window + auto_fold = false, -- automatically fold a file trouble list at creation + auto_jump = { 'lsp_definitions' }, -- for the given modes, automatically jump if there is only a single result + signs = { + -- icons / text used for a diagnostic + error = '', + warning = '▲', + information = '', + hint = '⚑', + other = '', + }, + use_diagnostic_signs = true, -- enabling this will use the signs defined in your lsp client +}) diff --git a/.config/nvim/lua/plugins/web-devicons.lua b/.config/nvim/lua/plugins/web-devicons.lua new file mode 100644 index 0000000..06f2d1c --- /dev/null +++ b/.config/nvim/lua/plugins/web-devicons.lua @@ -0,0 +1,22 @@ +local devicons = require('nvim-web-devicons') + +-- Set devicons overrides early. +devicons.setup({ + override = { + js = { icon = '', color = '#f5c06f', name = 'Js' }, + jsx = { icon = '', color = '#689fb6', name = 'Jsx' }, + ts = { icon = '', color = '#4377c1', name = 'Ts' }, + tsx = { icon = '', color = '#4377c1', name = 'Tsx' }, + png = { icon = '', color = '#d4843e', name = 'Png' }, + webp = { icon = '', color = '#3498db', name = 'Webp' }, + jpg = { icon = '', color = '#16a085', name = 'Jpg' }, + svg = { icon = '', color = '#3affdb', name = 'Svg' }, + zsh = { + icon = '', + color = '#428850', + cterm_color = '65', + name = 'Zsh', + }, + }, + color_icons = true, +}) diff --git a/.config/nvim/lua/plugins/which-key.lua b/.config/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..10c0c41 --- /dev/null +++ b/.config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,60 @@ +require("which-key").setup { + plugins = { + marks = true, -- shows a list of your marks on ' and ` + registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode + spelling = { + enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions + suggestions = 9, -- how many suggestions should be shown in the list? + }, + -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- No actual key bindings are created + presets = { + operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion + motions = true, -- adds help for motions + text_objects = true, -- help for text objects triggered after entering an operator + windows = true, -- default bindings on <c-w> + nav = true, -- misc bindings to work with windows + z = true, -- bindings for folds, spelling and others prefixed with z + g = true, -- bindings for prefixed with g + }, + }, + -- add operators that will trigger motion and text object completion + -- to enable all native operators, set the preset / operators plugin above + operators = { gc = "Comments" }, + key_labels = { + -- override the label used to display some keys. It doesn't effect WK in any other way. + -- For example: + -- ["<space>"] = "SPC", + -- ["<cr>"] = "RET", + -- ["<tab>"] = "TAB", + }, + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "➜", -- symbol used between a key and it's label + group = "+", -- symbol prepended to a group + }, + window = { + border = "none", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 0, 0, 0, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 1, 0, 1, 0 }, -- extra window padding [top, right, bottom, left] + }, + layout = { + height = { min = 1, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 1, -- spacing between columns + align = "center", -- align columns left, center or right + }, + ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label + hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate + show_help = true, -- show help message on the command line when the popup is visible + triggers = "auto", -- automatically setup triggers + -- triggers = {"<leader>"} -- or specify a list manually + + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + -- this is mostly relevant for key maps that start with a native binding + -- most people should not need to change this + n = { "o", "O" }, + }, +} diff --git a/.config/nvim/lua/plugins/zen-mode.lua b/.config/nvim/lua/plugins/zen-mode.lua new file mode 100644 index 0000000..7e52854 --- /dev/null +++ b/.config/nvim/lua/plugins/zen-mode.lua @@ -0,0 +1,7 @@ +local status, zenMode = pcall(require, "zen-mode") +if (not status) then return end + +zenMode.setup { +} + +vim.keymap.set('n', '<C-w>o', '<cmd>ZenMode<cr>', { silent = true }) diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua new file mode 100644 index 0000000..d97d86d --- /dev/null +++ b/.config/nvim/lua/user/keys.lua @@ -0,0 +1,440 @@ +local keymap = vim.keymap +local map = function(mode, l, r, opts) + opts = opts or {} + opts.silent = true + opts.noremap = true + keymap.set(mode, l, r, opts) +end +local term_opts = { noremap = true, silent = false } +local bufnr = vim.api.nvim_get_current_buf() + +-- Semi-colon as leader key +vim.g.mapleader = ';' + +-- "jk" and "kj" to exit insert-mode +map('i', 'jk', '<esc>') + +-- Jump to next match on line using `.` instead of `;` NOTE: commented out in favour of "ggandor/flit.nvim" +--map("n", ".", ";") + +-- Repeat last command using `<Space>` instead of `.` NOTE: commented out in favour of "ggandor/flit.nvim" +--map("n", "<Space>", ".") + +-- Reload nvim config +map('n', '<leader><CR>', "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nvim config loading...') | :sl! | echo ('')<CR>") + +--------------- Extended Operations --------------- +-- Conditional 'q' to quit on floating/quickfix/help windows otherwise still use it for macros +-- TODO: Have a list of if available on system/packages, example "Zen Mode" to not work on it (quit Zen Mode) +map('n', 'q', function() + local config = vim.api.nvim_win_get_config(0) + if config.relative ~= '' then -- is_floating_window? + return ':silent! close!<CR>' + elseif vim.o.buftype == 'quickfix' then + return ':quit<CR>' + elseif vim.o.buftype == 'help' then + return ':close<CR>' + else + return 'q' + end +end, { expr = true, replace_keycodes = true }) + +-- Combine buffers list with buffer name +map('n', '<Leader>b', ':buffers<CR>:buffer<Space>') + +-- Buffer confirmation +map('n', '<leader>y', ':BufferPick<CR>') + +-- Map buffer next, prev and delete to <leader>+(n/p/d) respectively +map('n', '<leader>n', ':bn<cr>') +map('n', '<leader>p', ':bp<cr>') +map('n', '<leader>d', ':bd<cr>') + +-- Delete file of current buffer +map('n', '<leader>rm', "<CMD>call delete(expand('%')) | bdelete!<CR>") + +-- List marks +map('n', '<Leader>m', ':marks<CR>') + +-- Messages +map('n', '<Leader>M', ':messages<CR>') + +-- Clear messages or just refresh/redraw the screen +map('n', '<leader>u', ":echo '' | redraw<CR>") + +-- Unsets the 'last search pattern' register by hitting return +--map("n", "<CR>", "!silent :noh<CR><CR>") + +-- Toggle set number +map('n', '<leader>$', ':NumbersToggle<CR>') +map('n', '<leader>%', ':NumbersOnOff<CR>') + +-- Easier split navigations, just ctrl-j instead of ctrl-w then j +map('t', '<C-[>', '<C-\\><C-N>') +map('t', '<C-h>', '<C-\\><C-N><C-h>') +map('t', '<C-j>', '<C-\\><C-N><C-j>') +map('t', '<C-k>', '<C-\\><C-N><C-k>') +map('t', '<C-l>', '<C-\\><C-N><C-l>') + +-- Split window +map('n', '<leader>h', ':split<CR>') +map('n', '<leader>v', ':vsplit<CR>') +map('n', '<leader>c', '<C-w>c') + +-- Resize Panes +map('n', '<Leader>+', ':resize +5<CR>') +map('n', '<Leader>-', ':resize -5<CR>') +map('n', '<Leader><', ':vertical resize +5<CR>') +map('n', '<Leader>>', ':vertical resize -5<CR>') +map('n', '<Leader>=', '<C-w>=') + +-- Map Alt+(h/j/k/l) in insert(include terminal/command) mode to move directional +map({ 'i', 't', 'c' }, '<A-h>', '<left>') +map({ 'i', 't', 'c' }, '<A-j>', '<down>') +map({ 'i', 't', 'c' }, '<A-k>', '<up>') +map({ 'i', 't', 'c' }, '<A-l>', '<right>') + +-- Create tab, edit and move between them +map('n', '<C-T>n', ':tabnew<CR>') +map('n', '<C-T>e', ':tabedit') +map('n', '<leader>[', ':tabprev<CR>') +map('n', '<leader>]', ':tabnext<CR>') + +-- "Zoom" a split window into a tab and/or close it +--map("n", "<Leader>,", ":tabnew %<CR>") +--map("n", "<Leader>.", ":tabclose<CR>") + +-- Vim TABs +map('n', '<leader>1', '1gt<CR>') +map('n', '<leader>2', '2gt<CR>') +map('n', '<leader>3', '3gt<CR>') +map('n', '<leader>4', '4gt<CR>') +map('n', '<leader>5', '5gt<CR>') +map('n', '<leader>6', '6gt<CR>') +map('n', '<leader>7', '7gt<CR>') +map('n', '<leader>8', '8gt<CR>') +map('n', '<leader>9', '9gt<CR>') +map('n', '<leader>0', '10gt<CR>') + +-- Hitting ESC when inside a terminal to get into normal mode +--map("t", "<Esc>", [[<C-\><C-N>]]) + +-- Move block (indentation) easily +map('n', '<', '<<', term_opts) +map('n', '>', '>>', term_opts) +map('x', '<', '<gv', term_opts) +map('x', '>', '>gv', term_opts) + +-- Set alt+(j/k) to switch lines of texts or simply move them +map('n', '<A-k>', ':let save_a=@a<Cr><Up>"add"ap<Up>:let @a=save_a<Cr>') +map('n', '<A-j>', ':let save_a=@a<Cr>"add"ap:let @a=save_a<Cr>') + +-- Toggle Diff +map('n', '<leader>df', '<Cmd>call utils#ToggleDiff()<CR>') + +-- Toggle Verbose +map('n', '<leader>vt', '<Cmd>call utils#VerboseToggle()<CR>') + +-- Jump List +map('n', '<leader>j', '<Cmd>call utils#GotoJump()<CR>') + +-- Rename file +map('n', '<leader>rf', '<Cmd>call utils#RenameFile()<CR>') + +-- Map delete to Ctrl+l +map('i', '<C-l>', '<Del>') + +-- Clear screen +map('n', '<leader><C-l>', '<Cmd>!clear<CR>') + +-- Change file to an executable +map('n', '<Leader>x', ":lua require('user.mods').Toggle_executable()<CR> | :echom ('Toggle executable')<CR> | :sl! | echo ('')<CR>") +-- map("n", "<leader>x", ":!chmod +x %<CR>") + +-- Paste without replace clipboard +map('v', 'p', '"_dP') + +-- Swap two pieces of text, use x to cut in visual mode, then use Ctrl-x in +-- visual mode to select text to swap with +--map("v", "<C-X>", "<Esc>`.``gvP``P") + +-- Change Working Directory to current project +map('n', '<leader>cd', ':cd %:p:h<CR>:pwd<CR>') + +-- Open the current file in the default program (on Mac this should just be just `open`) +map('n', '<leader>o', ':!xdg-open %<cr><cr>') + +-- URL handling +if vim.fn.has('mac') == 1 then + map('', 'gx', '<Cmd>call jobstart(["open", expand("<cfile>")], {"detach": v:true})<CR>', {}) +elseif vim.fn.has('unix') == 1 then + map('', 'gx', '<Cmd>call jobstart(["xdg-open", expand("<cfile>")], {"detach": v:true})<CR>', {}) +elseif vim.fn.has('wsl') == 1 then + map('', 'gx', '<Cmd>call jobstart(["wslview", expand("<cfile>")], {"detach": v:true})<CR>', {}) +else + map[''].gx = { '<Cmd>lua print("Error: gx is not supported on this OS!")<CR>' } +end + +-- Search and replace +map('v', '<leader>sr', 'y:%s/<C-r><C-r>"//g<Left><Left>c') + +-- Substitute globally and locally in the selected region. +map('n', '<leader>s', ':%s//g<Left><Left>') +map('v', '<leader>s', ':s//g<Left><Left>') + +-- Toggle completion +map('n', '<Leader>tc', ':lua require("user.mods").toggle_completion()<CR>') + +-- Disable default completion. +map('i', '<C-n>', '<Nop>') +map('i', '<C-p>', '<Nop>') + +-- Set line wrap +map('n', '<M-z>', function() + local wrap_status = vim.api.nvim_exec('set wrap ?', true) + + if wrap_status == 'nowrap' then + vim.api.nvim_command('set wrap linebreak') + print('Wrap enabled') + else + vim.api.nvim_command('set wrap nowrap') + print('Wrap disabled') + end +end, { silent = true }) + +-- Toggle between folds +--utils.map("n", "<F2>", "&foldlevel ? 'zM' : 'zR'", { expr = true }) + +-- Use space to toggle fold +map('n', '<Space>', 'za') + +-- Make a copy of current file +--vim.cmd([[ +-- map <leader>s :up \| saveas! %:p:r-<C-R>=strftime("%y.%m.%d-%H:%M")<CR>-bak.<C-R>=expand("%:e")<CR> \| 3sleep \| e #<CR> +--]]) +map('n', '<leader>.b', ':!cp % %.backup<CR>') + +-- Toggle transparency +map('n', '<leader>tb', ':call utils#Toggle_transparent_background()<CR>') + +-- Toggle zoom +map('n', '<leader>z', ':call utils#ZoomToggle()<CR>') +map('n', '<C-w>z', '<C-w>|<C-w>_') + +-- Toggle statusline +map('n', '<S-h>', ':call utils#ToggleHiddenAll()<CR>') + +-- Open last closed buffer +map('n', '<C-t>', ':call OpenLastClosed()<CR>') + +---------------- Plugin Operations ---------------- +-- Packer +map('n', '<leader>Pc', '<cmd>PackerCompile<cr>') +map('n', '<leader>Pi', '<cmd>PackerInstall<cr>') +map('n', '<leader>Ps', '<cmd>PackerSync<cr>') +map('n', '<leader>PS', '<cmd>PackerStatus<cr>') +map('n', '<leader>Pu', '<cmd>PackerUpdate<cr>') + +-- Tmux navigation (aserowy/tmux.nvim) +map('n', '<C-h>', '<CMD>NavigatorLeft<CR>') +map('n', '<C-l>', '<CMD>NavigatorRight<CR>') +map('n', '<C-k>', '<CMD>NavigatorUp<CR>') +map('n', '<C-j>', '<CMD>NavigatorDown<CR>') + +-- ToggleTerm +map({ 'n', 't' }, '<leader>tt', '<cmd>ToggleTerm<CR>') +map({ 'n', 't' }, '<leader>th', '<cmd>lua Horizontal_term_toggle()<CR>') +map({ 'n', 't' }, '<leader>tv', '<cmd>lua Vertical_term_toggle()<CR>') + +-- LazyGit +map({ 'n', 't' }, '<leader>gg', '<cmd>lua Lazygit_toggle()<CR>') + +map('n', '<leader>tg', '<cmd>lua Gh_dash()<CR>') + +-- Fugitive git bindings +map('n', '<leader>gs', vim.cmd.Git) +map('n', '<leader>ga', ':Git add %:p<CR><CR>') +--map("n", "<leader>gs", ":Gstatus<CR>") +map('n', '<leader>gc', ':Gcommit -v -q<CR>') +map('n', '<leader>gt', ':Gcommit -v -q %:p<CR>') +--map("n", "<leader>gd", ":Gdiff<CR>") +map('n', '<leader>ge', ':Gedit<CR>') +--map("n", "<leader>gr", ":Gread<Cj>") +map('n', '<leader>gw', ':Gwrite<CR><CR>') +map('n', '<leader>gl', ':silent! Glog<CR>:bot copen<CR>') +--map("n", "<leader>gp", ":Ggrep<Space>") +--map("n", "<Leader>gp", ":Git push<CR>") +--map("n", "<Leader>gb", ":Gblame<CR>") +map('n', '<leader>gm', ':Gmove<Space>') +--map("n", "<leader>gb", ":Git branch<Space>") +--map("n", "<leader>go", ":Git checkout<Space>") +--map("n", "<leader>gps", ":Dispatch! git push<CR>") +--map("n", "<leader>gpl", ":Dispatch! git pull<CR>") + +-- Telescope +map('n', '<leader>ff', ":cd %:p:h<CR>:pwd<CR><cmd>lua require('telescope.builtin').find_files()<cr>") -- find files with hidden option +map('n', '<leader>fF', ":cd %:p:h<CR>:pwd<CR><cmd>lua require('user.mods').findFilesInCwd()<CR>", { noremap = true, silent = true, desc = 'Find files in cwd' }) +map('n', '<leader>f.', function() + require('telescope.builtin').find_files({ hidden = false, no_ignore = true }) +end) -- find all files +map('n', '<leader>fg', "<cmd>lua require('telescope.builtin').live_grep()<cr>") +map('n', '<leader>fb', "<cmd>lua require('telescope.builtin').buffers()<cr>") +map('n', '<leader>fh', "<cmd>lua require('telescope.builtin').help_tags()<cr>") +map('n', '<leader>fc', "<cmd>lua require('telescope.builtin').commands()<cr>") +map('n', '<leader>cf', '<cmd>Telescope changed_files<cr>') +map('n', '<leader>fp', '<cmd>Telescope pickers<cr>') +map('n', '<leader>fd', "<cmd>lua require('telescope.builtin').diagnostics()<cr>") +map('n', '<leader>fk', "<cmd>lua require('telescope.builtin').keymaps()<cr>") +map('n', '<leader>fr', "<cmd>lua require('telescope.builtin').registers({})<CR>") -- registers picker +map('n', '<leader>fm', "<cmd>lua require('telescope').extensions.media_files.media_files({})<cr>") -- find media files +map('n', '<leader>fi', "<cmd>lua require('telescope').extensions.notify.notify({})<cr>") -- find notifications +map('n', '<Leader>fs', '<cmd>lua require("session-lens").search_session()<CR>') +map('n', '<leader>ffd', [[<Cmd>lua require'plugins.telescope'.find_dirs()<CR>]]) -- find dies +map('n', '<leader>ff.', [[<Cmd>lua require'plugins.telescope'.find_configs()<CR>]]) -- find configs +map('n', '<leader>ffs', [[<Cmd>lua require'plugins.telescope'.find_scripts()<CR>]]) -- find scripts +map('n', '<leader>ffw', [[<Cmd>lua require'plugins.telescope'.find_projects()<CR>]]) -- find projects +map('n', '<leader>ffb', [[<Cmd>lua require'plugins.telescope'.find_books()<CR>]]) -- find books +map('n', '<leader>ffn', [[<Cmd>lua require'plugins.telescope'.find_notes()<CR>]]) -- find notes +map('n', '<leader>fgn', [[<Cmd>lua require'plugins.telescope'.grep_notes()<CR>]]) -- search notes +map('n', '<Leader>ffr', "<cmd>lua require('telescope').extensions.recent_files.pick()<CR>") +map('n', '<leader>ffc', "<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<cr>") +map('n', '<Leader>f/', "<cmd>lua require('telescope').extensions.file_browser.file_browser()<CR>") +--map("n", "<leader>f/", "<cmd>lua require('plugins.telescope').curbuf()<cr>") -- find files with hidden option +-- Map a shortcut to open the picker. + +-- FZF +map('n', '<leader>fz', "<cmd>lua require('fzf-lua').files()<CR>") + +-- Nvim-tree +map('n', '<leader>f', '<cmd>Rooter<CR>:NvimTreeToggle<CR>', {}) +map('n', '<leader>F', ':NvimTreeFindFileToggle<CR>', { noremap = false, silent = true }) + +-- Undotree +map('n', '<leader>u', vim.cmd.UndotreeToggle) + +-- Markdown-preview +map('n', '<leader>md', '<Plug>MarkdownPreviewToggle') +map('n', '<leader>mg', '<CMD>Glow<CR>') + +-- Autopairs +map('n', '<leader>ww', "<cmd>lua require('user.mods').Toggle_autopairs()<CR>") + +-- Zen-mode toggle +map('n', '<leader>zm', "<CMD>ZenMode<CR> | :echom ('Zen Mode')<CR> | :sl! | echo ('')<CR>") + +-- Vim-rooter +map('n', '<leader>ro', "<CMD>Rooter<CR> | :echom ('cd to root/project directory')<CR> | :sl! | echo ('')<CR>", term_opts) + +-- Trouble (UI to show diagnostics) +map('n', '<leader>t', ':cd %:p:h<CR>:pwd<CR><CMD>TroubleToggle<CR>') +map('n', '<leader>tw', ':cd %:p:h<CR>:pwd<CR><CMD>TroubleToggle workspace_diagnostics<CR>') +map('n', '<leader>td', ':cd %:p:h<CR>:pwd<CR><CMD>TroubleToggle document_diagnostics<CR>') +map('n', '<leader>tq', ':cd %:p:h<CR>:pwd<CR><CMD>TroubleToggle quickfix<CR>') +map('n', '<leader>tl', ':cd %:p:h<CR>:pwd<CR><CMD>TroubleToggle loclist<CR>') +map('n', 'gR', '<CMD>TroubleToggle lsp_references<CR>') + +-- Null-ls +map('n', '<leader>ls', '<CMD>NullLsToggle<CR>') + +-- Replacer +map('n', '<Leader>qr', ':lua require("replacer").run()<CR>') + +-- Quickfix +map('n', '<leader>q', function() + if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then + require('plugins.quickfix').close() + else + require('plugins.quickfix').open() + end +end, { desc = 'Toggle quickfix window' }) + +-- Move to the next and previous item in the quickfixlist +map('n', ']c', '<Cmd>cnext<CR>') +map('n', '[c', '<Cmd>cprevious<CR>') + +-- Location list +map('n', '<leader>l', '<cmd>lua require("plugins.loclist").loclist_toggle()<CR>') + +-- Dap (debugging) +local dap_ok, dap = pcall(require, 'dap') +local dap_ui_ok, ui = pcall(require, 'dapui') + +if not (dap_ok and dap_ui_ok) then + require('notify')('nvim-dap or dap-ui not installed!', 'warning') + return +end + +vim.fn.sign_define('DapBreakpoint', { text = '🐞' }) + +-- Start debugging session +map('n', '<leader>ds', function() + dap.continue() + ui.toggle({}) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-w>=', false, true, true), 'n', false) -- Spaces buffers evenly +end) + +-- Set breakpoints, get variable values, step into/out of functions, etc. +map('n', '<leader>dC', dap.continue) +-- map("n", "<leader>dC", dap.close) +-- map("n", "<leader>dt", dap.terminate) +map('n', '<leader>dt', ui.toggle) +map('n', '<leader>dd', function() + dap.disconnect({ terminateDebuggee = true }) +end) +map('n', '<leader>dn', dap.step_over) +map('n', '<leader>di', dap.step_into) +map('n', '<leader>do', dap.step_out) +map('n', '<leader>db', dap.toggle_breakpoint) +map('n', '<leader>dB', function() + dap.clear_breakpoints() + require('notify')('Breakpoints cleared', 'warn') +end) +map('n', '<leader>dl', require('dap.ui.widgets').hover) +map('n', '<leader>de', function() + require('dapui').float_element() +end, { desc = 'Open Element' }) +map('n', '<leader>dq', function() + require('dapui').close() + require('dap').repl.close() + local session = require('dap').session() + if session then + require('dap').terminate() + end + require('nvim-dap-virtual-text').refresh() +end, { desc = 'Terminate Debug' }) +map('n', '<leader>dc', function() + require('telescope').extensions.dap.commands() +end, { desc = 'DAP-Telescope: Commands' }) +--vim.keymap.set("n", "<leader>B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>") +--vim.keymap.set("v", "<leader>B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>") +--vim.keymap.set("n", "<leader>lp", ":lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>") +--vim.keymap.set("n", "<leader>dr", ":lua require'dap'.repl.open()<CR>") + +-- Close debugger and clear breakpoints +--map("n", "<leader>de", function() +-- dap.clear_breakpoints() +-- ui.toggle({}) +-- dap.terminate() +-- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<C-w>=", false, true, true), "n", false) +-- require("notify")("Debugger session ended", "warn") +--end) + +-- Toggle Dashboard +map('n', '<leader><Space>', '<CMD>lua require("user.mods").toggle_dashboard()<CR>') + +-- Lsp Lines toggle +map('', '<Leader>ll', require('lsp_lines').toggle, { desc = 'Toggle lsp_lines' }) + +-- SnipRun +map({ 'n', 'v' }, '<leader>r', '<Plug>SnipRun<CR>') + +-- Codi +map('n', '<leader>co', '<CMD>lua require("user.mods").toggleCodi()<CR>') + +-- Scratch buffer +map('n', '<leader>ss', '<CMD>lua require("user.mods").Scratch("float")<CR>') +map('n', '<leader>sh', '<CMD>lua require("user.mods").Scratch("horizontal")<CR>') +map('n', '<leader>sv', '<CMD>lua require("user.mods").Scratch("vertical")<CR>') + +-- Hardtime +map('n', '<leader>H', ':Hardtime toggle<CR>') diff --git a/.config/nvim/lua/user/mods.lua b/.config/nvim/lua/user/mods.lua new file mode 100644 index 0000000..b6431a6 --- /dev/null +++ b/.config/nvim/lua/user/mods.lua @@ -0,0 +1,818 @@ +local M = {} + +--- Shorten Function Names +local fn = vim.fn +function M.executable(name) + if fn.executable(name) > 0 then + return true + end + + return false +end + +-------------------------------------------------- + +--- Check whether a feature exists in Nvim +--- @feat: string +--- the feature name, like `nvim-0.7` or `unix`. +--- return: bool +M.has = function(feat) + if fn.has(feat) == 1 then + return true + end + + return false +end + +-------------------------------------------------- + +-- Format on save +local format_augroup = vim.api.nvim_create_augroup('LspFormatting', {}) +require('null-ls').setup({ + -- you can reuse a shared lspconfig on_attach callback here + on_attach = function(client, bufnr) + if client.supports_method('textDocument/formatting') then + vim.api.nvim_clear_autocmds({ group = format_augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd('BufWritePre', { + group = format_augroup, + buffer = bufnr, + callback = function() + -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead + --vim.lsp.buf.formatting_seq_sync() + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + end + end, +}) + +vim.cmd([[autocmd BufWritePre <buffer> lua vim.lsp.buf.format()]]) +--vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] + +-------------------------------------------------- + +---Determine if a value of any type is empty +---@param item any +---@return boolean? +function M.empty(item) + if not item then + return true + end + local item_type = type(item) + if item_type == 'string' then + return item == '' + end + if item_type == 'number' then + return item <= 0 + end + if item_type == 'table' then + return vim.tbl_isempty(item) + end + return item ~= nil +end + +-------------------------------------------------- + +--- Create a dir if it does not exist +function M.may_create_dir(dir) + local res = fn.isdirectory(dir) + + if res == 0 then + fn.mkdir(dir, 'p') + end +end + +-------------------------------------------------- + +--- Toggle cmp completion +vim.g.cmp_toggle_flag = false -- initialize +local normal_buftype = function() + return vim.api.nvim_buf_get_option(0, 'buftype') ~= 'prompt' +end +M.toggle_completion = function() + local ok, cmp = pcall(require, 'cmp') + if ok then + local next_cmp_toggle_flag = not vim.g.cmp_toggle_flag + if next_cmp_toggle_flag then + print('completion on') + else + print('completion off') + end + cmp.setup({ + enabled = function() + vim.g.cmp_toggle_flag = next_cmp_toggle_flag + if next_cmp_toggle_flag then + return normal_buftype + else + return next_cmp_toggle_flag + end + end, + }) + else + print('completion not available') + end +end + +-------------------------------------------------- + +--- Make sure using latest neovim version +function M.get_nvim_version() + local actual_ver = vim.version() + + local nvim_ver_str = string.format('%d.%d.%d', actual_ver.major, actual_ver.minor, actual_ver.patch) + return nvim_ver_str +end + +function M.add_pack(name) + local status, error = pcall(vim.cmd, 'packadd ' .. name) + + return status +end + +-------------------------------------------------- + +-- Define a global function to retrieve LSP clients based on Neovim version +function M.get_lsp_clients(bufnr) + local mods = require('user.mods') + --local expected_ver = '0.10.0' + local nvim_ver = mods.get_nvim_version() + + local version_major, version_minor = string.match(nvim_ver, '(%d+)%.(%d+)') + version_major = tonumber(version_major) + version_minor = tonumber(version_minor) + + if version_major > 0 or (version_major == 0 and version_minor >= 10) then + return vim.lsp.get_clients({ buffer = bufnr }) + else + return vim.lsp.buf_get_clients() + end +end + +-------------------------------------------------- + +--- Toggle autopairs on/off (requires "windwp/nvim-autopairs") +function M.Toggle_autopairs() + local ok, autopairs = pcall(require, 'nvim-autopairs') + if ok then + if autopairs.state.disabled then + autopairs.enable() + print('autopairs on') + else + autopairs.disable() + print('autopairs off') + end + else + print('autopairs not available') + end +end + +-------------------------------------------------- + +--- Make vim-rooter message disappear after making it's changes +--vim.cmd([[ +--let timer = timer_start(1000, 'LogTrigger', {}) +--func! LogTrigger(timer) +-- silent! +--endfunc +--]]) +-- +--vim.cmd([[ +--function! ConfigureChDir() +-- echo ('') +--endfunction +--" Call after vim-rooter changes the root dir +--autocmd User RooterChDir :sleep! | call LogTrigger(timer) | call ConfigureChDir() +--]]) + +function M.findFilesInCwd() + vim.cmd('let g:rooter_manual_only = 1') -- Toggle the rooter plugin + require('plugins.telescope').findhere() + vim.defer_fn(function() + vim.cmd('let g:rooter_manual_only = 0') -- Change back to automatic rooter + end, 100) +end + +--function M.findFilesInCwd() +-- vim.cmd("let g:rooter_manual_only = 1") -- Toggle the rooter plugin +-- require("plugins.telescope").findhere() +-- --vim.cmd("let g:rooter_manual_only = 0") -- Change back to automatic rooter +--end + +-------------------------------------------------- + +-- Toggle the executable permission +function M.Toggle_executable() + local current_file = vim.fn.expand('%:p') + local executable = vim.fn.executable(current_file) == 1 + + if executable then + -- File is executable, unset the executable permission + vim.fn.system('chmod -x ' .. current_file) + --print(current_file .. ' is no longer executable.') + print('No longer executable') + else + -- File is not executable, set the executable permission + vim.fn.system('chmod +x ' .. current_file) + --print(current_file .. ' is now executable.') + print('Now executable') + end +end + +-------------------------------------------------- + +-- Set bare dotfiles repository git environment variables dynamically + +-- Set git enviornment variables +--function M.Set_git_env_vars() +-- local git_dir_job = vim.fn.jobstart({ "git", "rev-parse", "--git-dir" }) +-- local command_status = vim.fn.jobwait({ git_dir_job })[1] +-- if command_status > 0 then +-- vim.env.GIT_DIR = vim.fn.expand("$HOME/.cfg") +-- vim.env.GIT_WORK_TREE = vim.fn.expand("~") +-- else +-- vim.env.GIT_DIR = nil +-- vim.env.GIT_WORK_TREE = nil +-- end +-- -- Launch terminal emulator with Git environment variables set +-- --require("toggleterm").exec(string.format([[%s %s]], os.getenv("SHELL"), "-i")) +--end + +------ + +local prev_cwd = '' + +function M.Set_git_env_vars() + local cwd = vim.fn.getcwd() + if prev_cwd == '' then + -- First buffer being opened, set prev_cwd to cwd + prev_cwd = cwd + elseif cwd ~= prev_cwd then + -- Working directory has changed since last buffer was opened + prev_cwd = cwd + local git_dir_job = vim.fn.jobstart({ 'git', 'rev-parse', '--git-dir' }) + local command_status = vim.fn.jobwait({ git_dir_job })[1] + if command_status > 0 then + vim.env.GIT_DIR = vim.fn.expand('$HOME/.cfg') + vim.env.GIT_WORK_TREE = vim.fn.expand('~') + else + vim.env.GIT_DIR = nil + vim.env.GIT_WORK_TREE = nil + end + end +end + +vim.cmd([[augroup my_git_env_vars]]) +vim.cmd([[ autocmd!]]) +vim.cmd([[ autocmd BufEnter * lua require('user.mods').Set_git_env_vars()]]) +vim.cmd([[ autocmd VimEnter * lua require('user.mods').Set_git_env_vars()]]) +vim.cmd([[augroup END]]) + +-------------------------------------------------- + +--- Update Tmux Status Vi-mode +function M.update_tmux_status() + local mode = vim.api.nvim_eval('mode()') + -- Determine the mode name based on the mode value + local mode_name + if mode == 'n' then + mode_name = '-- NORMAL --' + elseif mode == 'i' or mode == 'ic' then + mode_name = '-- INSERT --' + else + mode_name = '-- NORMAL --' --'-- COMMAND --' + end + + -- Write the mode name to the file + local file = io.open(os.getenv('HOME') .. '/.vi-mode', 'w') + file:write(mode_name) + file:close() + if nvim_running then + -- Neovim is running, update the mode file and refresh tmux + VI_MODE = '' -- Clear VI_MODE to show Neovim mode + vim.cmd('silent !tmux refresh-client -S') + end + ---- Force tmux to update the status + vim.cmd('silent !tmux refresh-client -S') +end + +vim.cmd([[ + augroup TmuxStatus + autocmd! + autocmd InsertLeave,InsertEnter * lua require("user.mods").update_tmux_status() + autocmd VimEnter * lua require("user.mods").update_tmux_status() + autocmd BufEnter * lua require("user.mods").update_tmux_status() + autocmd ModeChanged * lua require("user.mods").update_tmux_status() + autocmd WinEnter,WinLeave * lua require("user.mods").update_tmux_status() + augroup END +]]) + +-- Add autocmd for <esc> +-- Add autocmd to check when tmux switches panes/windows +--autocmd InsertLeave,InsertEnter * lua require("user.mods").update_tmux_status() +--autocmd BufEnter * lua require("user.mods").update_tmux_status() +--autocmd WinEnter,WinLeave * lua require("user.mods").update_tmux_status() + +--autocmd WinEnter,WinLeave * lua require("user.mods").update_tmux_status() +--autocmd VimResized * lua require("user.mods").update_tmux_status() +--autocmd FocusGained * lua require("user.mods").update_tmux_status() +--autocmd FocusLost * lua require("user.mods").update_tmux_status() +--autocmd CmdwinEnter,CmdwinLeave * lua require("user.mods").update_tmux_status() + +-------------------------------------------------- + +-- function OpenEmulatorList() +-- local emulatorsBuffer = vim.api.nvim_create_buf(false, true) +-- vim.api.nvim_buf_set_lines(emulatorsBuffer, 0, 0, true, {"Some text"}) +-- vim.api.nvim_open_win( +-- emulatorsBuffer, +-- false, +-- { +-- relative='win', row=3, col=3, width=12, height=3 +-- } +-- ) +-- end +-- +-- vim.api.nvim_create_user_command('OpenEmulators', OpenEmulatorList, {}) + +--local api = vim.api +--local fn = vim.fn +--local cmd = vim.cmd +-- +--local function bufremove(opts) +-- local target_buf_id = api.nvim_get_current_buf() +-- +-- -- Do nothing if buffer is in modified state. +-- if not opts.force and api.nvim_buf_get_option(target_buf_id, 'modified') then +-- return false +-- end +-- +-- -- Hide target buffer from all windows. +-- vim.tbl_map(function(win_id) +-- win_id = win_id or 0 +-- +-- local current_buf_id = api.nvim_win_get_buf(win_id) +-- +-- api.nvim_win_call(win_id, function() +-- -- Try using alternate buffer +-- local alt_buf_id = fn.bufnr('#') +-- if alt_buf_id ~= current_buf_id and fn.buflisted(alt_buf_id) == 1 then +-- api.nvim_win_set_buf(win_id, alt_buf_id) +-- return +-- end +-- +-- -- Try using previous buffer +-- cmd('bprevious') +-- if current_buf_id ~= api.nvim_win_get_buf(win_id) then +-- return +-- end +-- +-- -- Create new listed scratch buffer +-- local new_buf = api.nvim_create_buf(true, true) +-- api.nvim_win_set_buf(win_id, new_buf) +-- end) +-- +-- return true +-- end, fn.win_findbuf(target_buf_id)) +-- +-- cmd(string.format('bdelete%s %d', opts.force and '!' or '', target_buf_id)) +--end +-- +---- Assign bufremove to a global variable +--_G.bufremove = bufremove + +--vim.cmd([[ +-- augroup NvimTreeDelete +-- autocmd! +-- autocmd FileType NvimTree lua require('user.mods').enew_on_delete() +-- augroup END +--]]) +-- +--function M.enew_on_delete() +-- if vim.bo.buftype == 'nofile' then +-- vim.cmd('enew') +-- end +--end + +-- Update Neovim +--function M.Update_neovim() +-- -- Run the commands to download and extract the latest version +-- os.execute("curl -L -o nvim-linux64.tar.gz https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz") +-- os.execute("tar xzvf nvim-linux64.tar.gz") +-- -- Replace the existing Neovim installation with the new version +-- os.execute("rm -rf $HOME/.local/bin/nvim") +-- os.execute("mv nvim-linux64 $HOME/.local/bin/nvim") +-- +-- -- Clean up the downloaded file +-- os.execute("rm nvim-linux64.tar.gz") +-- +-- -- Print a message to indicate the update is complete +-- print("Neovim has been updated to the latest version.") +--end +-- +---- Bind a keymap to the update_neovim function (optional) +--vim.api.nvim_set_keymap('n', '<leader>u', '<cmd> lua require("user.mods").Update_neovim()<CR>', { noremap = true, silent = true }) + +-- Define a function to create a floating window and run the update process inside it +function M.Update_neovim() + -- Create a new floating window + local bufnr, winid = vim.api.nvim_create_buf(false, true) + vim.api.nvim_open_win(bufnr, true, { + relative = 'editor', + width = 80, + height = 20, + row = 2, + col = 2, + style = 'minimal', + border = 'single', + }) + + -- Function to append a line to the buffer in the floating window + local function append_line(line) + vim.api.nvim_buf_set_option(bufnr, 'modifiable', true) + vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { line }) + vim.api.nvim_buf_set_option(bufnr, 'modifiable', false) + end + + -- Download the latest version of Neovim + append_line('Downloading the latest version of Neovim...') + os.execute('curl -L -o nvim-linux64.tar.gz https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz') + append_line('Download complete.') + + -- Extract the downloaded archive + append_line('Extracting the downloaded archive...') + os.execute('tar xzvf nvim-linux64.tar.gz') + append_line('Extraction complete.') + + -- Replace the existing Neovim installation with the new version + append_line('Replacing the existing Neovim installation...') + os.execute('rm -rf $HOME/nvim') + os.execute('mv nvim-linux64 $HOME/nvim') + append_line('Update complete.') + + -- Clean up the downloaded file + append_line('Cleaning up the downloaded file...') + os.execute('rm nvim-linux64.tar.gz') + append_line('Cleanup complete.') + + -- Close the floating window after a delay + vim.defer_fn(function() + vim.api.nvim_win_close(winid, true) + end, 5000) -- Adjust the delay as needed +end + +-- Bind a keymap to the update_neovim function (optional) +vim.api.nvim_set_keymap('n', '<leader>U', '<cmd> lua require("user.mods").Update_neovim()<CR>', { noremap = true, silent = true }) + +-------------------------------------------------- + +-- Fix or suppress closing nvim error message (/src/unix/core.c:147: uv_close: Assertion `!uv__is_closing(handle)' failed.) +vim.api.nvim_create_autocmd({ 'VimLeave' }, { + callback = function() + vim.fn.jobstart('!notify-send 2>/dev/null &', { detach = true }) + end, +}) + +-------------------------------------------------- + +-- Rooter +--vim.cmd([[autocmd BufEnter * lua vim.cmd('Rooter')]]) + +-------------------------------------------------- + +-- Nvim-tree +local modifiedBufs = function(bufs) -- nvim-tree is also there in modified buffers so this function filter it out + local t = 0 + for k, v in pairs(bufs) do + if v.name:match('NvimTree_') == nil then + t = t + 1 + end + end + return t +end + +-- Deleting current file opened behaviour +function M.DeleteCurrentBuffer() + local cbn = vim.api.nvim_get_current_buf() + local buffers = vim.fn.getbufinfo({ buflisted = true }) + local size = #buffers + local idx = 0 + + for n, e in ipairs(buffers) do + if e.bufnr == cbn then + idx = n + break -- Exit loop as soon as we find the buffer + end + end + + if idx == 0 then + return + end + + if idx == size then + vim.cmd('bprevious') + else + vim.cmd('bnext') + end + + vim.cmd('silent! bdelete ' .. cbn) + + -- Open a new blank window + vim.cmd('silent! enew') -- Opens a new vertical split + -- OR + -- vim.cmd("new") -- Opens a new horizontal split + -- Delay before opening a new split + --vim.defer_fn(function() + -- vim.cmd("enew") -- Opens a new vertical split + --end, 100) -- Adjust the delay as needed (in milliseconds) + -- Delay before closing the nvim-tree window +end + +vim.cmd([[autocmd FileType NvimTree lua require("user.mods").DeleteCurrentBuffer()]]) + +-- On :bd nvim-tree should behave as if it wasn't opened +vim.api.nvim_create_autocmd('BufEnter', { + nested = true, + callback = function() + -- Only 1 window with nvim-tree left: we probably closed a file buffer + if #vim.api.nvim_list_wins() == 1 and require('nvim-tree.utils').is_nvim_tree_buf() then + local api = require('nvim-tree.api') + -- Required to let the close event complete. An error is thrown without this. + vim.defer_fn(function() + -- close nvim-tree: will go to the last buffer used before closing + api.tree.toggle({ find_file = true, focus = true }) + -- re-open nivm-tree + api.tree.toggle({ find_file = true, focus = true }) + -- nvim-tree is still the active window. Go to the previous window. + vim.cmd('wincmd p') + end, 0) + end + end, +}) + +-- Dismiss notifications when opening nvim-tree window +local function isNvimTreeOpen() + local win = vim.fn.win_findbuf(vim.fn.bufnr('NvimTree')) + return vim.fn.empty(win) == 0 +end + +function M.DisableNotify() + if isNvimTreeOpen() then + require('notify').dismiss() + end +end + +vim.cmd([[ + autocmd! WinEnter,WinLeave * lua require('user.mods').DisableNotify() +]]) + +-------------------------------------------------- + +-- Toggle Dashboard +function M.toggle_dashboard() + if vim.bo.filetype == 'dashboard' then + vim.cmd('bdelete') + else + vim.cmd('Dashboard') + end +end + +-------------------------------------------------- + +-- Helper function to suppress errors +local function silent_execute(cmd) + vim.fn['serverlist']() -- Required to prevent 'Press ENTER' prompt + local result = vim.fn.system(cmd .. ' 2>/dev/null') + vim.fn['serverlist']() + return result +end + +-------------------------------------------------- + +-- Toggle Codi +-- Define a global variable to track Codi's state +local is_codi_open = false + +function M.toggleCodi() + if is_codi_open then + -- Close Codi + vim.cmd('Codi!') + is_codi_open = false + print('Codi off') + else + -- Open Codi + vim.cmd('Codi') + is_codi_open = true + print('Codi on') + end +end + +-------------------------------------------------- + +---- Function to create or toggle a scratch buffer +local scratch_buf = nil -- Store the scratch buffer globally +local scratch_win = nil -- Store the scratch window globally +local scratch_date = os.date('%Y-%m-%d') +local scratch_dir = vim.fn.expand('~/notes/private') +local scratch_file = 'scratch-' .. scratch_date .. '.md' + +function M.Scratch(Split_direction) + -- Check if the directory exists, and create it if it doesn't + if vim.fn.isdirectory(scratch_dir) == 0 then + vim.fn.mkdir(scratch_dir, 'p') + end + + -- Determine the window type based on Split_direction + local current_window_type = 'float' + if Split_direction == 'float' then + current_window_type = 'float' + elseif Split_direction == 'vertical' then + current_window_type = 'vertical' + elseif Split_direction == 'horizontal' then + current_window_type = 'horizontal' + end + + local file_path = scratch_dir .. '/' .. scratch_file + + if scratch_win and vim.api.nvim_win_is_valid(scratch_win) then + -- Window exists, save buffer to file and close it + WriteScratchBufferToFile(scratch_buf, file_path) + vim.cmd(':w!') + vim.api.nvim_win_close(scratch_win, true) + scratch_win = nil + else + if scratch_buf and vim.api.nvim_buf_is_valid(scratch_buf) then + -- Buffer exists, reuse it + OpenScratchWindow(scratch_buf, current_window_type) + else + -- Buffer doesn't exist, create it and load the file if it exists + scratch_buf = OpenScratchBuffer(file_path) + OpenScratchWindow(scratch_buf, current_window_type) + end + end +end + +function WriteScratchBufferToFile(buf, file_path) + local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) + local content = table.concat(lines, '\n') + local escaped_file_path = vim.fn.fnameescape(file_path) + + -- Write the buffer content to the file + local file = io.open(escaped_file_path, 'w') + if file then + file:write(content) + file:close() + end +end + +function OpenScratchBuffer(file_path) + local buf = vim.api.nvim_create_buf(true, false) + + -- Set the file name for the buffer + local escaped_file_path = vim.fn.fnameescape(file_path) + vim.api.nvim_buf_set_name(buf, escaped_file_path) + + -- Check if the file exists and load it if it does + if vim.fn.filereadable(file_path) == 1 then + local file_contents = vim.fn.readfile(file_path) + vim.api.nvim_buf_set_lines(buf, 0, -1, true, file_contents) + else + -- Insert initial content + vim.api.nvim_buf_set_lines(buf, 0, -1, true, { + '# Quick Notes - ' .. scratch_date, + '--------------------------', + '', + }) + + -- Save the initial content to the file + vim.cmd(':w') + end + + return buf +end + +function OpenScratchWindow(buf, current_window_type) + if current_window_type == 'float' then + local opts = { + relative = 'win', + width = 120, + height = 10, + border = 'single', + row = 20, + col = 20, + } + scratch_win = vim.api.nvim_open_win(buf, true, opts) + -- Go to the last line of the buffer + vim.api.nvim_win_set_cursor(0, { vim.api.nvim_buf_line_count(buf), 1 }) + elseif current_window_type == 'vertical' then + vim.cmd('vsplit') + vim.api.nvim_win_set_buf(0, buf) + scratch_win = 0 + elseif current_window_type == 'horizontal' then + vim.cmd('split') + vim.api.nvim_win_set_buf(0, buf) + scratch_win = 0 + end +end + +-------------------------------------------------- + +-- Intercept file open +local augroup = vim.api.nvim_create_augroup('user-autocmds', { clear = true }) +local intercept_file_open = true +vim.api.nvim_create_user_command('InterceptToggle', function() + intercept_file_open = not intercept_file_open + local intercept_state = '`Enabled`' + if not intercept_file_open then + intercept_state = '`Disabled`' + end + vim.notify('Intercept file open set to ' .. intercept_state, vim.log.levels.INFO, { + title = 'Intercept File Open', + ---@param win integer The window handle + on_open = function(win) + vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), 'filetype', 'markdown') + end, + }) +end, { desc = 'Toggles intercepting BufNew to open files in custom programs' }) + +-- NOTE: Add "BufReadPre" to the autocmd events to also intercept files given on the command line, e.g. +-- `nvim myfile.txt` +vim.api.nvim_create_autocmd({ 'BufNew' }, { + group = augroup, + callback = function(args) + ---@type string + local path = args.match + ---@type integer + local bufnr = args.buf + + ---@type string? The file extension if detected + local extension = vim.fn.fnamemodify(path, ':e') + ---@type string? The filename if detected + local filename = vim.fn.fnamemodify(path, ':t') + + ---Open a given file path in a given program and remove the buffer for the file. + ---@param buf integer The buffer handle for the opening buffer + ---@param fpath string The file path given to the program + ---@param fname string The file name used in notifications + ---@param prog string The program to execute against the file path + local function open_in_prog(buf, fpath, fname, prog) + vim.notify(string.format('Opening `%s` in `%s`', fname, prog), vim.log.levels.INFO, { + title = 'Open File in External Program', + ---@param win integer The window handle + on_open = function(win) + vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), 'filetype', 'markdown') + end, + }) + local mods = require('user.mods') + local nvim_ver = mods.get_nvim_version() + + local version_major, version_minor = string.match(nvim_ver, '(%d+)%.(%d+)') + version_major = tonumber(version_major) + version_minor = tonumber(version_minor) + + if version_major > 0 or (version_major == 0 and version_minor >= 10) then + vim.system({ prog, fpath }, { detach = true }) + else + vim.fn.jobstart({ prog, fpath }, { detach = true }) + end + vim.api.nvim_buf_delete(buf, { force = true }) + end + + local extension_callbacks = { + ['pdf'] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, 'zathura') + end, + ['png'] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, 'feh') + end, + ['jpg'] = 'png', + ['mp4'] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, 'mpv') + end, + ['gif'] = 'mp4', + } + + ---Get the extension callback for a given extension. Will do a recursive lookup if an extension callback is actually + ---of type string to get the correct extension + ---@param ext string A file extension. Example: `png`. + ---@return fun(bufnr: integer, path: string, filename: string?) extension_callback The extension callback to invoke, expects a buffer handle, file path, and filename. + local function extension_lookup(ext) + local callback = extension_callbacks[ext] + if type(callback) == 'string' then + callback = extension_lookup(callback) + end + return callback + end + + if extension ~= nil and not extension:match('^%s*$') and intercept_file_open then + local callback = extension_lookup(extension) + if type(callback) == 'function' then + callback(bufnr, path, filename) + end + end + end, +}) + +-------------------------------------------------- + +-- ... +return M diff --git a/.config/nvim/lua/user/opts.lua b/.config/nvim/lua/user/opts.lua new file mode 100644 index 0000000..cc8debc --- /dev/null +++ b/.config/nvim/lua/user/opts.lua @@ -0,0 +1,351 @@ +--[[ opts.lua ]] + +-- Environment +--vim.opt.shell = "zsh" -- +vim.o.updatetime = 250 +vim.o.shell = '/bin/zsh' +vim.scriptencoding = 'utf-8' -- +vim.opt.encoding = 'utf-8' -- +vim.opt.fileencoding = 'utf-8' -- +vim.g.python3_host_prog = '/usr/bin/python3' -- +vim.g.loaded_python3_provider = 1 -- +vim.g.sh_noisk = 1 -- iskeyword word boundaries when editing a 'sh' file +vim.o.autochdir = true +--vim.o.writeany= true + +-- Clipboard +vim.opt.clipboard:append({ 'unnamedplus' }) -- Install xclip or this will slowdown startup + +-- Behaviour +vim.opt.backspace = { 'start', 'eol', 'indent' } -- Make backspace work as you would expect. +vim.opt.hidden = true -- Switch between buffers without having to save first. +vim.opt.splitbelow = true -- make split put the new buffer below the current buffer +vim.opt.splitright = true -- make vsplit put the new buffer on the right of the current buffer +vim.opt.scrolloff = 8 -- +vim.opt.sidescrolloff = 8 -- how many lines to scroll when using the scrollbar +vim.opt.autoread = true -- reload files if changed externally +vim.opt.display = 'lastline' -- Show as much as possible of the last line. +vim.opt.inccommand = 'split' -- +vim.opt.ttyfast = true -- Faster redrawing. +vim.opt.lazyredraw = false -- Only redraw when necessary +vim.opt.keywordprg = ':help' -- :help options +vim.opt.ruler = true -- +vim.opt.errorbells = false -- +vim.opt.list = true -- Show non-printable characters. +vim.opt.showmatch = true -- +vim.opt.matchtime = 3 -- +vim.opt.showbreak = '↪ ' -- +vim.opt.linebreak = true -- +vim.opt.exrc = true -- +--vim.opt.autochdir = true -- or use this to use <:e> to create a file in current directory +vim.opt.autoread = true -- if a file is changed outside of vim, automatically reload it without asking +--vim.opt.notimeout = true -- Timeout on keycodes and not mappings +vim.opt.ttimeout = true -- Makes terminal vim work sanely +vim.opt.ttimeoutlen = 10 -- +--vim.opt.timeoutlen = 100 -- time to wait for a mapped sequence to complete (in milliseconds) +--vim.cmd([[set diffopt = vertical = true]]) -- diffs are shown side-by-side not above/below + +-- Indent/tab +vim.opt.breakindent = true -- +vim.opt.autoindent = true -- Indent according to previous line. +vim.opt.copyindent = true -- Copy indent from the previous line +vim.opt.smarttab = false -- +vim.opt.tabstop = 2 -- +vim.opt.expandtab = true -- Indent according to previous line. +--vim.opt.expandtab = true -- Use spaces instead of tabs. +vim.opt.softtabstop = 2 -- Tab key indents by 2 spaces. +vim.opt.shiftwidth = 2 -- >> indents by 2 spaces. +vim.opt.shiftround = true -- >> indents to next multiple of 'shiftwidth'. +vim.opt.smartindent = true -- smart indent + +-- Column/statusline/Cl +vim.opt.number = true -- +vim.opt.title = true -- +--vim.opt.colorcolumn = "+1" -- +vim.opt.signcolumn = 'yes:1' -- always show the sign column +--vim.opt.signcolumn = "yes:" .. vim.o.numberwidth +--vim.opt.signcolumn = "number" +--vim.opt.signcolumn = "no" -- +vim.opt.laststatus = 3 -- " Always show statusline. +vim.opt.showmode = true -- Show current mode in command-line, example: -- INSERT -- mode +vim.opt.showcmd = true -- Show the command in the status bar +vim.opt.cmdheight = 1 -- +--vim.opt.cmdheight = 0 -- +vim.opt.report = 0 -- Always report changed lines. +--local autocmd = vim.api.nvim_create_autocmd +--autocmd("bufenter", { +-- pattern = "*", +-- callback = function() +-- if vim.bo.ft ~= "terminal" then +-- vim.opt.statusline = "%!v:lua.require'ui.statusline'.run()" +-- else +-- vim.opt.statusline = "%#normal# " +-- end +-- end, +--}) +---- With vertical splits, the statusline would still show up at the +---- bottom of the split. A quick fix is to just set the statusline +---- to empty whitespace (it can't be an empty string because then +---- it'll get replaced by the default stline). +--vim.opt.stl = " " + +-- Backup/undo/swap +local prefix = vim.env.XDG_CONFIG_HOME or vim.fn.expand('~/.config') +--vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undodir = { prefix .. '/nvim/tmp/.undo//' } +vim.opt.directory = { prefix .. '/nvim/tmp/.swp//' } +vim.opt.backupdir = { prefix .. '/nvim/tmp/.backup//' } +vim.opt.undofile = true -- +vim.opt.swapfile = true -- +vim.opt.backup = true -- +--vim.opt.backupcopy = +-- Add timestamp as extension for backup files +vim.api.nvim_create_autocmd('BufWritePre', { + group = vim.api.nvim_create_augroup('timestamp_backupext', { clear = true }), + desc = 'Add timestamp to backup extension', + pattern = '*', + callback = function() + vim.opt.backupext = '-' .. vim.fn.strftime('%Y%m%d%H%M') + end, +}) + +-- Format +--vim.opt.textwidth = 80 -- +vim.opt.isfname:append('@-@') +vim.cmd([[let &t_Cs = "\e[4:3m"]]) -- Undercurl +vim.cmd([[let &t_Ce = "\e[4:0m"]]) -- +vim.opt.path:append({ '**' }) -- Finding files - Search down into subfolder +vim.cmd('set whichwrap+=<,>,[,],h,l') -- +vim.cmd([[set iskeyword+=-]]) -- +--vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work +vim.opt.formatoptions = vim.opt.formatoptions + - 't' -- wrap with text width + + 'c' -- wrap comments + + 'r' -- insert comment after enter + - 'o' -- insert comment after o/O + - 'q' -- allow formatting of comments with gq + - 'a' -- format paragraphs + + 'n' -- recognized numbered lists + - '2' -- use indent of second line for paragraph + + 'l' -- long lines are not broken + + 'j' -- remove comment when joining lines +vim.opt.wrapscan = true -- " Searches wrap around end-of-file. +--vim.wo.number = true -- +--vim.opt.wrap = false -- No Wrap lines +--vim.opt.foldmethod = 'manual' -- +--vim.opt.foldmethod = "expr" -- +vim.opt.foldmethod = 'manual' +vim.opt.foldlevel = 3 +vim.opt.confirm = false +--vim.opt.shortmess:append("sI") +--vim.opt.shortmess = "a" +--vim.opt.shortmess = "sI" +--vim.o.shortmess = vim.o.shortmess:gsub('s', '') +vim.opt.shortmess = table.concat({ -- Use abbreviations and short messages in command menu line. + 'f', -- Use "(3 of 5)" instead of "(file 3 of 5)". + 'i', -- Use "[noeol]" instead of "[Incomplete last line]". + 'l', -- Use "999L, 888C" instead of "999 lines, 888 characters". + 'm', -- Use "[+]" instead of "[Modified]". + 'n', -- Use "[New]" instead of "[New File]". + 'r', -- Use "[RO]" instead of "[readonly]". + 'w', -- Use "[w]", "[a]" instead of "written", "appended". + 'x', -- Use "[dos]", "[unix]", "[mac]" instead of "[dos format]", "[unix format]", "[mac format]". + 'o', -- Overwrite message for writing a file with subsequent message. + 'O', -- Message for reading a file overwrites any previous message. + 's', -- Disable "search hit BOTTOM, continuing at TOP" such messages. + 't', -- Truncate file message at the start if it is too long. + 'T', -- Truncate other messages in the middle if they are too long. + 'I', -- Don't give the :intro message when starting. + 'c', -- Don't give ins-completion-menu messages. + 'F', -- Don't give the file info when editing a file. +}) +vim.opt.fillchars = { + horiz = '─', + horizup = '┴', + horizdown = '┬', + vert = '│', + vertleft = '┤', + vertright = '├', + verthoriz = '┼', + foldopen = '', + foldsep = '│', + foldclose = '', + fold = '─', + eob = ' ', + --diff = "┃", + diff = '░', + msgsep = '━', + --msgsep = "‾", +} +vim.opt.listchars = { tab = '▸ ', trail = '·' } -- +--vim.opt.fillchars:append({ eob = " " }) -- remove the ~ from end of buffer +vim.opt.modeline = true -- +vim.opt.modelines = 3 -- modelines (comments that set vim options on a per-file basis) +--vim.opt.modelineexpr = true +--vim.opt.nofoldenable = true -- turn folding off +--vim.opt.foldenable = false -- turn folding off +vim.o.showtabline = 2 + +-- Highlights +vim.opt.incsearch = true -- Highlight while searching with / or ?. +vim.opt.hlsearch = true -- Keep matches highlighted. +vim.opt.ignorecase = true -- ignore case in search patterns UNLESS /C or capital in search +vim.opt.smartcase = true -- smart case +vim.opt.synmaxcol = 200 -- Only highlight the first 200 columns. +--vim.opt.winblend = 30 +--vim.opt.winblend = 5 +vim.opt.wildoptions = 'pum' -- +--vim.opt.pumblend = 5 -- +vim.opt.pumblend = 12 -- +--vim.opt.pumblend=15 +vim.opt.pumheight = 10 -- pop up menu height + +-- Better Completion +vim.opt.complete = { '.', 'w', 'b', 'u', 't' } -- +--vim.opt.completeopt = { "longest,menuone,preview" } -- +vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } +--vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp +--vim.opt.completeopt = { "menu", "menuone", "noselect" } -- + +-- Wildmenu completion -- +vim.opt.wildmenu = true -- +vim.opt.wildmode = { 'list:longest' } -- +vim.opt.wildignore:append({ '.hg', '.git', '.svn' }) -- Version control +vim.opt.wildignore:append({ '*.aux', '*.out', '*.toc' }) -- LaTeX intermediate files +vim.opt.wildignore:append({ '*.jpg', '*.bmp', '*.gif', '*.png', '*.jpeg' }) -- binary images +vim.opt.wildignore:append({ '*.o', '*.obj', '*.exe', '*.dll', '*.manifest' }) -- compiled object files +vim.opt.wildignore:append({ '*.spl' }) -- compiled spelling word lists +vim.opt.wildignore:append({ '*.sw?' }) -- Vim swap files +vim.opt.wildignore:append({ '*.DS_Store' }) -- OSX bullshit +vim.opt.wildignore:append({ '*.luac' }) -- Lua byte code +vim.opt.wildignore:append({ 'migrations' }) -- Django migrations +vim.opt.wildignore:append({ '*.pyc' }) -- Python byte code +vim.opt.wildignore:append({ '*.orig' }) -- Merge resolution files +vim.opt.wildignore:append({ '*/node_modules/*' }) -- + +-- Shada +vim.opt.shada = "!,'1000,f1,<1000,s100,:1000,/1000,h" + +-- Sessions +vim.opt.sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal' +--vim.opt.sessionoptions = "curdir,folds,help,options,tabpages,winsize,winpos,terminal,globals" -- +--vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" +--vim.opt.sessionoptions:remove({ "blank", "buffers", "globals" }) + +-- Netrw file tree +vim.g.netrw_browse_split = 0 +vim.g.netrw_banner = 0 +vim.g.netrw_winsize = 25 + +-- " Load indent files, to automatically do language-dependent indenting. +--vim.cmd([[ +-- "filetype plugin indent on +--]]) +vim.cmd('filetype plugin on') +vim.cmd('filetype indent off') + +-- Let clipboard register be + +vim.cmd([[ + let g:clipbrdDefaultReg = '+' +]]) + +--vim.cmd([[ +-- "autocmd BufEnter * :syntax sync fromstart +-- "syntax enable +-- "set nocompatible +-- "autocmd FileType lua set comments=s1:---,m:--,ex:-- +--]]) + +-- Fast macros without lazyredraw +vim.cmd([[ + set re=0 + nnoremap @ <cmd>execute "noautocmd norm! " . v:count1 . "@" . getcharstr()<cr> + xnoremap @ :<C-U>execute "noautocmd '<,'>norm! " . v:count1 . "@" . getcharstr()<cr> +]]) + +-- Stop annoying auto commenting on new lines +vim.cmd([[ + augroup annoying + au! + au BufEnter * set fo-=c fo-=r fo-=o + augroup end +]]) + +-- Cursorline +vim.cmd([[ " Only show cursorline in the current window and in normal mode + augroup cline + au! + au WinLeave,InsertEnter * set nocursorline + au WinEnter,InsertLeave * set cursorline + augroup END +]]) +vim.opt.cursorline = true -- +vim.opt.guicursor = 'i:ver100,r:hor100' -- + +-- Trailing whitespace +vim.cmd([[ " Only show in insert mode + augroup trailing + au! + au InsertEnter * :set listchars-=trail:⌴ + au InsertLeave * :set listchars+=trail:⌴ + augroup END +]]) + +-- Line Return +vim.cmd([[ " Return to the same line when we reopen a file + augroup line_return + au! + au BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute 'normal! g`"zvzz' | + \ endif + augroup END +]]) + +-- Enable mouse scrollback +vim.cmd([[ + set mouse=a + tnoremap <Esc> <C-\><C-n> + tnoremap <c-b> <c-\><c-n> + function! ClearTerminal() + set scrollback=1 + let &g:scrollback=1 + echo &scrollback + call feedkeys("\i") + call feedkeys("clear\<CR>") + call feedkeys("\<C-\>\<C-n>") + call feedkeys("\i") + sleep 100m + let &scrollback=s:scroll_value + endfunction +]]) + +-- Yank to clipboard in Termux +if vim.fn.has('termux') == 1 then + local Job = require('plenary.job') + vim.api.nvim_create_autocmd('TextYankPost', { + pattern = '*', + callback = function() + Job:new({ + command = 'termux-clipboard-set', + writer = vim.fn.getreg('@'), + }):start() + end, + }) +end + +function GetTermuxClipboard() + if vim.fn.has('termux') == 1 then + local sysclip = vim.fn.system('termux-clipboard-get') + if sysclip ~= '@' then + vim.fn.setreg('@', sysclip) + end + end + return '' +end + +if vim.fn.has('termux') == 1 then + vim.cmd('autocmd TextYankPost * call GetTermuxClipboard()') + vim.cmd('noremap <expr> p Paste("p")') + vim.cmd('noremap <expr> P Paste("P")') +end diff --git a/.config/nvim/lua/user/pack.lua b/.config/nvim/lua/user/pack.lua new file mode 100644 index 0000000..3cd66c0 --- /dev/null +++ b/.config/nvim/lua/user/pack.lua @@ -0,0 +1,389 @@ +local fn = vim.fn + +-------------------------------------------------- + +-- Automatically install packer +local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system({ + 'git', + 'clone', + '--depth', + '1', + 'https://github.com/wbthomason/packer.nvim', + install_path, + }) + print('Installing packer, please close and reopen Neovim...') + vim.cmd([[packadd packer.nvim]]) +end + +-------------------------------------------------- + +-- Autocommand that reloads neovim whenever you save this file +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost pack.lua source <afile> | PackerSync + augroup end +]]) + +-------------------------------------------------- + +-- Use a protected call so don't error out on first use +local status_ok, packer = pcall(require, 'packer') +if not status_ok then + return +end + +-------------------------------------------------- + +-- Have packer use a popup window and set a maximum number of jobs +packer.init({ + auto_reload_compiled = true, + --max_jobs = 90, + display = { + open_fn = function() + return require('packer.util').float({ border = 'rounded' }) + end, + }, +}) + +-------------------------------------------------- + +-- Install plugins here +return packer.startup(function(use) + -- Defaults + use('wbthomason/packer.nvim') -- Have packer manage itself (package manager) + use('nvim-lua/plenary.nvim') -- Useful lua functions used by lots of plugins + use('lewis6991/impatient.nvim') -- Faster loading/startup times + + -- Tree-sitter + use({ 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }) -- For language parsing, examples: highlighting, folding, jumping, refactoring... + use('nvim-treesitter/nvim-treesitter-refactor') -- Refactor module for nvim-treesitter + + -- lsp + use('williamboman/mason.nvim') -- Package manager to install and manage LSP servers, DAP servers, linters and formatters + use('neovim/nvim-lspconfig') -- Collection of LSP configs + use('williamboman/mason-lspconfig.nvim') -- Bridges mason.nvim with nvim-lspconfig to help use them together + use({ + 'https://git.sr.ht/~whynothugo/lsp_lines.nvim', + config = function() + require('lsp_lines').setup() + end, + }) + use('rmagatti/goto-preview') + + -- Debugger + use('mfussenegger/nvim-dap') -- Debug Adapter Protocol client implementation for Neovim + use('rcarriga/nvim-dap-ui') -- UI for nvim-dap + --use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } + use('theHamsta/nvim-dap-virtual-text') + use('gabrielpoca/replacer.nvim') + use('jayp0521/mason-nvim-dap.nvim') + --use({ + -- "jayp0521/mason-nvim-dap.nvim", + -- config = function() + -- require("mason-nvim-dap").setup({ + -- automatic_installation = true, + -- ensure_installed = { "python", "cppdbg", "codelldb" }, + -- }) + -- end, + --}) + + -- Linters/Formatters + use('mhartington/formatter.nvim') + use('jay-babu/mason-null-ls.nvim') + --use({"jayp0521/mason-null-ls.nvim", + -- config = function() + -- require('mason-null-ls.nvim').setup({ + -- automatic_setup = true, + -- }) + -- end + --}) + use({ + 'jose-elias-alvarez/null-ls.nvim', -- Provides LSP: linters, formatters, diagnostics, code actions and etc... + requires = { 'jay-babu/mason-null-ls.nvim' }, + }) + + -- Completion + use('hrsh7th/nvim-cmp') -- Completion engine plugin + use('hrsh7th/cmp-nvim-lsp') -- Completion source for nvim-lsp + use('hrsh7th/cmp-buffer') -- Completion source for content of current buffer + use('hrsh7th/cmp-path') -- Completion source for paths + use('hrsh7th/cmp-cmdline') -- Completion source for command-line + use('petertriho/cmp-git') -- Completion source for git + use('tamago324/cmp-zsh') -- Completion source for zsh + use('f3fora/cmp-spell') -- Completion source for spell-checking + use('hrsh7th/cmp-calc') -- Completion source for math calculation + use('saadparwaiz1/cmp_luasnip') -- Completion source for snippets, specifically for luasnip + use('hrsh7th/cmp-nvim-lsp-signature-help') -- Completion source for displaying function signatures with the current parameter emphasized + use('rcarriga/cmp-dap') + + -- Snippets + use('L3MON4D3/LuaSnip') -- Snippet engine + use('rafamadriz/friendly-snippets') -- Collection of snippets to use + + -- Git + use('tpope/vim-fugitive') -- + --use("dinhhuy258/git.nvim") -- For git blame & browse + use('kdheepak/lazygit.nvim') -- Terminal UI for git commands + use('lewis6991/gitsigns.nvim') -- Git decorations + + -- File explorer/fuzzy finder + use('kyazdani42/nvim-tree.lua') -- File explorer + use('ibhagwan/fzf-lua') -- Fuzzy finder + use('ThePrimeagen/harpoon') + --use("nvim-telescope/telescope.nvim") -- Fuzzy finder with lots of features/extendabilities + use({ + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + --config = function() + -- require('plugins.telescope').setup() + --end, + requires = { + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope-live-grep-args.nvim', + 'nvim-telescope/telescope-file-browser.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, + }, + }) + use({ 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }) -- Support fzf syntax/algorithm + use('nvim-telescope/telescope-ui-select.nvim') -- + use('nvim-telescope/telescope-project.nvim') -- + use('nvim-telescope/telescope-media-files.nvim') -- + use('nvim-telescope/telescope-file-browser.nvim') -- + use({ 'nvim-telescope/telescope-symbols.nvim', after = 'telescope.nvim' }) -- Search emoji(s) and other symbols + use('nvim-telescope/telescope-dap.nvim') + use('axkirillov/telescope-changed-files') -- + use('smartpde/telescope-recent-files') + use('rmagatti/auto-session') + use('rmagatti/session-lens') + + -- UX + use('folke/neodev.nvim') + use({ + 'numToStr/Navigator.nvim', -- Navigate between Tmux and Nvim + config = function() + require('Navigator').setup() + end, + }) + use({ 'tpope/vim-eunuch', cmd = { 'Rename', 'Delete', 'Mkdir' } }) -- Handy unix commands inside Vim (Rename, Move etc.) + --use("tpope/vim-surround") -- + --use("tpope/vim-obsession") -- + use('tpope/vim-unimpaired') -- + --use("vimpostor/vim-tpipeline") -- + --use("nathom/filetype.nvim") -- + use('mbbill/undotree') + use({ + 'myusuf3/numbers.vim', -- + vim.cmd("let g:numbers_exclude = ['dashboard']"), + }) + use('windwp/nvim-autopairs') -- + use('numToStr/Comment.nvim') -- + use('akinsho/toggleterm.nvim') -- + use('tweekmonster/startuptime.vim') -- + use('qpkorr/vim-bufkill') + use({ + 'ggandor/leap.nvim', -- + config = function() + require('leap').add_default_mappings() + --require("leap").set_default_keymaps() + --vim.keymap.set('n', '-', '<Plug>(leap-forward)', {}) + --vim.keymap.set('n', '_', '<Plug>(leap-backward)', {}) + end, + }) + use({ + 'ggandor/flit.nvim', -- + config = function() + require('flit').setup() + end, + }) + use('folke/which-key.nvim') -- + use('folke/zen-mode.nvim') -- + use('romainl/vim-cool') -- + use('antoinemadec/FixCursorHold.nvim') -- + use({ + 'folke/trouble.nvim', + requires = 'nvim-tree/nvim-web-devicons', + }) + use({ + 'airblade/vim-rooter', -- + --vim.cmd("let g:rooter_change_directory_for_non_project_files = ''"), + --vim.cmd("let g:rooter_change_directory_for_non_project_files = 'current'") + }) + use({ 'michaelb/sniprun', run = 'bash ./install.sh' }) + --use("vim-test/vim-test") -- + --use({ + -- "rcarriga/vim-ultest", -- + -- requires = { "vim-test/vim-test" }, + -- run = ":UpdateRemotePlugins", + -- config = function() + -- require("plugins.ultest") + -- end, + --}) + --use({"rcarriga/neotest", + -- config = function() + -- require("neotest").setup() + --end, + --}) + use({ + 'nvim-neotest/neotest', + requires = { + { + 'nvim-neotest/neotest-python', + 'nvim-neotest/neotest-plenary', + 'nvim-neotest/neotest-vim-test', + }, + }, + }) + use('kawre/leetcode.nvim') + use({ + 'm4xshen/hardtime.nvim', + config = function() + require('hardtime').setup() + end, + }) + use({ + 'luckasRanarison/nvim-devdocs', + config = function() + require('nvim-devdocs').setup() + end, + }) + + -- Colorschemes + use('bluz71/vim-nightfly-guicolors') + use('ayu-theme/ayu-vim') + use('joshdick/onedark.vim') + use('NTBBloodbath/doom-one.nvim') + use('nyngwang/nvimgelion') + use('projekt0n/github-nvim-theme') + use({ + 'folke/tokyonight.nvim', + config = function() + require('tokyonight').setup({ + transparent = true, + dim_inactive = false, + }) + end, + }) + + -- UI + use('kyazdani42/nvim-web-devicons') -- + use('onsails/lspkind-nvim') -- + use({ 'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async' }) -- Fold code + use({ + 'luukvbaal/statuscol.nvim', + config = function() + local builtin = require('statuscol.builtin') + require('statuscol').setup({ + relculright = true, + segments = { + { text = { builtin.foldfunc }, click = 'v:lua.ScFa' }, + { text = { '%s' }, click = 'v:lua.ScSa' }, + { text = { builtin.lnumfunc, ' ' }, click = 'v:lua.ScLa' }, + }, + }) + end, + }) + use({ + 'glepnir/dashboard-nvim', + --event = 'VimEnter', + requires = { 'nvim-tree/nvim-web-devicons' }, + }) + use('rcarriga/nvim-notify') -- Notification plugin + use('karb94/neoscroll.nvim') -- Faster/smooth scrolling + --use("MunifTanjim/prettier.nvim") -- Prettier plugin for Neovim's built-in LSP client + use({ + 'norcalli/nvim-colorizer.lua', -- colorize hexa and rgb strings + cmd = { 'ColorizerToggle', 'ColorizerAttachToBuffer' }, + config = function() + require('colorizer').setup({ + --'*'; + user_default_options = { + RGB = true, + RRGGBB = true, + names = false, + RRGGBBAA = false, + css = false, + css_fn = true, + mode = 'foreground', + }, + }) + end, + }) + use('MunifTanjim/nui.nvim') + use({ + 'j-hui/fidget.nvim', + tag = 'legacy', + }) -- UI to show nvim-lsp progress + use('metakirby5/codi.vim') + use({ + 'simrat39/symbols-outline.nvim', -- + config = function() + require('symbols-outline').setup({ + auto_close = true, + }) + end, + }) + use({ + 'kosayoda/nvim-lightbulb', -- + requires = 'antoinemadec/FixCursorHold.nvim', + }) + use({ + 'SmiteshP/nvim-navic', -- Statusline/Winbar component that uses LSP to show current code context + requires = 'neovim/nvim-lspconfig', + }) + use({ + 'rebelot/heirline.nvim', -- Statusline that is highly configurable + --requires = 'kyazdani42/nvim-web-devicons', + --event = 'VimEnter', + }) + + -- Language specific tools + use('simrat39/rust-tools.nvim') -- Rust tooling ecosystem + use({ + 'saecki/crates.nvim', -- + requires = { 'nvim-lua/plenary.nvim' }, + config = function() + require('crates').setup() + end, + }) + use({ + 'akinsho/flutter-tools.nvim', + requires = { + 'nvim-lua/plenary.nvim', + 'stevearc/dressing.nvim', -- optional for vim.ui.select + }, + config = function() + require('flutter-tools').setup({ + debugger = { + enabled = true, + run_via_dap = true, + }, + }) + end, + }) + use({ + 'iamcco/markdown-preview.nvim', -- Markdown Preview + run = function() + vim.fn['mkdp#util#install']() + end, + vim.cmd('let g:mkdp_auto_close = 0'), + }) + use({ + 'ellisonleao/glow.nvim', -- Markdown Preview + config = function() + require('glow').setup({ + style = 'dark', + }) + end, + }) + + -------------------------------------------------- + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require('packer').sync() + end +end) diff --git a/.config/nvim/lua/user/view.lua b/.config/nvim/lua/user/view.lua new file mode 100644 index 0000000..50cea8c --- /dev/null +++ b/.config/nvim/lua/user/view.lua @@ -0,0 +1,68 @@ +-- Colorscheme + +-- Colors +vim.opt.termguicolors = true + +-- Available colorschemes: +-- [[ nightfly ayu onedark doom-one nvimgelion github_dark tokyonight ]] + +require('tokyonight').setup({ + style = 'night', + transparent = true, + transparent_sidebar = true, + styles = { + sidebars = 'transparent', + floats = 'transparent', + }, +}) + +-- Define default color scheme +local default_colorscheme = 'tokyonight' +local fallback_colorscheme = 'desert' + +-- Attempt to set the default color scheme +local status_ok, _ = pcall(vim.cmd, 'colorscheme ' .. default_colorscheme) + +-- If the default color scheme is not found, use the fallback color scheme +if not status_ok then + vim.cmd('colorscheme ' .. fallback_colorscheme) +end + +vim.api.nvim_command('syntax on') +vim.api.nvim_command('highlight Normal guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NormalNC guibg=NONE') +vim.api.nvim_command('highlight NormalFloat guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight Float guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NonText guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight SignColumn guibg=NONE') +vim.api.nvim_command('highlight FoldColumn guibg=NONE') +vim.api.nvim_command('highlight CursorLineSign guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight Title guibg=NONE gui=bold') +vim.api.nvim_command('highlight TabLine guibg=#333842 gui=bold') +vim.api.nvim_command('highlight TabLineSel guibg=#333842 gui=bold') +vim.api.nvim_command('highlight TabLineFill guibg=NONE gui=bold') +vim.api.nvim_command('highlight WinBar guibg=NONE ctermbg=NONE gui=bold') +vim.api.nvim_command('highlight WinBarNC guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight LineNr guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight WinSeparator guibg=NONE gui=bold ctermbg=NONE') +vim.api.nvim_command('highlight MsgSeparator guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight EndOfBuffer guibg=NONE guifg=Normal') +vim.api.nvim_command('highlight Comment guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight Winblend guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NormalFloat guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight Pumblend guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight WildMenu guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight WarningMsg guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight Pmenu guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight PmenuSel guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight PmenuThumb guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight PmenuSbar guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight PmenuExtra guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight PmenuExtraSel guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight MoreMsg guibg=NONE ctermbg=NONE') + +-- Set different window separator colorscheme +vim.cmd([[ +au WinEnter * setl winhl=WinSeparator:WinSeparatorA +au WinLeave * setl winhl=WinSeparator:WinSeparator +]]) diff --git a/.config/nvim/snippets/boilerplate.lua b/.config/nvim/snippets/boilerplate.lua new file mode 100644 index 0000000..04e973a --- /dev/null +++ b/.config/nvim/snippets/boilerplate.lua @@ -0,0 +1,75 @@ +local ls = require("luasnip") --{{{ +local s = ls.s +local i = ls.i +local t = ls.t + +local d = ls.dynamic_node +local c = ls.choice_node +local f = ls.function_node +local sn = ls.snippet_node + +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep + +local snippets, autosnippets = {}, {} --}}} + +local group = vim.api.nvim_create_augroup("Lua Snippets", { clear = true }) +local file_pattern = "*.lua" + +local function cs(trigger, nodes, opts) --{{{ + local snippet = s(trigger, nodes) + local target_table = snippets + + local pattern = file_pattern + local keymaps = {} + + if opts ~= nil then + -- check for custom pattern + if opts.pattern then + pattern = opts.pattern + end + + -- if opts is a string + if type(opts) == "string" then + if opts == "auto" then + target_table = autosnippets + else + table.insert(keymaps, { "i", opts }) + end + end + + -- if opts is a table + if opts ~= nil and type(opts) == "table" then + for _, keymap in ipairs(opts) do + if type(keymap) == "string" then + table.insert(keymaps, { "i", keymap }) + else + table.insert(keymaps, keymap) + end + end + end + + -- set autocmd for each keymap + if opts ~= "auto" then + for _, keymap in ipairs(keymaps) do + vim.api.nvim_create_autocmd("BufEnter", { + pattern = pattern, + group = group, + callback = function() + vim.keymap.set(keymap[1], keymap[2], function() + ls.snip_expand(snippet) + end, { noremap = true, silent = true, buffer = true }) + end, + }) + end + end + end + + table.insert(target_table, snippet) -- insert snippet into appropriate table +end --}}} + +-- Start Refactoring -- + +-- End Refactoring -- + +return snippets, autosnippets diff --git a/.config/nvim/snippets/lua.lua b/.config/nvim/snippets/lua.lua new file mode 100644 index 0000000..eb46b67 --- /dev/null +++ b/.config/nvim/snippets/lua.lua @@ -0,0 +1,264 @@ + +local ls = require("luasnip") --{{{ +local s = ls.s --> snippet +local i = ls.i --> insert node +local t = ls.t --> text node + +local d = ls.dynamic_node +local c = ls.choice_node --> takes in a pos as first arg and a table of nodes +local f = ls.function_node +local sn = ls.snippet_node + +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep + +local snippets, autosnippets = {}, {} --}}} + +local group = vim.api.nvim_create_augroup("Lua Snippets", { clear = true }) +local file_pattern = "*.lua" + +local function cs(trigger, nodes, opts) --{{{ + local snippet = s(trigger, nodes) + local target_table = snippets + + local pattern = file_pattern + local keymaps = {} + + if opts ~= nil then + -- check for custom pattern + if opts.pattern then + pattern = opts.pattern + end + + -- if opts is a string + if type(opts) == "string" then + if opts == "auto" then + target_table = autosnippets + else + table.insert(keymaps, { "i", opts }) + end + end + + -- if opts is a table + if opts ~= nil and type(opts) == "table" then + for _, keymap in ipairs(opts) do + if type(keymap) == "string" then + table.insert(keymaps, { "i", keymap }) + else + table.insert(keymaps, keymap) + end + end + end + + -- set autocmd for each keymap + if opts ~= "auto" then + for _, keymap in ipairs(keymaps) do + vim.api.nvim_create_autocmd("BufEnter", { + pattern = pattern, + group = group, + callback = function() + vim.keymap.set(keymap[1], keymap[2], function() + ls.snip_expand(snippet) + end, { noremap = true, silent = true, buffer = true }) + end, + }) + end + end + end + + table.insert(target_table, snippet) -- insert snippet into appropriate table +end --}}} + +-- Start Refactoring -- + +cs("CMD", { -- [CMD] multiline vim.cmd{{{ + t({ "vim.cmd[[", " " }), + i(1, ""), + t({ "", "]]" }), +}) --}}} +cs("cmd", fmt("vim.cmd[[{}]]", { i(1, "") })) -- single line vim.cmd +cs({ -- github import for packer{{{ + trig = "https://github%.com/([%w-%._]+)/([%w-%._]+)!", + regTrig = true, + hidden = true, +}, { + t([[use "]]), + f(function(_, snip) + return snip.captures[1] + end), + t("/"), + f(function(_, snip) + return snip.captures[2] + end), + t({ [["]], "" }), + i(1, ""), +}, "auto") --}}} + +cs( -- {regexSnippet} LuaSnippet{{{ + "regexSnippet", + fmt( + [=[ +cs( -- {} +{{ trig = "{}", regTrig = true, hidden = true }}, fmt([[ +{} +]], {{ + {} +}})) + ]=], + { + i(1, "Description"), + i(2, ""), + i(3, ""), + i(4, ""), + } + ), + { pattern = "*/snippets/*.lua", "<C-d>" } +) --}}} +cs( -- [luaSnippet] LuaSnippet{{{ + "luaSnippet", + fmt( + [=[ +cs("{}", fmt( -- {} +[[ +{} +]], {{ + {} + }}){}) + ]=], + { + i(1, ""), + i(2, "Description"), + i(3, ""), + i(4, ""), + c(5, { + t(""), + fmt([[, "{}"]], { i(1, "keymap") }), + fmt([[, {{ pattern = "{}", {} }}]], { i(1, "*/snippets/*.lua"), i(2, "keymap") }), + }), + } + ), + { pattern = "*/snippets/*.lua", "jcs" } +) --}}} + +cs( -- choice_node_snippet luaSnip choice node{{{ + "choice_node_snippet", + fmt( + [[ +c({}, {{ {} }}), +]], + { + i(1, ""), + i(2, ""), + } + ), + { pattern = "*/snippets/*.lua", "jcn" } +) --}}} + +cs( -- [function] Lua function snippet{{{ + "function", + fmt( + [[ +function {}({}) + {} +end +]], + { + i(1, ""), + i(2, ""), + i(3, ""), + } + ), + "jff" +) --}}} +cs( -- [local_function] Lua function snippet{{{ + "local_function", + fmt( + [[ +local function {}({}) + {} +end +]], + { + i(1, ""), + i(2, ""), + i(3, ""), + } + ), + "jlf" +) --}}} +cs( -- [local] Lua local variable snippet{{{ + "local", + fmt( + [[ +local {} = {} + ]], + { i(1, ""), i(2, "") } + ), + "jj" +) --}}} +-- Tutorial Snippets go here -- +local myFirstSnippet = s("myFirstSnippet", { + t("Hi! This is my first snippet in Luasnip "), + i(1, "placeholder"), + t({"", "this is another text node", ""}), + i(2, "put here"), +}) +table.insert(snippets, myFirstSnippet) + + + +local mySecondSnippet = s( + "mySecondSnippet", + fmt( + [[ + local {} = function({}) + {} {{ im in a curly braces }} + end {} + ]], + { + i(1, "myVar"), + c(2, { t(""), i(1, "myArg") }), + i(3, "-- TODO: something"), + i(4, "-- nice") + } + ) +) +table.insert(snippets, mySecondSnippet) + +local myFirstAutoSnippet = s("automatic", { t("This was auto triggered") }) +table.insert(autosnippets, myFirstAutoSnippet) + +local mySecondAutoSnippet = s({ trig = "digit(%d)(%d)", regTrig = true }, { + f(function(_, snip) + return snip.captures[1] .. " + " + end), + f(function(_, snip) + return snip.captures[2] + end), +}) +table.insert(autosnippets, mySecondAutoSnippet) + + + + + + + + +-- End Refactoring -- + +return snippets, autosnippets + + + + + + + + + + + + + + diff --git a/.config/nvim/snippets/markdown.lua b/.config/nvim/snippets/markdown.lua new file mode 100644 index 0000000..d0d1487 --- /dev/null +++ b/.config/nvim/snippets/markdown.lua @@ -0,0 +1,58 @@ +local ls = require("luasnip") +local s = ls.s +local i = ls.i +local t = ls.t + +local d = ls.dynamic_node +local c = ls.choice_node +local f = ls.function_node +local sn = ls.snippet_node + +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep + +-- -- + +local snippets = {} +local autosnippets = {} + +local autocmd = vim.api.nvim_create_autocmd +local augroup = vim.api.nvim_create_augroup +local map = vim.keymap.set +local opts = { noremap = true, silent = true, buffer = true } +local group = augroup("Markdown Snippets", { clear = true }) + +local function cs(trigger, nodes, keymap) --> cs stands for create snippet + local snippet = s(trigger, nodes) + table.insert(snippets, snippet) + + if keymap ~= nil then + local pattern = "*.md" + if type(keymap) == "table" then + pattern = keymap[1] + keymap = keymap[2] + end + autocmd("BufEnter", { + pattern = pattern, + group = group, + callback = function() + map({ "i" }, keymap, function() + ls.snip_expand(snippet) + end, opts) + end, + }) + end +end + +local function lp(package_name) -- Load Package Function + package.loaded[package_name] = nil + return require(package_name) +end + +-- Utility Functions -- + +-- Start Refactoring -- + +-- Start Refactoring -- + +return snippets, autosnippets diff --git a/.config/picom/picom.conf b/.config/picom/picom.conf new file mode 100644 index 0000000..1e071ed --- /dev/null +++ b/.config/picom/picom.conf @@ -0,0 +1,488 @@ +################################# +# Animations # +################################# +# requires https://github.com/jonaburg/picom +# (These are also the default values) +transition-length = 300 +transition-pow-x = 0.1 +transition-pow-y = 0.1 +transition-pow-w = 0.1 +transition-pow-h = 0.1 +size-transition = true + + +################################# +# Corners # +################################# +# requires: https://github.com/sdhand/compton or https://github.com/jonaburg/picom +corner-radius = 10.0; +rounded-corners-exclude = [ +#"window_type = 'normal'", +# "class_g = 'Bspwm' && class_i = 'presel_feedback'", +# "class_g = 'URxvt'", +# "class_g = 'alacritty'", +# "class_g = 'Org.gnome.Nautilus'", +# "class_g = 'Nemo'", + "class_g = 'firefox'", +# "class_g = 'Rofi'", +# "class_g = 'Spotify'", +# "class_g = 'discord'", +# "class_g = 'Code'", +# "class_g = 'TelegramDesktop'", +# "class_g = 'YouTube Music'", + "class_g = 'Polybar'" +# "class_g = 'qutebrowser'", +# "class_g = 'Zathura'", +# "class_g = 'Pavucontrol'" + +]; +round-borders = 1; +#round-borders-exclude = [ +# "class_g = 'TelegramDesktop'", +#]; + + + +################################# +# Shadows # +################################# + + +# Enabled client-side shadows on windows. Note desktop windows +# (windows with '_NET_WM_WINDOW_TYPE_DESKTOP') never get shadow, +# unless explicitly requested using the wintypes option. +# +# shadow = false +shadow = true; + +# The blur radius for shadows, in pixels. (defaults to 12) +# shadow-radius = 12 +shadow-radius = 20; + +# The opacity of shadows. (0.0 - 1.0, defaults to 0.75) +# shadow-opacity = .75 + +# The left offset for shadows, in pixels. (defaults to -15) +# shadow-offset-x = -15 +shadow-offset-x = -5; + +# The top offset for shadows, in pixels. (defaults to -15) +# shadow-offset-y = -15 +shadow-offset-y = -5; + +# Avoid drawing shadows on dock/panel windows. This option is deprecated, +# you should use the *wintypes* option in your config file instead. +# +# no-dock-shadow = false + +# Don't draw shadows on drag-and-drop windows. This option is deprecated, +# you should use the *wintypes* option in your config file instead. +# +# no-dnd-shadow = false + +# Red color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-red = 0 + +# Green color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-green = 0 + +# Blue color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-blue = 0 + +# Do not paint shadows on shaped windows. Note shaped windows +# here means windows setting its shape through X Shape extension. +# Those using ARGB background is beyond our control. +# Deprecated, use +# shadow-exclude = 'bounding_shaped' +# or +# shadow-exclude = 'bounding_shaped && !rounded_corners' +# instead. +# +# shadow-ignore-shaped = '' + +# Specify a list of conditions of windows that should have no shadow. +# +# examples: +# shadow-exclude = "n:e:Notification"; +# +# shadow-exclude = [] +shadow-exclude = [ + "name = 'Notification'", + "class_g = 'Conky'", + "class_g ?= 'Notify-osd'", + "class_g = 'Cairo-clock'", + "class_g = 'Polybar'", + # "class_g = 'Rofi'" + "_GTK_FRAME_EXTENTS@:c" + ]; + +# Specify a X geometry that describes the region in which shadow should not +# be painted in, such as a dock window region. Use +# shadow-exclude-reg = "x10+0+0" +# for example, if the 10 pixels on the bottom of the screen should not have shadows painted on. +# +# shadow-exclude-reg = "" + +# Crop shadow of a window fully on a particular Xinerama screen to the screen. +# xinerama-shadow-crop = false + + +################################# +# Fading # +################################# + + +# Fade windows in/out when opening/closing and when opacity changes, +# unless no-fading-openclose is used. +# fading = false +fading = true + +# Opacity change between steps while fading in. (0.01 - 1.0, defaults to 0.028) +# fade-in-step = 0.028 +fade-in-step = 0.08; + +# Opacity change between steps while fading out. (0.01 - 1.0, defaults to 0.03) +# fade-out-step = 0.03 +fade-out-step = 0.08; + +# The time between steps in fade step, in milliseconds. (> 0, defaults to 10) +# fade-delta = 10 + +# Specify a list of conditions of windows that should not be faded. +# fade-exclude = [] + +# Do not fade on window open/close. +# no-fading-openclose = false + +# Do not fade destroyed ARGB windows with WM frame. Workaround of bugs in Openbox, Fluxbox, etc. +# no-fading-destroyed-argb = false + + +################################# +# Transparency / Opacity # +################################# + +# Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0) +# inactive-opacity = 1 +inactive-opacity = 1; + +# Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default) +# frame-opacity = 1.0 +frame-opacity = 1; + +# Default opacity for dropdown menus and popup menus. (0.0 - 1.0, defaults to 1.0) +# menu-opacity = 1.0 + +# Let inactive opacity set by -i override the '_NET_WM_OPACITY' values of windows. +# inactive-opacity-override = true +inactive-opacity-override = false; + +# Default opacity for active windows. (0.0 - 1.0, defaults to 1.0) +active-opacity = 1.0; + +# Dim inactive windows. (0.0 - 1.0, defaults to 0.0) +inactive-dim = 0.2 + +# Specify a list of conditions of windows that should always be considered focused. +# focus-exclude = [] +focus-exclude = ["class_g = 'Plank'", "class_g = 'st'", "class_g = 'kitty'", "class_g = 'wezterm'", "class_g = 'Alacritty'", "class_g = 'firefox'"]; + +# Use fixed inactive dim value, instead of adjusting according to window opacity. +# inactive-dim-fixed = 1.0 + +# Specify a list of opacity rules, in the format `PERCENT:PATTERN`, +# like `50:name *= "Firefox"`. picom-trans is recommended over this. +# Note we don't make any guarantee about possible conflicts with other +# programs that set '_NET_WM_WINDOW_OPACITY' on frame or client windows. +# example: +# opacity-rule = [ "80:class_g = 'URxvt'" ]; +opacity-rule = ["80:class_g = 'betterlockscreen'", "80:class_g = 'URxvt'", "100:class_g = 'firefox'", "100:class_g = 'Zathura'", "80:class_g = 'Spotify'", "80:class_g *?= 'Rofi'", "100:class_g = 'kitty' && focused", "100:class_g = 'kitty' && !focused", "100:class_g = 'Alacritty' && focused", "100:class_g = 'Alacritty' && !focused", "100:class_g = 'wezterm' && focused", "100:class_g = 'wezterm' && !focused"]; +# +#opacity-rule = ["85:class_g ?= 'Alacritty' && focused"]; + +#blur-background-exclude = ["class_g = 'scratchpad'"]; + +################################# +# Background-Blurring # +################################# + + +# Parameters for background blurring, see the *BLUR* section for more information. +blur-method = "dual_kawase"; +#blur-method = "gaussian"; +blur-strength = 6; +# blur-size = 12 +# +# blur-deviation = false + +# Blur background of semi-transparent / ARGB windows. +# Bad in performance, with driver-dependent behavior. +# The name of the switch may change without prior notifications. +# +blur-background = false; + +# Blur background of windows when the window frame is not opaque. +# Implies: +# blur-background +# Bad in performance, with driver-dependent behavior. The name may change. +# +# blur-background-frame = false + + +# Use fixed blur strength rather than adjusting according to window opacity. +#blur-background-fixed = false + + +# Specify the blur convolution kernel, with the following format: +# example: +# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"; +# +# blur-kern = '' +#blur-kern = "3x3box"; +blur-kern = "7x7box"; + +# Exclude conditions for background blur. +# blur-background-exclude = [] +blur-background-exclude = [ + "window_type = 'dock'", + "window_type = 'desktop'", + "_GTK_FRAME_EXTENTS@:c", + "class_g = 'kitty'", + "class_g = 'Alacritty'", + "class_g = 'wezterm'", +# "class_g = 'Polybar'", + "class_g = 'URxvt'", + "class_g = 'scratchpad'", + "class_g = 'Heads-Up-Display'", + "class_g = 'Firefox'", + "class_g = 'firefox'", + "class_g = 'discord'", + "class_g = 'Rofi'", + "class_g = 'Zathura'" +]; + +################################# +# General Settings # +################################# + +# Daemonize process. Fork to background after initialization. Causes issues with certain (badly-written) drivers. +# daemon = false + +# Specify the backend to use: `xrender`, `glx`, or `xr_glx_hybrid`. +# `xrender` is the default one. +# +experimental-backends = true; +#backend = 'glx' +backend = "glx"; +#backend = "xrender"; + +# Enable/disable VSync. +# vsync = false +vsync = true + +# Enable remote control via D-Bus. See the *D-BUS API* section below for more details. +# dbus = false + +# Try to detect WM windows (a non-override-redirect window with no +# child that has 'WM_STATE') and mark them as active. +# +# mark-wmwin-focused = false +mark-wmwin-focused = true; + +# Mark override-redirect windows that doesn't have a child window with 'WM_STATE' focused. +mark-ovredir-focused = false; +#mark-ovredir-focused = true; + +# Try to detect windows with rounded corners and don't consider them +# shaped windows. The accuracy is not very high, unfortunately. +# +# detect-rounded-corners = false +detect-rounded-corners = true; + +# Detect '_NET_WM_OPACITY' on client windows, useful for window managers +# not passing '_NET_WM_OPACITY' of client windows to frame windows. +# +# detect-client-opacity = false +detect-client-opacity = true; + +# Specify refresh rate of the screen. If not specified or 0, picom will +# try detecting this with X RandR extension. +# +# refresh-rate = 60 +refresh-rate = 0 + +# Limit picom to repaint at most once every 1 / 'refresh_rate' second to +# boost performance. This should not be used with +# vsync drm/opengl/opengl-oml +# as they essentially does sw-opti's job already, +# unless you wish to specify a lower refresh rate than the actual value. +# +# sw-opti = + +# Use EWMH '_NET_ACTIVE_WINDOW' to determine currently focused window, +# rather than listening to 'FocusIn'/'FocusOut' event. Might have more accuracy, +# provided that the WM supports it. +# +# use-ewmh-active-win = false + +# Unredirect all windows if a full-screen opaque window is detected, +# to maximize performance for full-screen windows. Known to cause flickering +# when redirecting/unredirecting windows. +# +# unredir-if-possible = false + +# Delay before unredirecting the window, in milliseconds. Defaults to 0. +# unredir-if-possible-delay = 0 + +# Conditions of windows that shouldn't be considered full-screen for unredirecting screen. +# unredir-if-possible-exclude = [] + +# Use 'WM_TRANSIENT_FOR' to group windows, and consider windows +# in the same group focused at the same time. +# +# detect-transient = false +detect-transient = true + +# Use 'WM_CLIENT_LEADER' to group windows, and consider windows in the same +# group focused at the same time. 'WM_TRANSIENT_FOR' has higher priority if +# detect-transient is enabled, too. +# +# detect-client-leader = false +detect-client-leader = true + +# Resize damaged region by a specific number of pixels. +# A positive value enlarges it while a negative one shrinks it. +# If the value is positive, those additional pixels will not be actually painted +# to screen, only used in blur calculation, and such. (Due to technical limitations, +# with use-damage, those pixels will still be incorrectly painted to screen.) +# Primarily used to fix the line corruption issues of blur, +# in which case you should use the blur radius value here +# (e.g. with a 3x3 kernel, you should use `--resize-damage 1`, +# with a 5x5 one you use `--resize-damage 2`, and so on). +# May or may not work with *--glx-no-stencil*. Shrinking doesn't function correctly. +# +# resize-damage = 1 + +# Specify a list of conditions of windows that should be painted with inverted color. +# Resource-hogging, and is not well tested. +# +# invert-color-include = [] + +# GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer. +# Might cause incorrect opacity when rendering transparent content (but never +# practically happened) and may not work with blur-background. +# My tests show a 15% performance boost. Recommended. +# +# glx-no-stencil = false + +# GLX backend: Avoid rebinding pixmap on window damage. +# Probably could improve performance on rapid window content changes, +# but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.). +# Recommended if it works. +# +# glx-no-rebind-pixmap = false + +# Disable the use of damage information. +# This cause the whole screen to be redrawn everytime, instead of the part of the screen +# has actually changed. Potentially degrades the performance, but might fix some artifacts. +# The opposing option is use-damage +# +# no-use-damage = false +use-damage = true + +# Use X Sync fence to sync clients' draw calls, to make sure all draw +# calls are finished before picom starts drawing. Needed on nvidia-drivers +# with GLX backend for some users. +# +# xrender-sync-fence = false + +# GLX backend: Use specified GLSL fragment shader for rendering window contents. +# See `compton-default-fshader-win.glsl` and `compton-fake-transparency-fshader-win.glsl` +# in the source tree for examples. +# +# glx-fshader-win = '' + +# Force all windows to be painted with blending. Useful if you +# have a glx-fshader-win that could turn opaque pixels transparent. +# +# force-win-blend = false + +# Do not use EWMH to detect fullscreen windows. +# Reverts to checking if a window is fullscreen based only on its size and coordinates. +# +# no-ewmh-fullscreen = false + +# Dimming bright windows so their brightness doesn't exceed this set value. +# Brightness of a window is estimated by averaging all pixels in the window, +# so this could comes with a performance hit. +# Setting this to 1.0 disables this behaviour. Requires --use-damage to be disabled. (default: 1.0) +# +# max-brightness = 1.0 + +# Make transparent windows clip other windows like non-transparent windows do, +# instead of blending on top of them. +# +# transparent-clipping = false + +# Set the log level. Possible values are: +# "trace", "debug", "info", "warn", "error" +# in increasing level of importance. Case doesn't matter. +# If using the "TRACE" log level, it's better to log into a file +# using *--log-file*, since it can generate a huge stream of logs. +# +# log-level = "debug" +log-level = "warn"; + +# Set the log file. +# If *--log-file* is never specified, logs will be written to stderr. +# Otherwise, logs will to written to the given file, though some of the early +# logs might still be written to the stderr. +# When setting this option from the config file, it is recommended to use an absolute path. +# +# log-file = '/path/to/your/log/file' + +# Show all X errors (for debugging) +# show-all-xerrors = false + +# Write process ID to a file. +# write-pid-path = '/path/to/your/log/file' + +# Window type settings +# +# 'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard: +# "unknown", "desktop", "dock", "toolbar", "menu", "utility", +# "splash", "dialog", "normal", "dropdown_menu", "popup_menu", +# "tooltip", "notification", "combo", and "dnd". +# +# Following per window-type options are available: :: +# +# fade, shadow::: +# Controls window-type-specific shadow and fade settings. +# +# opacity::: +# Controls default opacity of the window type. +# +# focus::: +# Controls whether the window of this type is to be always considered focused. +# (By default, all window types except "normal" and "dialog" has this on.) +# +# full-shadow::: +# Controls whether shadow is drawn under the parts of the window that you +# normally won't be able to see. Useful when the window has parts of it +# transparent, and you want shadows in those areas. +# +# redir-ignore::: +# Controls whether this type of windows should cause screen to become +# redirected again after been unredirected. If you have unredir-if-possible +# set, and doesn't want certain window to cause unnecessary screen redirection, +# you can set this to `true`. +# +wintypes: +{ + tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; full-shadow = false; }; + dock = { shadow = false; } + dnd = { shadow = false; } + popup_menu = { opacity = 0.8; } + dropdown_menu = { opacity = 0.8; } +}; + diff --git a/.config/polybar/config b/.config/polybar/config new file mode 100644 index 0000000..3bc2a2b --- /dev/null +++ b/.config/polybar/config @@ -0,0 +1,816 @@ +;========================================================== +; +; +; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗ +; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗ +; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝ +; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗ +; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ +; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ +; +; +; To learn more about how to configure Polybar +; go to https://github.com/polybar/polybar +; +; The README contains a lot of information +; +;========================================================== + +[colors] +background = #aa000000 +;background = #aa101212 +;background = #00000000 +background-alt = #aaCECCC9 +;foreground = #aaCECCC9 +foreground = #fafafa +foreground-alt = #aaCECCC9 +primary = #aaCECCC9 +secondary = #aaCECCC9 +alert = #aaCECCC9 +non = #aaCECCC9 +;background = #aa000000 +blue = #61afef +dark_blue = #42A5F5 +nord = #81a1c1 +light_blue = #ADD8E6 +;green = #a0c980 +purple = #c882e7 +orange = #E57C46 +;orange = #d08770 +gray = #676E95 +red = #EC7875 +pink = #EC407A +yellow = #FDD835 +;yellow = #ECBE7B +amber = #FBC02D +indigo = #6C77BB +green = #61C766 +lime = #B9C244 +cyber = #53E2AE + +[bar/top] +;width = 100% +width = 99.15% +height = 24 +offset-x = 0.5% +offset-y = 0.5% +radius = 10.0 +;radius = 0 +fixed-center = true +bottom = false +enable-ipc = true +tray-position = right +tray-padding = 4 +tray-background = ${colors.background} +;tray-offest-x = -15 +;tray-offset-x = 400 +;tray-offset-x = -95 +;tray-offset-x = -208 +;tray-offset-x = -178 +;tray-offset-x = -183 +tray-offset-x = -188 +;tray-offset-x = -210 +tray-offset-y = -0.9 +tray-detached = true + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 0 +line-color = ${colors.background-alt} + +;border-top-size = 1 +;border-bottom-size = 1 +;border-right-size = 1 +;border-left-size = 1 +;border-color = ${colors.foreground} +;border-size = 2 +;border-color = ${colors.background} + +padding-left = 0 +padding-right = 0 + +module-margin-left = 0 +module-margin-right = 0 +; Font for date +font-0 = "SF Pro Mono:style=Display Bold:size=10;2" +; Font for crypto, dunst +font-1 = "Material Design Icons:style=Bold:size=11.5;2" +; Font for menu +font-2 = "Material Design Icons:style=Bold:size=13.5;2" +; Font for controlCenter +font-3 = "SF Pro:style=Medium:size=10.5;2" +; Font for search +font-4 = "SF Pro:style=Medium:size=9.5;2" +; Font for bspwm/workspaces +font-5 = "UbuntuMono Nerd font:size=11;2" + +modules-left = sep menu sep close sep minimize sep maximize sep +modules-center = bspwm +modules-right = spotify spotify-prev spotify-play-pause spotify-next long-sep dunst search control date sep + +;modules-left = sep menu +;modules-center = date +;modules-right = bspwm whitespace crypto dunst search control space + +;modules-right = crypto dunst search date sep powermenu sep +;modules-right = crypto toggle_spotify volume backlight battery network notification powermenu + +wm-restack = bspwm +;wm-restack = bspwm + +override-redirect = true + +;; scroll-up = bspwm-desknext +;; scroll-down = bspwm-deskprev + +;scroll-up = i3wm-wsnext +;scroll-down = i3wm-wsprev + +cursor-click = pointer +cursor-scroll = ns-resize + +[module/menu] +type = custom/text +content = +content-font = 3 +content-padding = 1 +content-foreground = ${colors.foreground} +click-left = ~/.config/polybar/scripts/menu.sh +click-right = ~/.config/polybar/scripts/menu_full.sh + +[module/bspwm] +type = internal/bspwm +format = <label-state> +;format = <label-state> <label-mode> +format-padding = 0 +;format-padding-right = 2 +format-foreground = ${colors.foreground} +index-sort = true +enable-click = true +reverse-scroll = true +#reverse-scroll = false + +label-focused = +label-focused-padding = 2 + +label-occupied = +label-occupied-padding = 2 + +label-empty = +label-empty-padding = 2 + + +[module/sepp] +type = custom/text +content = " " + + +[module/close] +type = custom/text +content-foreground = ${colors.red} +content-padding = 1 +content = +click-left = "xdotool getwindowfocus windowkill" + +[module/minimize] +type = custom/text +content-foreground = ${colors.yellow} +content-padding = 1 +content = +click-left = bspc node -g hidden +click-right = ${HOME}/.config/bspwm/bspcmd unhide + +;label = +[module/maximize] +type = custom/text +content-foreground = ${colors.green} +content-padding = 1 +content = +;click-left = bspc node -t {fullscreen} +click-left = bspc node -t ~floating +click-right = bspc desktop -l next +#bspc node -t \~{fullscreen}; + +[module/blur-toggle] +type = custom/ipc +hook-0 = echo +hook-1 = echo +click-left = ~/.local/bin/scripts/blurtoggle.sh +initial = 1 +format-foreground = ${colors.foreground} + + +[module/battery] +type = internal/battery +full-t = 99 +time-format = %H:%M +battery = BAT1 +adapter = ACAD +format-padding = 1 +format-charging = <animation-charging> <label-charging> +format-charging-background = +label-charging = %percentage%% +format-discharging = <ramp-capacity> <label-discharging> +format-discharging-background = +label-discharging = %percentage%% +format-full = <label-full> +format-full-prefix = " " +format-full-prefix-foreground = ${colors.green} +;format-foreground = ${colors.green} +ramp-capacity-0 = +ramp-capacity-1 = +ramp-capacity-2 = +ramp-capacity-3 = +ramp-capacity-4 = +ramp-capacity-5 = +ramp-capacity-6 = +ramp-capacity-7 = +ramp-capacity-8 = +ramp-capacity-9 = + +ramp-capacity-0-foreground = ${colors.red} +ramp-capacity-1-foreground = ${colors.red} +ramp-capacity-foreground = ${colors.green} +;ramp-capacity-foreground = ${colors.foreground} +bar-capacity-width = 10 + +animation-charging-0 = +animation-charging-1 = +animation-charging-2 = +animation-charging-3 = +animation-charging-4 = +animation-charging-5 = +animation-charging-6 = +animation-charging-foreground = ${colors.green} + +animation-charging-framerate = 750 + +[module/xbacklight] +type = internal/xbacklight +enable-scroll = true + +[module/backlight] +inherit = module/xbacklight +type = internal/backlight +card = intel_backlight +format-backlight = <ramp-backlight> <label> +format-padding = 1 +format-prefix = " " +format-prefix-foreground = ${colors.indigo} +label = %percentage%% +label-foreground = ${colors.foreground} + +[module/bluetooth] +type = custom/script +exec = ~/.config/polybar/scripts/bluetooth.sh +tail = true +click-left = exec blueberry & +click-right = exec $HOME/.config/polybar/scripts/toggle_bluetooth.sh + +[module/network] +type = custom/script +exec = ~/.config/polybar/scripts/check-network.sh +format-background = +format-foreground = ${colors.light_blue} +click-left = networkmanager_dmenu & +click-right = nm-applet +tail = true +format-padding = 1 + + +;[module/date] +;type = internal/date +;interval = 30 +;label = %time% +;label-padding = 2 +;label-background = +;time = %H:%M +;time-alt = %Y-%m-%d + +[module/date] +type = internal/date +interval = 1 +label = %date%, %time% +label-padding = 2.5 +label-background = +date = %a %d %b +time = %H:%M + +;[module/powermenu] +;type = custom/text +;content = +;;content = 襤 +;content-foreground = ${colors.red} +;content-padding = 1 +;label-margin = 3 +;click-left = ~/.config/polybar/scripts/sysmenu.sh +;click-right = ~/.config/polybar/scripts/sysmenu.sh + +[module/control] +type = custom/text +content = +;content = 襤 +content-foreground = ${colors.foreground} +content-padding = 1 +label-margin = 10 +click-left = ~/.config/polybar/scripts/sysmenu.sh +click-right = ~/.config/polybar/scripts/sysmenu.sh + + +;[module/title] +;type = internal/xwindow +;; Available tags: +;; <label> (default) +;format = <label> +;format-background = ${colors.background} +;format-foreground = ${colors.foreground} +;format-padding = 1 +;label-maxlen = 10 +;label-empty = " " + + +;[module/bspwm] +;type = internal/bspwm +;format = <label-state> +;;format = <label-state> <label-mode> +;format-padding = 1 +;format-foreground = ${colors.foreground} +;index-sort = true +;enable-click = true +;reverse-scroll = true +;#reverse-scroll = false +; +;label-focused = +;label-focused-padding = 2 +; +;label-occupied = +;label-occupied-padding = 2 +; +;label-empty = +;label-empty-padding = 2 +; +;label-monocle = " " +;label-tiled = " " +;label-fullscreen = " " +;label-floating = " " +;label-pseudotiled = " " +;label-locked = " " +;;label-sticky = " " +;label-private = " " + +; Separator in between workspaces +;label-separator = | +;label-separator-padding = 10 +;label-separator-foreground = #ffb52a +[module/search] +type = custom/text +content = "" +; hack nerd +content-padding = 1 +content-font = 5 +;content-padding-right = 5 +content-foreground = ${colors.foreground} +click-left = rofi -show drun +;click-left = ~/.config/polybar/scripts/menu.sh + + + +[module/crypto] +type = custom/script +exec = echo +format = <label> +format-padding = 1 +label-padding = +content-background = +format-foreground = ${colors.foreground} +interval = 60 +click-left = cryptonotify +click-right = $TERMINAL -e cointop & + +[module/now-playing] +type = custom/script +tail = true +;format-prefix = "" +format = <label> +exec = ~/.config/polybar/scripts/now-playing.sh +click-right = "kill -USR1 $(pgrep --oldest --parent %pid%)" + + +[module/sep] +type = custom/text +content = " " + +[module/long-sep] +type = custom/text +content = " " + +[module/space] +type = custom/text +content = " " + +[module/whitespace] +type = custom/text +content = " " + +[module/xwindow] +type = internal/xwindow +label = %title:0:60:...% +format-foreground = ${colors.foreground} +format-padding = 6 + +[module/arch] +typ = custom/text +content = " " +format-foreground = ${colors.foreground} +format-padding = 4 + + + +[module/workspaces] +type = internal/xworkspaces +pin-workspaces = true +enable-click = true +enable-scroll = true +format-padding = 1 + +icon-default = + +format = <label-state> +format-background = ${colors.bg1} +label-active = " " +label-occupied = " " +label-urgent = " " +label-empty = " " + +label-empty-padding = 1 +label-active-padding = 1 +label-urgent-padding = 1 +label-occupied-padding = 1 + +label-empty-foreground = ${colors.foreground} +label-active-foreground = ${colors.acolor} +label-urgent-foreground = ${colors.curgent} +label-occupied-foreground = ${colors.foreground} + +[module/spotify] +type = custom/script +tail = true +interval = 1 +; prefix symbol is shown before the text +format-prefix = "" +format = <label> +exec = ~/.config/polybar/scripts/scroll_spotify_status.sh + +[module/spotify-prev] +type = custom/script +tail = true +interval = 1 +exec = echo " " +format = <label> +click-left = playerctl previous -p spotify + +[module/spotify-play-pause] +type = custom/ipc +tail = true +interval = 1 +hook-0 = echo "" +hook-1 = echo "" +initial = 1 +click-left = playerctl play-pause -p spotify + +[module/spotify-next] +type = custom/script +#type = custom/ipc +tail = true +interval = 1 +exec = echo " " +format = <label> +click-left = playerctl next -p spotify + +[module/toggle_spotify] +type = custom/text +content = " " +content-padding = 1 +content-foreground = ${colors.pink} +click-left = spotify +click-right = spotify + +[module/cmus] +type = custom/script + +exec = ~/.config/polybar/scripts/cmus.sh +exec-if = pgrep -x cmus +interval = 1 + +click-left = cmus-remote --next +click-right = cmus-remote --prev +click-middle = cmus-remote --pause +scroll-up = cmus-remote --volume +5% +scroll-down = cmus-remote --volume -5% + +label-font = 1 +format = <label> +format-underline = ${colors.foreground-alt} +label = %output% +label-maxlen = 50 + +[module/notification] +type = custom/text +content = +content-padding = 0 +content-foreground = ${colors.foreground-alt} +click-left = sh rofi_notif_center.sh +click-right = sh rofi_notif_center.sh + +[module/dunst] +type = custom/text +content-foreground = ${colors.foreground} +content-padding = 1 +content = +click-left = "dunstctl history-pop" + +[module/popup-calendar] +type = custom/script +exec = ~/.config/polybar/scripts/popup-calendar.sh +interval = 5 +click-left = ~/.config/polybar/scripts/popup-calendar.sh --popup & + +;[module/dunst] +;type = custom/ipc +;initial = 1 +;format-foreground = ${colors.foreground} +;hook-0 = echo "%{A1:notify-send dunstctl && polybar-msg hook dunst 2:}%{A}" & +;hook-1 = echo "%{A1:notify-send dunstctl && polybar-msg hook dunst 1:}%{A}" & + +[module/eww] +type = custom/text +content = +content-padding = 0 +content-foreground = #d8dee9 +click-left = sh toggle_eww.sh +click-right = sh toggle_eww.sh + +[module/pulseaudio] +type = internal/pulseaudio +ramp-volume-foreground = #8959a8 +format-volume-padding = 0 +format-volume-margin = 0 +format-volume = <ramp-volume> +use-ui-max = true +interval = 5 + +ramp-volume-0 = " " +ramp-volume-1 = " " +ramp-volume-2 = " " + + +label-muted = +label-muted-background = #3e999f +format-muted-foreground = #3e999f +format-muted-overline = #3e999f +format-muted-margin = 2 +format-muted-padding = 2 + +[module/volume] +type = internal/pulseaudio +format-volume = <ramp-volume> <label-volume> +format-volume-font = 10 +format-volume-padding = 0 +;ramp-volume-foreground = ${colors.foreground} +label-volume = %percentage%% +label-volume-padding = 0 +;label-muted-foreground = ${colors.foreground} +;format-volume-foreground = ${colors.purple} +format-muted-foreground = ${colors.red} +format-muted-underline = ${colors.red} +ramp-volume-foreground = ${colors.purple} +label-muted = "婢 " +ramp-volume-0 = "" +ramp-volume-1 = "" +ramp-volume-2 = "" +ramp-volume-3 = "" +ramp-volume-4 = "" +ramp-volume-5 = "" +ramp-volume-6 = "" + + +[module/xkeyboard] +type = internal/xkeyboard +blacklist-0 = num lock + +format-prefix = +format-foreground = ${colors.foreground-alt} +label-layout = " %layout%" + +label-indicator-foreground = ${colors.alert} +label-indicator-padding = 2 + +[module/filesystem] +type = internal/fs +interval = 25 + +mount-0 = / + +format-mounted = <label-mounted> +format-mounted-foreground = #b48ead +format-mounted-prefix = " " +label-mounted = " %free%" + +format-unmounted = <label-unmounted> +format-unmounted-prefix = +label-unmounted = %mountpoint%: not mounted + +[module/updates] +type = custom/script +exec = xbps-updates +format = <label> +interval = 4600 +label = %output% +label-padding = 2 +label-foreground = #81A1C1 + + +[module/cpu] +type = internal/cpu +interval = 2 +format-prefix = " " +format-prefix-foreground = #b48ead +label = %percentage:2%% + + +[module/memory] +type = internal/memory +interval = 2 +format-prefix = " " +format-prefix-foreground = #5e81ac +label = %percentage_used%% + +[module/globalmenu] +type = custom/script +exec = ~/.config/polybar/globalmenu.sh +format = <label> +label = %output% +;type = custom/ipc +;hook-0 = xfce4-panel | sed -e 's/^"//' -e 's/"$//' +;;exec = awk /usr/bin/xfce4-panel +;initial = 1 +;format-underline = ${colors.cyber} +;format-padding = 1 + +[module/global] +type = custom/script +exec = ~/.config/polybar/globaldmenu +label = %output% + +[settings] +screenchange-reload = true +;compositing-background = xor +;compositing-background = screen +;compositing-foreground = source +;compositing-border = over +;pseudo-transparency = false + +[global/wm] +margin-top = 0 +margin-bottom = 0 + +[module/options_open] +type = custom/text +content-foreground = ${colors.foreground} +content = "" +click-left = ~/.config/polybar/scripts/polybar_wrapper options + +[module/options_close] +type = custom/text +content-foreground = ${colors.primary} +content = "" +click-left = ~/.config/polybar/scripts/polybar_wrapper options + +;[bar/bottom] +;width = 8% +;height = 15 +;offset-x = 46% +;;offset-x = 35% +;;offset-x = 0.5% +;offset-y = 2.5% +;radius = 7.0 +;fixed-center = true +;bottom = false +;enable-ipc = true +;;tray-offset-x = 515 +;;tray-detached = true +; +;background = ${colors.background} +;foreground = ${colors.foreground} +; +;line-size = 0 +;line-color = ${colors.background-alt} +; +;;border-top-size = 1 +;;border-bottom-size = 1 +;;border-right-size = 1 +;;border-left-size = 1 +;;border-color = ${colors.foreground} +;;border-size = 2 +;;border-color = ${colors.background} +; +;padding-left = 0 +;padding-right = 0 +; +;module-margin-left = 0 +;module-margin-right = 0 +;; Font for date +;font-0 = "SF Pro Mono:style=Display Bold:size=10;2" +;; Font for bspwm/workspaces +;font-1 = "UbuntuMono Nerd font:size=10.5;2" +;; Font for crypto, dunst +;font-2 = "Material Design Icons:style=Bold:size=11;3" +;; Font for menu +;font-3 = "Material Design Icons:style=Bold:size=14;5" +;; Font for search and controlCenter +;font-4 = "SF Pro:style=Medium:size=10.5;3" +; +;modules-center = bspwm sepp +; +;;wm-restack = bspwm +; +;override-redirect = true +; +;;; scroll-up = bspwm-desknext +;;; scroll-down = bspwm-deskprev +; +;;scroll-up = i3wm-wsnext +;;scroll-down = i3wm-wsprev +; +;cursor-click = pointer +;cursor-scroll = ns-resize +; +; +;[bar/left] +;width = 5% +;height = 15 +;offset-x = 2.5% +;;offset-x = 35% +;;offset-x = 0.5% +;offset-y = 2.5% +;radius = 7.0 +;fixed-center = true +;bottom = false +;enable-ipc = true +;;tray-offset-x = 515 +;;tray-detached = true +; +;background = ${colors.background} +;foreground = ${colors.foreground} +; +;line-size = 0 +;line-color = ${colors.background-alt} +; +;;border-top-size = 1 +;;border-bottom-size = 1 +;;border-right-size = 1 +;;border-left-size = 1 +;;border-color = ${colors.foreground} +;;border-size = 2 +;;border-color = ${colors.background} +; +;padding-left = 0 +;padding-right = 0 +; +;module-margin-left = 0 +;module-margin-right = 0 +;; Font for date +;font-0 = "SF Pro Mono:style=Display Bold:size=10;2" +;; Font for bspwm/workspaces +;font-1 = "UbuntuMono Nerd font:size=11.5;2" +;; Font for crypto, dunst +;font-2 = "Material Design Icons:style=Bold:size=11;3" +;; Font for menu +;font-3 = "Material Design Icons:style=Bold:size=14;5" +;; Font for search and controlCenter +;font-4 = "SF Pro:style=Medium:size=10.5;3" +; +;modules-left = close blank minimize blank maximize blank +; +;;wm-restack = bspwm +; +;override-redirect = true +; +;;; scroll-up = bspwm-desknext +;;; scroll-down = bspwm-deskprev +; +;;scroll-up = i3wm-wsnext +;;scroll-down = i3wm-wsprev +; +;cursor-click = pointer +;cursor-scroll = ns-resize +; +;;[module/decorations] +;;type = custom/text +; +;[module/blank] +;type = custom/text +;content = " " + +; vim:ft=dosini diff --git a/.config/polybar/launch.sh b/.config/polybar/launch.sh new file mode 100755 index 0000000..1c0ac10 --- /dev/null +++ b/.config/polybar/launch.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env sh + +# Terminate already running bar instances +killall -q polybar + +# Wait until the processes have been shut down +while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + +# Launch bar +polybar top & +#polybar bottom & +#polybar left & +#polybar top_external & + +#sleep 5 && xdo raise -N "polybar-bottom_LVDS-1" & +if [[ $(xrandr -q | grep 'HDMI-1 connected') ]]: then + polybar top_external & +fi diff --git a/.config/polybar/scripts/bluetooth.sh b/.config/polybar/scripts/bluetooth.sh new file mode 100755 index 0000000..061604b --- /dev/null +++ b/.config/polybar/scripts/bluetooth.sh @@ -0,0 +1,12 @@ +#!/bin/sh +if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] +then + echo "" +else + if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ] + then + echo "" + fi + echo "" +fi + diff --git a/.config/polybar/scripts/check-network.sh b/.config/polybar/scripts/check-network.sh new file mode 100755 index 0000000..dabe74c --- /dev/null +++ b/.config/polybar/scripts/check-network.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +count=0 +disconnected="睊" +wireless_connected="直" +ethernet_connected="泌" + +ID="$(ip link | awk '/state UP/ {print $2}')" + +while true; do + if (ping -c 1 archlinux.org || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) &>/dev/null; then + if [[ $ID == e* ]]; then + echo "$ethernet_connected" ; sleep 25 + else + echo "$wireless_connected" ; sleep 25 + fi + else + echo "$disconnected" ; sleep 0.5 + fi +done + diff --git a/.config/polybar/scripts/check_updates.sh b/.config/polybar/scripts/check_updates.sh new file mode 100755 index 0000000..52e51a9 --- /dev/null +++ b/.config/polybar/scripts/check_updates.sh @@ -0,0 +1,118 @@ + +#!/usr/bin/bash +# +# checkupdates: Safely print a list of pending updates. +# +# Copyright (c) 2013 Kyle Keen <keenerd@gmail.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +declare -r myname='checkupdates' +declare -r myver='1.0.0' + +plain() { + (( QUIET )) && return + local mesg=$1; shift + printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 +} + +msg() { + (( QUIET )) && return + local mesg=$1; shift + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 +} + +msg2() { + (( QUIET )) && return + local mesg=$1; shift + printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 +} + +ask() { + local mesg=$1; shift + printf "${BLUE}::${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}" "$@" >&1 +} + +warning() { + local mesg=$1; shift + printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +error() { + local mesg=$1; shift + printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +# check if messages are to be printed using color +unset ALL_OFF BOLD BLUE GREEN RED YELLOW +if [[ -t 2 && ! $USE_COLOR = "n" ]]; then + # prefer terminal safe colored and bold text when tput is supported + if tput setaf 0 &>/dev/null; then + ALL_OFF="$(tput sgr0)" + BOLD="$(tput bold)" + BLUE="${BOLD}$(tput setaf 4)" + GREEN="${BOLD}$(tput setaf 2)" + RED="${BOLD}$(tput setaf 1)" + YELLOW="${BOLD}$(tput setaf 3)" + else + ALL_OFF="\e[1;0m" + BOLD="\e[1;1m" + BLUE="${BOLD}\e[1;34m" + GREEN="${BOLD}\e[1;32m" + RED="${BOLD}\e[1;31m" + YELLOW="${BOLD}\e[1;33m" + fi +fi +readonly ALL_OFF BOLD BLUE GREEN RED YELLOW + + +if (( $# > 0 )); then + echo "${myname} v${myver}" + echo + echo "Safely print a list of pending updates" + echo + echo "Usage: ${myname}" + echo + echo 'Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database.' + exit 0 +fi + +if ! type -P fakeroot >/dev/null; then + error 'Cannot find the fakeroot binary.' + exit 1 +fi + +if [[ -z $CHECKUPDATES_DB ]]; then + CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/" +fi + +trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT + +DBPath="$(pacman-conf DBPath)" +if [[ -z "$DBPath" ]] || [[ ! -d "$DBPath" ]]; then + DBPath="/var/lib/pacman/" +fi + +mkdir -p "$CHECKUPDATES_DB" +ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null +if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null; then + error 'Cannot fetch updates' + exit 1 +fi +pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]' + +exit 0 + +# vim: set noet: diff --git a/.config/polybar/scripts/cmus.sh b/.config/polybar/scripts/cmus.sh new file mode 100755 index 0000000..2f42c63 --- /dev/null +++ b/.config/polybar/scripts/cmus.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +prepend_zero () { + seq -f "%02g" $1 $1 +} + +artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-)) + +if [[ $artist = *[!\ ]* ]]; then + song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-)) + position=$(cmus-remote -C status | grep position | cut -c 10-) + minutes1=$(prepend_zero $(($position / 60))) + seconds1=$(prepend_zero $(($position % 60))) + duration=$(cmus-remote -C status | grep duration | cut -c 10-) + minutes2=$(prepend_zero $(($duration / 60))) + seconds2=$(prepend_zero $(($duration % 60))) + echo -n "$artist - $song " +else + echo +fi + +#prepend_zero () { +# seq -f "%02g" $1 $1 +#} +# +#artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-)) +# +#if [[ $artist = *[!\ ]* ]]; then +# song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-)) +# position=$(cmus-remote -C status | grep position | cut -c 10-) +# minutes1=$(prepend_zero $(($position / 60))) +# seconds1=$(prepend_zero $(($position % 60))) +# duration=$(cmus-remote -C status | grep duration | cut -c 10-) +# minutes2=$(prepend_zero $(($duration / 60))) +# seconds2=$(prepend_zero $(($duration % 60))) +# echo -n "$artist - $song [$minutes1:$seconds1/$minutes2:$seconds2]" +#else +# echo +#fi diff --git a/.config/polybar/scripts/get_spotify_status.sh b/.config/polybar/scripts/get_spotify_status.sh new file mode 100755 index 0000000..f04400d --- /dev/null +++ b/.config/polybar/scripts/get_spotify_status.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# The name of polybar bar which houses the main spotify module and the control modules. +PARENT_BAR="now-playing" +PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1) + +# Set the source audio player here. +# Players supporting the MPRIS spec are supported. +# Examples: spotify, vlc, chrome, mpv and others. +# Use `playerctld` to always detect the latest player. +# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control +#PLAYER="spotify" +PLAYER="playerctld" + +# Format of the information displayed +# Eg. {{ artist }} - {{ album }} - {{ title }} +# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata +FORMAT="{{ title }} - {{ artist }}" + +# Sends $2 as message to all polybar PIDs that are part of $1 +update_hooks() { + while IFS= read -r id + do + polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1 + done < <(echo "$1") +} + +PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null) +EXIT_CODE=$? + +if [ $EXIT_CODE -eq 0 ]; then + STATUS=$PLAYERCTL_STATUS +else + STATUS="No player is running" +fi + +if [ "$1" == "--status" ]; then + echo "$STATUS" +else + if [ "$STATUS" = "Stopped" ]; then + echo "No music is playing" + elif [ "$STATUS" = "Paused" ]; then + update_hooks "$PARENT_BAR_PID" 2 + playerctl --player=$PLAYER metadata --format "$FORMAT" + elif [ "$STATUS" = "No player is running" ]; then + echo "" + else + update_hooks "$PARENT_BAR_PID" 1 + playerctl --player=$PLAYER metadata --format "$FORMAT" + fi +fi + diff --git a/.config/polybar/scripts/menu.sh b/.config/polybar/scripts/menu.sh new file mode 100755 index 0000000..93f3779 --- /dev/null +++ b/.config/polybar/scripts/menu.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#FF6F00" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true \ +-hide-sidebar-mode true \ +-bw 0 \ +-lines 15 \ +-line-padding 10 \ +-padding 0 \ +-width 20 \ +-xoffset 7 -yoffset 28 \ +-location 1 \ +-columns 1 \ +-show-icons -icon-theme "Papirus" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" +#rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true -sidebar-mode false -bw 0 -lines 6 -line-padding 10 -padding 20 -width 30 -xoffset 7 -yoffset 25 -location 1 -columns 2 -show-icons -icon-theme "Papirus" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/polybar/scripts/menu.shsave b/.config/polybar/scripts/menu.shsave new file mode 100755 index 0000000..ea5bf8e --- /dev/null +++ b/.config/polybar/scripts/menu.shsave @@ -0,0 +1,63 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#FF6F00" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar false \ +-hide-sidebar-mode true \ +-bw 0 \ +-lines 15 \ +-line-padding 10 \ +-padding 0 \ +-width 20 \ +-xoffset 7 -yoffset 28 \ +-location 1 \ +-columns 1 \ +-show-icons -icon-theme "Papirus" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" +#rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true -sidebar-mode false -bw 0 -lines 6 -line-padding 10 -padding 20 -width 30 -xoffset 7 -yoffset 25 -location 1 -columns 2 -show-icons -icon-theme "Papirus" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/polybar/scripts/menu_full.sh b/.config/polybar/scripts/menu_full.sh new file mode 100755 index 0000000..9f898a4 --- /dev/null +++ b/.config/polybar/scripts/menu_full.sh @@ -0,0 +1,65 @@ + +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#FF6F00" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun \ +-display-drun "Applications " -drun-display-format "{name}" \ +-hide-scrollbar true \ +-bw 0 \ +-lines 10 \ +-line-padding 15 \ +-padding 60 \ +-width 30 \ +-xoffset 10 -yoffset 40 \ +-location 1 \ +-fullscreen \ +-columns 4 \ +-show-icons -icon-theme "Papirus" \ +-font "Fantasque Sans Mono 10" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground diff --git a/.config/polybar/scripts/now-playing.sh b/.config/polybar/scripts/now-playing.sh new file mode 100755 index 0000000..8fa6000 --- /dev/null +++ b/.config/polybar/scripts/now-playing.sh @@ -0,0 +1,217 @@ +#!/usr/bin/env python3 +import dbus +import signal +import time +from unicodedata import east_asian_width + +# Config options + +# (int) : Length of media info string. If length of string exceedes this value, the text will scroll. Default value is 20 +message_display_len = 20 + +# (int) : Font index of polybar. this value should be 1 more than the font value specified in polybar config. +font_index = 1 + +# (float) : Update speed of the text in seconds. +update_delay = 0.3 + +# (list) : list of chars containing previous, play, pause, next glyphs for media controls in respective order +control_chars = ['','','',''] + +# (dict) : dict of char icons to display as prefix. +# If player name is available as key, then use the corressponding icon, +# else default key value. +# example: +display_player_prefix = { + "spotify": ' ', + "firefox": ' ', + "default": ' ' +} + +# (list) : list of metadata fields based on mpris sepecification. +# For more details/ field names, refer [mpris sepecification](https://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/) +metadata_fields = ["xesam:title", "xesam:artist"] + +# (char) : separator for metadata fields +metadata_separator = "-" + +# (bool) : Hide text when no player is available? True disables the output for no players. +hide_output = False + +# Defult initialization +current_player = None +player_names = None +players = None +message = None +display_text = "" +display_prefix = " " +display_suffix = "" +last_player_name = None + +session_bus = dbus.SessionBus() + +def get_name(player_name ): + if player_name not in player_names: + return + name = ".".join(player_name.split(".")[3:]) + return name + +def get_name_by_index(index): + if index >= len(player_names): + return + return get_name(player_names[index]) + +def get_status(player): + status = "" + try: + status = player.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus', dbus_interface='org.freedesktop.DBus.Properties') + except Exception as e: + pass + return status + +def get_metadata(player): + metadata = {} + try: + metadata = player.Get('org.mpris.MediaPlayer2.Player', 'Metadata', dbus_interface='org.freedesktop.DBus.Properties') + except Exception as e: + pass + return metadata + +def update_prefix_suffix(player_name="", status=""): + global display_prefix, display_suffix, status_paused + + player_option = "" + if player_name != "": + player_option = "-p " + player_name + + prev_button = "%%{A:playerctl %s previous :}%c%%{A}" %(player_option,control_chars[0]) + play_button = "%%{A:playerctl %s play :}%c%%{A}" %(player_option,control_chars[1]) + pause_button = "%%{A:playerctl %s pause :}%c%%{A}" %(player_option,control_chars[2]) + next_button = "%%{A:playerctl %s next :}%c%%{A}" %(player_option,control_chars[3]) + + suffix = "| " + prev_button + if status == "Playing": + suffix += " "+pause_button + status_paused = False + else: + suffix += " "+play_button + status_paused = True + suffix += " "+next_button + # print(suffix) + display_suffix = suffix + + for key in display_player_prefix.keys(): + if key in player_name: + display_prefix = display_player_prefix[key] + break + else: + display_prefix = display_player_prefix["default"] + +def update_players(): + global player_names, players, session_bus, current_player, last_player_name + player_names = [service for service in session_bus.list_names() if service.startswith('org.mpris.MediaPlayer2.')] + players = [session_bus.get_object(service, '/org/mpris/MediaPlayer2') for service in player_names] + if last_player_name != get_name(current_player): + for index, player in enumerate(player_names): + if get_name(player) == last_player_name: + current_player = index + +def handle_event(*args): + global current_player, players, last_player_name + update_players() + if len(players) == 0: + return + current_player += 1 + current_player %= len(players) + last_player_name = getname_by_index(current_player) +# print("SIGUSR1: updated values - current_player = %d players len = %d"%(current_player,len(players))) + +def update_message(): + global players, current_player,player_names, message, display_text, message_display_len, display_suffix, last_player_name + if len(players) == 0: + tmp_message = "No player available" + update_prefix_suffix() + else: + name = get_name_by_index(current_player) + status = get_status(players[current_player]) + metadata_obj = get_metadata(players[current_player]) + metadata_string_list = [] + for field in metadata_fields: + result = metadata_obj.get(field) + if type(result) == dbus.Array: + result = result[0] + if not result: + result = "No "+field.split(":")[1] + metadata_string_list.append(str(result)) + metadata_string = (" "+metadata_separator+" ").join(metadata_string_list) + if visual_len(metadata_string) > message_display_len: + metadata_string = " " + metadata_string + " |" + update_prefix_suffix(name,status) + tmp_message = "" + if metadata_string: + tmp_message += str(metadata_string) + last_player_name = name + if message != tmp_message: + message = tmp_message + display_text = message + +def scroll(): + global display_text, message_display_len, status_paused + if not status_paused: + if len(display_text) > message_display_len: + display_text = display_text[1:] + display_text[0] + elif len(display_text) < message_display_len: + display_text += " "*(message_display_len - len(display_text)) + +def visual_len(text): + visual_length = 0 + for ch in text: + width = east_asian_width(ch) + if width == 'W' or width == 'F': + visual_length += 1 + visual_length += 1 + return visual_length + +def make_visual_len(text, visual_desired_length): + visual_length = 0 + altered_text = '' + for char in text: + if visual_length < visual_desired_length: + width = east_asian_width(char) + if width == 'W' or width == 'F': + visual_length += 2 + else: + visual_length += 1 + altered_text += char + else: + break + if visual_length == visual_desired_length + 1: + altered_text = altered_text[:-1] + ' ' + elif visual_length < visual_desired_length: + altered_text += ' ' * (visual_desired_length - visual_length) + return altered_text + +def print_text(): + global display_text, message_display_len, players, player_names, display_prefix, display_suffix + if hide_output and len(players)==0: + print("", flush = True) + return + scroll() + print(display_prefix + " " + + "%%{T%d}" % (font_index) + + make_visual_len(display_text, message_display_len) + + "%{T-}" + display_suffix, flush=True) + +def main(): + global current_player, players + update_players() + current_player = 0 + while True: + time.sleep(update_delay) + update_players() + update_message() + print_text() + +if __name__ == '__main__': + signal.signal(signal.SIGUSR1, handle_event) + main() diff --git a/.config/polybar/scripts/polybar_wrapper b/.config/polybar/scripts/polybar_wrapper new file mode 100755 index 0000000..901bb28 --- /dev/null +++ b/.config/polybar/scripts/polybar_wrapper @@ -0,0 +1,92 @@ +#!/bin/bash + +DIR=$(dirname $(realpath $0)) + +WINDOW_ID_CONKY=/tmp/conky_window_id +WINDOW_ID_TOP=/tmp/polybar_top_window_id +WINDOW_ID_EXPANDED=/tmp/polybar_expanded_window_id + +conky_launch() { + # Hacky X11 magic to make Conky appear above polybar + killall conky + # xdotool search can't find Conky's window but fortunately Conky outputs it + conky -c ~/.config/conky/config 2> /tmp/conky_out + # Extract the hex window id from Conky's output + HEX=$(awk '/drawing to created window/ {print $NF}' /tmp/conky_out | tr -d '()' | awk -Fx '{print $2}') + WIN_ID=$(( 16#$HEX )) # convert to decimal + xdotool windowunmap $WIN_ID + echo $WIN_ID > $WINDOW_ID_CONKY +} + +polybar_launch() { + killall polybar + + polybar top & + xdotool search --sync --pid $! > $WINDOW_ID_TOP + + polybar expanded & + xdotool search --sync --pid $! > $WINDOW_ID_EXPANDED + + bar_collapse +} + +launch() { + # Temporarily disable conky until I update the config + # conky_launch + # sleep 0.2 + polybar_launch +} + +bar_expand() { + xdotool windowmap $(cat $WINDOW_ID_EXPANDED) + xdotool windowunmap $(cat $WINDOW_ID_TOP) +} + +bar_collapse() { + xdotool windowunmap $(cat $WINDOW_ID_EXPANDED) + xdotool windowmap $(cat $WINDOW_ID_TOP) +} + +rofi_open() { + options_close + bar_expand & + rofi -modi run -show run + bar_collapse +} + +drun_open() { + bar_expand & + rofi -theme drun -modi drun -show drun -drun-categories Custom + bar_collapse +} + +search_open() { + options_close + bar_expand & + rofi -theme window -modi window -show window + bar_collapse +} + +options_open() { + bar_expand + $DIR/rofi_option_menu + bar_collapse + # echo "open" > /tmp/polybar_side_panel_state + # ID_CONKY=$(cat $WINDOW_ID_CONKY) + # xdotool windowmap $ID_CONKY + # xdotool windowraise $ID_CONKY + # ~/.config/i3/scripts/music_player show_applet +} + +case "$1" in + rofi) + rofi_open;; + search) + search_open;; + drun) + drun_open;; + options) + options_open;; + launch) + launch;; +esac diff --git a/.config/polybar/scripts/popup-calendar.sh b/.config/polybar/scripts/popup-calendar.sh new file mode 100755 index 0000000..4e5303c --- /dev/null +++ b/.config/polybar/scripts/popup-calendar.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +BAR_HEIGHT=22 # polybar height +BORDER_SIZE=1 # border size from your wm settings +YAD_WIDTH=222 # 222 is minimum possible value +YAD_HEIGHT=193 # 193 is minimum possible value +DATE="$(date +"%a %d %b, %H:%M")" + +case "$1" in +--popup) + if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then + exit 0 + fi + + eval "$(xdotool getmouselocation --shell)" + eval "$(xdotool getdisplaygeometry --shell)" + + # X + if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side + : $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE)) + elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side + : $((pos_x = BORDER_SIZE)) + else #Center + : $((pos_x = X - YAD_WIDTH / 2)) + fi + + # Y + if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom + : $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE)) + else #Top + : $((pos_y = BAR_HEIGHT + BORDER_SIZE)) + fi + + yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \ + --width="$YAD_WIDTH" --height="$YAD_HEIGHT" --posx="$pos_x" --posy="$pos_y" \ + --title="yad-calendar" --borders=0 >/dev/null & + ;; +*) + echo "$DATE" + ;; +esac diff --git a/.config/polybar/scripts/rofi-power.sh b/.config/polybar/scripts/rofi-power.sh new file mode 100755 index 0000000..87ac92c --- /dev/null +++ b/.config/polybar/scripts/rofi-power.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh +# +# A rofi powered menu to execute power related action. +# Uses: amixer mpc poweroff reboot rofi rofi-prompt + +power_off='' +reboot='' +lock='' +suspend='鈴' +log_out='' + +chosen=$(printf '%s;%s;%s;%s;%s\n' "$power_off" "$reboot" "$lock" "$suspend" \ + "$log_out" \ + | rofi -theme '~/.config/rofi/themes/power.rasi' \ + -dmenu \ + -sep ';' \ + -selected-row 2) + +case "$chosen" in + "$power_off") + rofi-prompt --query 'Shutdown?' && poweroff + ;; + + "$reboot") + rofi-prompt --query 'Reboot?' && reboot + ;; + + "$lock") + # TODO Add your lockscreen command. + ;; + + "$suspend") + # Pause music and mute volume before suspending. + mpc --quiet pause + amixer set Master mute + # TODO Add your suspend command. + ;; + + "$log_out") + # TODO Add your log out command. + ;; + + *) exit 1 ;; +esac + diff --git a/.config/polybar/scripts/scroll_spotify_status.sh b/.config/polybar/scripts/scroll_spotify_status.sh new file mode 100755 index 0000000..74e0bfd --- /dev/null +++ b/.config/polybar/scripts/scroll_spotify_status.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# see man zscroll for documentation of the following parameters +zscroll -l 20 \ + --delay 0.1 \ + --scroll-padding " " \ + --match-command "$HOME/.config/polybar/scripts/get_spotify_status.sh --status" \ + --match-text "Playing" "--scroll 1" \ + --match-text "Paused" "--scroll 0" \ + --update-check true "$HOME/.config/polybar/scripts/get_spotify_status.sh" & + +wait diff --git a/.config/polybar/scripts/sysmenu.sh b/.config/polybar/scripts/sysmenu.sh new file mode 100755 index 0000000..721bc1d --- /dev/null +++ b/.config/polybar/scripts/sysmenu.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# display a power menu to: shutdown, reboot, +# lock, logout, and suspend. This script can be +# executed by clicking on the polybar powermenu module +# or with a keyboard shortcut + + +# options to be displayed +shutdown=" Shutdown" +reboot=" Reboot" +lock=" Lock" +logout=" Logout" +suspend=" Suspend" + +uptime=$(uptime -p | sed -e 's/up //g') + +# options passed into variable +options="$shutdown\n$reboot\n$lock\n$logout\n$suspend" + +chosen="$(echo -e "$options" | rofi -no-lazy-grab -sep -lines 5 -hide-scrollbar true -border 0 -padding 0 -height 2px -width 15 -xoffset -8 -yoffset 28 -location 3 -columns 1 -dmenu -p 'System ' "$uptime")" + +case $chosen in +$shutdown) + systemctl poweroff + ;; +$reboot) + systemctl reboot + ;; +$lock) + betterlockscreen --lock dimblur + ;; +$logout) + bspc quit + ;; +$suspend) + systemctl suspend + ;; +esac + diff --git a/.config/polybar/scripts/sysmenu.shsave b/.config/polybar/scripts/sysmenu.shsave new file mode 100755 index 0000000..00ce125 --- /dev/null +++ b/.config/polybar/scripts/sysmenu.shsave @@ -0,0 +1,40 @@ +#!/bin/bash + +# display a power menu to: shutdown, reboot, +# lock, logout, and suspend. This script can be +# executed by clicking on the polybar powermenu module +# or with a keyboard shortcut + + +# options to be displayed +shutdown=" Shutdown" +reboot=" Reboot" +lock=" Lock" +logout=" Logout" +suspend=" Suspend" + +uptime=$(uptime -p | sed -e 's/up //g') + +# options passed into variable +options="$shutdown\n$reboot\n$lock\n$logout\n$suspend" + +chosen="$(echo -e "$options" | rofi -no-lazy-grab -sep -lines 5 -hide-scrollbar true -border 0 -padding 0 -height 2px -width 15 -xoffset -10 -yoffset 28 -location 3 -columns 1 -dmenu -p 'System ' "$uptime")" + +case $chosen in +$shutdown) + systemctl poweroff + ;; +$reboot) + systemctl reboot + ;; +$lock) + betterlockscreen --lock dimblur + ;; +$logout) + bspc quit + ;; +$suspend) + systemctl suspend + ;; +esac + diff --git a/.config/polybar/scripts/system-usb-mount.sh b/.config/polybar/scripts/system-usb-mount.sh new file mode 100755 index 0000000..63e9187 --- /dev/null +++ b/.config/polybar/scripts/system-usb-mount.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +devices=$(lsblk -Jplno NAME,TYPE,RM,SIZE,MOUNTPOINT,VENDOR) + +case "$1" in + --mount) + for mount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do + udisksctl mount --no-user-interaction -b "$mount" + + mountpoint=$(udisksctl mount --no-user-interaction -b $mount) + mountpoint=$(echo $mountpoint | cut -d " " -f 4- | tr -d ".") + kitty -e "bash -lc 'pcmanfm $mountpoint'" & + done + ;; + --unmount) + for unmount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .name'); do + udisksctl unmount --no-user-interaction -b "$unmount" + udisksctl power-off --no-user-interaction -b "$unmount" + done + ;; + *) + output="" + counter=0 + + for unmounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do + unmounted=$(echo "$unmounted" | tr -d "[:digit:]") + unmounted=$(echo "$devices" | jq -r '.blockdevices[] | select(.name == "'"$unmounted"'") | .vendor') + unmounted=$(echo "$unmounted" | tr -d ' ') + + if [ $counter -eq 0 ]; then + space="" + else + space=" " + fi + counter=$((counter + 1)) + + output="$output$space#1 $unmounted" + done + + for mounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .size'); do + if [ $counter -eq 0 ]; then + space="" + else + space=" " + fi + counter=$((counter + 1)) + + output="$output$space#2 $mounted" + done + + echo "$output" + ;; +esac diff --git a/.config/polybar/scripts/toggle_bluetooth.sh b/.config/polybar/scripts/toggle_bluetooth.sh new file mode 100755 index 0000000..899d5ec --- /dev/null +++ b/.config/polybar/scripts/toggle_bluetooth.sh @@ -0,0 +1,8 @@ +#!/bin/sh +if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] +then + bluetoothctl power on +else + bluetoothctl power off +fi + diff --git a/.config/pypoetry/config.toml b/.config/pypoetry/config.toml new file mode 100644 index 0000000..53b35d3 --- /dev/null +++ b/.config/pypoetry/config.toml @@ -0,0 +1,3 @@ +[virtualenvs] +create = true +in-project = true diff --git a/.config/sxhkd/show_help.sh b/.config/sxhkd/show_help.sh new file mode 100755 index 0000000..bd0cd6c --- /dev/null +++ b/.config/sxhkd/show_help.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cat ~/.config/sxhkd/sxhkdrc | awk '/^[a-z]/ && last {print $0,"\t",last} {last=""} /^#/{last=$0}' | column -t -s $'\t' | rofi -dmenu -i -no-show-icons -width 1000 + diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc new file mode 100755 index 0000000..0cc0023 --- /dev/null +++ b/.config/sxhkd/sxhkdrc @@ -0,0 +1,412 @@ +# __ __ __ +# /\ \ /\ \ /\ \ +# ____ __ _\ \ \___\ \ \/'\ \_\ \ +# /',__\/\ \/'\\ \ _ `\ \ , < /'_` \ +#/\__, `\/> </ \ \ \ \ \ \ \\`\ /\ \L\ \ +#\/\____//\_/\_\ \ \_\ \_\ \_\ \_\ \___,_\ +# \/___/ \//\/_/ \/_/\/_/\/_/\/_/\/__,_ / +# + +#--------------------------------------------------------------- +# +# WM independent hotkeys +# + +# Help +super + F1 + ~/.config/sxhkd/show_help.sh -m -3 + +# Application menu +super + a + ~/.config/polybar/scripts/menu.sh + +# Shutdown menu +#super + alt + Delete +# ~/.config/polybar/scripts/sysmenu.sh + +# lockscreen +super + Escape + betterlockscreen --lock blur + +# Program launcher +super + @space + rofi -show drun + +# Run launcher (commands) +super + r + rofi -show run + +# Task switcher +alt + Tab + rofi -show window + +# Turn off compositor +super + shift + p + toggleprogram "picom" "--experimental-backends" + +#picom-trans -c -10 +#picom-trans -c +10 + +# Launch eww +#super + ctrl + a +# ~/.config/eww/launch_widgets.sh + +# Terminal emulator +#super + Return +# $TERMINAL + +# Browser +super + w + $BROWSER + +# Show clipmenu +#alt + x +# parcellite + #~/.local/bin/scripts/clip.sh + +# Screenshots tool (selection) +ctrl + Print + flameshot gui -p ~/pictures/screenshots + +# Screenshots tool (screen) +shift + Print + flameshot full -p ~/pictures/screenshots + +# make sxhkd reload its configuration files: +super + ctrl + x + pkill -USR1 -x sxhkd; dunstify "Sxhkd configuration reloaded" + + + +#--------------------------------------------------------------- +# +# bspwm hotkeys +# + +# Quit/restart bspwm +super + alt + shift + {q,r} + bspc {quit,wm -r} + +# Close and kill +super + d + bspc node -c + +# Alternate between the tiled and monocle layout +super + m + bspc desktop -l next +super + z + bspc desktop -l next + +# Send the newest marked node to the newest preselected node +super + y + bspc node newest.marked.local -n newest.!automatic.local + +# Swap the current node and the biggest window +super + g + bspc node -s biggest.window + + +#--------------------------------------------------------------- +# +# state/flags +# + +# Set the window state +#super + {t,shift + t,s,f} +# bspc node -t {tiled,pseudo_tiled,floating,fullscreen} + +# Floating into monocle layout +super + shift + m + bspc node -t pseudo_tiled; bspc node -t floating && wtp 10 40 1342 716 "$(pfw)" + +# Set the window state +super + {t,shift + t,s} + bspc node -t {tiled,pseudo_tiled,floating}; \ + xdo raise -N Plank; \ + xdo raise -N '*:*:Picture in picture'; \ + xdo raise -N "Picture-in-Picture" + +# Toggle fullscreen +super + {f} + bspc node -t \~fullscreen + +# Toggle sticky +#super + q +# bspc node -g sticky=on + +# Set the node flags +super + ctrl + {m,x,y,z} + bspc node -g {marked,locked,sticky,private} + +# Move layers of windows above/below each other (script) +super + {equal,minus} + layer.sh {+,-} + + +#--------------------------------------------------------------- +# +# Focus/Swap +# + +# Focus the node in the given direction +super + {_,shift + }{h,j,k,l} + bspc node -{f,s} {west,south,north,east} + +# Focus the node for the given path jump +#super + {p,b,comma,period} +# bspc node -f @{parent,brother,first,second} + +# Focus the next/previous window in the current desktop +super + {_,shift + }c + bspc node -f {next,prev}.local.!hidden.window + +# Focus the next/previous desktop in the current monitor +super + bracket{left,right} + bspc desktop -f {prev,next}.local + +# Focus the last node/desktop +super + {grave,Tab} + bspc {node,desktop} -f last + +# Focus the older or newer node in the focus history +#super + {o,i} +# bspc wm -h off; \ +# bspc node {older,newer} -f; \ +# bspc wm -h on + +# Focus or send to the given desktop +super + {_,shift + }{1-9,0} + bspc {desktop -f,node -d} '^{1-9,10}' + +# Hide window +super + comma + bspc node -g hidden + +# Unhide window (script) +super + period + ${HOME}/.config/bspwm/bspcmd unhide + +# Toggle the hidden state of the focused node +super + q + ~/.local/bin/scripts/bspwm-toggle-visibility.sh + +#--------------------------------------------------------------- +# +# Preselect +# + +# Preselect the direction +super + ctrl + {h,j,k,l} + bspc node -p {west,south,north,east} + +# Preselect the ratio +super + ctrl + {1-9} + bspc node -o 0.{1-9} + +# Cancel the preselection for the focused node +super + ctrl + space + bspc node -p cancel + +# Cancel the preselection for the focused desktop +super + ctrl + shift + space + bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel + +# Close all receptacle +super + shift + i + for win in `bspc query -N -n .leaf.\!window`; do bspc node $win -k ; done; + +# Insert receptacle +super + i; {h,j,k,l} + bspc node --presel-dir {west,south,north,east} -i + +# Move to rectacle +super + ctrl + i + bspreceptacle + +# Balance nodes +super + alt + i + bspc node @/ -B + + + +#--------------------------------------------------------------- +# +# Move/resize +# + +# Move a floating window or swap with any other adjacent tiled/pseudo_tiled window +ctrl + alt + {h,j,k,l} + { dir=west dx=-20 dy=0 \ + , dir=south dx=0 dy=20 \ + , dir=north dx=0 dy=-20 \ + , dir=east dx=20 dy=0 \ + }; \ + bspc node --move "$dx" "$dy" || bspc node --swap $dir + +# Move a tiled window to any direction +super + shift + {h,j,k,l} + /path/to/bspwm_smart_move {west,south,north,east} + +# Rotate windows to different nodes +super + ctrl + r + bspc node @parent -R 90 + +# Resize tiled/floating windows (script) +shift + alt + {h,j,k,l} + bspwm_resize.sh {west,south,north,east} + +# Resize window into predefined pseudo_tiled window +super + shift + s + bspc node -t pseudo_tiled; bspc node -t floating && wtp 396 185 570 394 "$(pfw)" + +# Spawn next window/program into predefined floating window +super + ctrl + s + bspc rule -a '*' -o state=floating rectangle=720x480+320+200 + +# Spawn next window/program into predefined smaller Heads-Up-Display like floating window +#ctrl + alt + 2 +# bspc rule -a '*' -o state=floating rectangle=320x140+1030+32 + +# Spawn next window/program into another desktop +super + alt + {1-9,0} + bspc rule -a '*' -o desktop=^{1-9,10} + + +#--------------------------------------------------------------- +# +# Multimedia +# +# Multimedia control +{XF86AudioStop,XF86AudioPlay,XF86AudioPrev,XF86AudioNext} + playerctl {stop,play-pause,previous,next} + +# Use arrow keys as multimedia keys +alt + shift + {Left,Up,Right} + playerctl {previous,play-pause,next} + +# Brightness control +XF86MonBrightness{Up,Down} + brightnessctl s 5%{+,-} + +# Use arrow keys as brightness keys +alt + {Up,Down} + brightnessctl s 5%{+,-} + +# Volume control +XF86Audio{Raise,Lower}Volume + pulsemixer --change-volume {+,-}5 + +# Use arrow keys as volume keys +alt + {Right,Left} + pulsemixer --change-volume {+,-}5 + + +#--------------------------------------------------------------- +# +# Xdotool keys +# + +# Move mouse cursor north, west, south, east +alt + {w,a,s,d} + xdotool mousemove_relative --sync {-- 0 -24, -- -24 0, 0 24, 24 0} + +# Move mouse cursor diagonally north-west, north-east, south-west, south-east +shift + alt + {q,e,a,d} + xdotool mousemove_relative --sync {-- -24 -24, -- 24 -24, -- -24 24,-- 24 24} + +# Emulate left mouse click +alt + i + xdotool click --clearmodifiers 1 + +# Emulate left mouse click select +alt + shift + i + xdotool mousedown 1 sleep 0.5 mousemove_relative --sync {-- -8 0, 0 8, -- 0 -8, 8 0} sleep 0.5 mouseup 1 + +# Emulate mouse right click +alt + o + xdotool click --clearmodifiers 3 + +# Emulate mouse scroll up +alt + n + xdotool click --clearmodifiers 4 + +# Emulate mouse scroll down +alt + m + xdotool click --clearmodifiers 5 + +# Emulate mouse scroll button +alt + p + xdotool click --clearmodifiers 2 + +# Emulate home key +alt + ctrl + Left + xdotool keyup Left key --clearmodifiers Home + +# Emulate end key +alt + ctrl + Right + xdotool keyup Right key --clearmodifiers End + +# Emulate delete key +~alt + BackSpace + xte 'keyup Alt_L' 'key Delete' 'keydown Alt_L' + + +#--------------------------------------------------------------- +# +# Programs +# + +# Scratchpd +super + semicolon + ~/.local/bin/scripts/scratchpad + +super + x + ~/.local/bin/scripts/scratchpad + +# Heads-Up-Display scratchpad terminal +super + e + ~/.local/bin/scripts/Heads-Up-Display + +# File manager nnn +super + shift + n + $TERMINAL -e nnn + +# File manager pcmanfm (GUI) +super + shift + f + pcmanfm + +# Bitwarden-rofi +super + shift + b + rofi-rbw + +# Thunderbird mail +#super + shift + m +# thunderbird + +# VirtualBox gui +super + v + /usr/bin/VirtualBox -- :0 vt1 + +# Discord +super + shift + d + discord + +# Spotify +super + shift + y + spotify + +# Book reader (zathura) +super + shift + z + zathura + +# Dictionary +super + ctrl + w + goldendict + +# Thesaurus +super + shift + w + artha + +# Suspend +alt + F4 + systemctl suspend && betterlockscreen --lock dimblur diff --git a/.config/tmux/left-status.sh b/.config/tmux/left-status.sh new file mode 100755 index 0000000..e4a8c49 --- /dev/null +++ b/.config/tmux/left-status.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +function ip-address() { + # Loop through the interfaces and check for the interface that is up. + for file in /sys/class/net/*; do + iface=$(basename $file); + read status < $file/operstate; + [ "$status" == "up" ] && ip addr show $iface | awk '/inet /{printf $2""}' + done +} + +function vpn-connection() { + # Check for tun0 interface. + [ -d /sys/class/net/tun0 ] && printf "%s " 'VPN*' +} + +function main() { + # Comment out any function you do not need. + ip-address + vpn-connection +} + +# Calling the main function which will call the other functions. +main + diff --git a/.config/tmux/right-status.sh b/.config/tmux/right-status.sh new file mode 100755 index 0000000..a14bbe3 --- /dev/null +++ b/.config/tmux/right-status.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Get CPU average +getCPU=$[100-$(vmstat 1 2|tail -1|awk '{print $15}')] + +# Grab the second line of the ouput produced by the command: free -g (displays output in Gb) +getMem=$(free -h | sed -n '2p') +getMemPct=$(free -g | sed -n '2p') + +# Split the string in secondLine into an array +read -ra ADDR <<< "$getMem" +read -ra ADDRPct <<< "$getMemPct" + +# Get the total RAM from arrays +totalRam="${ADDR[1]//[^0-9.0-9]/}" +totalRamPct="${ADDRPct[1]}" + +# Get the used RAM from arrays +usedRam="${ADDR[2]//[^0-9.0-9]/}" +usedRamPct="${ADDRPct[2]}" + +# Calculate and display the percentages +pct="$(($usedRamPct*100/$totalRamPct))" +usage="$usedRam/$totalRam" +#echo "cpu:$getCPU% | mem:$pct% ($usage""G)" +echo "Cpu:$getCPU% | Mem:$pct% |" + diff --git a/.config/tmux/tmux-toggle-option.sh b/.config/tmux/tmux-toggle-option.sh new file mode 100755 index 0000000..52d5fdb --- /dev/null +++ b/.config/tmux/tmux-toggle-option.sh @@ -0,0 +1,27 @@ +#!/usr/bin/bash + +#USAGE="USAGE: $0 OPTION_NAME ON_STATE OFF_STATE" + +#OPTION_NAME=$1 +#ON_STATE=$2 +#OFF_STATE=$3 +# +#if [[ "$#" != 3 ]]; then +# echo $USAGE +# exit 1 +#fi +# +#if [[ `tmux show-option -w | grep "$OPTION_NAME $ON_STATE"` ]]; then +# OPTION_VALUE=$OFF_STATE +#else +# OPTION_VALUE=$ON_STATE +#fi +# +#tmux display-message "monitor activity: $OPTION_NAME $OPTION_VALUE" +#tmux set-option -w $OPTION_NAME $OPTION_VALUE > /dev/null + +if [ $(tmux show-option -A status-left) != 'status-left* "#[fg=#50fa7b,bg=default] #[bg=#50fa7b,fg=black]❐ #S #[fg=#50fa7b,bg=default]"' ]; then + tmux set -g status-left "#[fg=#50fa7b,bg=default] #[bg=#50fa7b,fg=black]❐ #S #[fg=#50fa7b,bg=default] "; +else + tmux set -g status-left "#[fg=#50fa7b,bg=default]#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" && tmux set -g status-right "#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,}#[bg=default,fg=#50fa7b]#[bg=#50fa7b,fg=black] #( ~/.config/tmux/right-status.sh ) %d-%b-%y | %H:%M #[bg=default,fg=#50fa7b]"; +fi diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf new file mode 100644 index 0000000..a731ff1 --- /dev/null +++ b/.config/tmux/tmux.conf @@ -0,0 +1,312 @@ +# ████████╗███╗ ███╗██╗ ██╗██╗ ██╗ +# ╚══██╔══╝████╗ ████║██║ ██║╚██╗██╔╝ +# ██║ ██╔████╔██║██║ ██║ ╚███╔╝ +# ██║ ██║╚██╔╝██║██║ ██║ ██╔██╗ +# ██║ ██║ ╚═╝ ██║╚██████╔╝██╔╝ ██╗ +# ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ +#―――――――――――――――――――――――――――――――――――――――――― + +### Options ### + +# Setting the Prefix from Ctrl+b to Ctrl+s +unbind C-b +set -g prefix C-s +#set -g prefix M-Space + +# Ensure that we can send Ctrl+s to other apps +bind C-s send-prefix + +# send the prefix to client inside window +bind-key -n C-a send-prefix + +# Disable local tmux keys (nested tmux) +bind -T root F12 \ + set prefix None \;\ + set key-table off \;\ + if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ + refresh-client -S \;\ + +bind -T off F12 \ + set -u prefix \;\ + set -u key-table \;\ + refresh-client -S + +# Setting the delay between Prefix and Command +set -sg escape-time 10 +#set-option -sg escape-time 10 + +# Reload tmux with <Prefix>r +#bind r source-file ~/.tmux.conf \; display "Reloaded!" +bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!" + +# Use <Prefix>Ctrl+l to clear terminal +bind C-l send-keys 'C-l' + +# Mouse +set -g mouse on +#set -g mouse-select-pane on +#set -g mouse-resize-pane on +#set -g mouse-select-window on + +# Scrollback +#set -g history-limit 10000 + +# Sane scrolling +set -g terminal-overrides 'xterm*:smcup@:rmcup@' + +# Shift up/down copy-mode without prefix +bind-key -n S-Up copy-mode \; send-key Up +bind-key -n S-Down copy-mode \; send-key Down +bind-key -n Pageup copy-mode \; send-key Pageup +bind-key -n Pagedown copy-mode \; send-key Pagedown +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +#bind -n M-k if-shell "$is_vim" "send-keys Pageup" "copy-mode -u" +bind -n Pageup if-shell "$is_vim" "send-keys Pageup" "copy-mode -u" +bind -n S-Pageup if-shell "$is_vim" "send-keys Pageup" "copy-mode -u" +bind -n S-Pagedown send-keys Pagedown +#bind -n M-j send-keys Pagedown + +# Focus events, allow supported requests from applications to passthrough/run in tmux +set-option -g focus-events on + +# Update the TERM variable of terminal emulator when creating a new session or attaching a existing session +set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM' + + +#―――――――――――――――――――――――――――――――――――――――――― + +### Window Movement/Control ### + +# Aggressive resizing, useful when using "grouped sessions" and multi-monitor setup +setw -g aggressive-resize on + +# Popup scratch session +#bind -n M-g display-popup -E "tmux new-session -A -s scratch" + +# Toggle popup scratch session +bind-key -n M-g if-shell -F '#{==:#{session_name},note}' { +detach-client +} { +display-popup -E "tmux new-session -A -s note" +} + +# Non-popup +#bind C-k new-window -n "session-switcher" "\ +# tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ +# sed '/^$/d' |\ +# fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ +# xargs tmux switch-client -t" + +# Popup +bind -n M-f display-popup -E "\ + tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ + sed '/^$/d' |\ + fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ + xargs tmux switch-client -t" + +# Quick window select +bind -n M-? list-keys +bind -n M-1 select-window -t :=1 +bind -n M-2 select-window -t :=2 +bind -n M-3 select-window -t :=3 +bind -n M-4 select-window -t :=4 +bind -n M-5 select-window -t :=5 +bind -n M-6 select-window -t :=6 +bind -n M-7 select-window -t :=7 +bind -n M-8 select-window -t :=8 +bind -n M-9 select-window -t :=9 +bind -n M-0 select-window -t :=0 + + +#―――――――――――――――――――――――――――――――――――――――――― + +### Pane Movement/Control ### + +# Smart pane switching with awareness of Vim splits. +# See: https://github.com/christoomey/vim-tmux-navigator +is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'" + +bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' +bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' +bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' +bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' + +tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' +if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" +if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" + +# Copy Mode vi-directional keys +bind-key -T copy-mode-vi 'C-h' select-pane -L +bind-key -T copy-mode-vi 'C-j' select-pane -D +bind-key -T copy-mode-vi 'C-k' select-pane -U +bind-key -T copy-mode-vi 'C-l' select-pane -R +bind-key -T copy-mode-vi 'C-\' select-pane -l + +# Change horizontal split <Prefix>% and Vertical split <Prefix>" to <Prefix>h and <Prefix>v respectively and change current working directory +bind v split-window -h -c "#{pane_current_path}" +bind h split-window -v -c "#{pane_current_path}" + +# Pane resizing, <Prefix> then shift + vi-directional keys, default is D,U,L,R +bind -r H resize-pane -L 20 +bind -r J resize-pane -D 20 +bind -r K resize-pane -U 20 +bind -r L resize-pane -R 20 + +# Pane resizing, <Prefix> then alt + vi-directional keys +bind-key M-j resize-pane -D 5 +bind-key M-k resize-pane -U 5 +bind-key M-h resize-pane -L 5 +bind-key M-l resize-pane -R 5 + +# Hide a pane and bring it back with <Prefix>! and <Prefix>@ respectively +bind-key ! break-pane -d -n _hidden_pane +bind-key @ join-pane -s $.0 + +# Send Pane to another session/window +bind-key j command-prompt -p "send pane to:" "join-pane -t '%%'" + + +#―――――――――――――――――――――――――――――――――――――――――― + +### Copy Mode (Copy/Paste) ### + +# Set Vi copy mode, use <prefix>[ to enter copy mode +setw -g mode-keys vi # `<prefix>:list-keys -T copy-mode-vi` to confirm + +# Change selection <space> and enter to vi keybinding +bind-key -T copy-mode-vi 'v' send -X begin-selection +bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel + +# Copy to system clipboard (requires xclip) +if-shell -b 'echo $XDG_SESSION_TYPE | grep -q x11' "\ + bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \ + bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \ + bind-key C-M-v run 'xclip -out -selection clipboard | tmux load-buffer - ; tmux paste-buffer'" + +# Wayland support +if-shell -b 'echo $XDG_SESSION_TYPE | grep -q wayland' "\ + bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'wl-copy'; \ + bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'wl-copy'; \ + bind-key C-p run 'wl-paste --no-newline | tmux load-buffer - ; tmux paste-buffer'" "\ + \ + bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \ + bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \ + bind-key C-M-v run 'cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer'" + +# + +### Colors ### + +# Set 256 color terminal +set-option -sa terminal-overrides ",tmux-256color:Tc" +#set-option -sa terminal-overrides ",xterm*:Tc,alacritty*:Tc" + +# Colors for pane borders(default) +setw -g pane-border-style fg=white +setw -g pane-active-border-style fg=green + +# Active pane normal, other shaded out +setw -g window-style fg=colour240 +setw -g window-active-style fg=white + + +# + +### Status ### + +set -g status-position bottom # [top, bottom] +set -g status on +#set -g status-interval 1 +set -g status-interval 500 +set -g status-style fg=#50fa7b,bg=default + +## Left +#set -g status-left "" +set -g status-left-length 60 +#set -g status-left "#[fg=#50fa7b,bg=default]#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" +set -g status-left "#(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=#39BAE6]#[bg=default]#[bg=#39BAE6,fg=black] ❐ #S #[fg=#39BAE6,bg=default]\"} /-- INSERT --/ {print \"#[fg=#50fa7b]#[bg=default]#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]\"}')" + +## Centre +#set -g window-status-current-format "#[bg=default,fg=#50fa7b]#[fg=black,bg=#50fa7b] #I:#W #[bg=default,fg=#50fa7b]" +set -g window-status-current-format "#(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=#39BAE6]#[bg=default]#[fg=black,bg=#39BAE6] #I:#W #[bg=default,fg=#39BAE6]\"} /-- INSERT --/ {print \"#[fg=#50fa7b]#[bg=default]#[fg=black,bg=#50fa7b] #I:#W #[bg=default,fg=#50fa7b]\"}')" +set -g status-justify absolute-centre + +## Right +set-option -g status-right "" +set -g status-right-length 60 +#set -g status-right "#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[bg=default,fg=#50fa7b]#[bg=#50fa7b,fg=black] %H:%M #[bg=default,fg=#50fa7b]" +local_keys_off="#[fg=#50fa7b,bg=default]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]" +set -g status-right "$local_keys_off #(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[fg=#39BAE6]#[bg=default]#[bg=#39BAE6,fg=black] %H:%M #[bg=default,fg=#39BAE6]\"} /-- INSERT --/ {print \"#[fg=#39BAE6,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[fg=#50fa7b]#[bg=default]#[bg=#50fa7b,fg=black] %H:%M #[bg=default,fg=#50fa7b]\"}')" + +#set -g status-right "#[fg=white,bg=black]#(cat ~/.vi-mode)" +#set -g status-right "#[fg=white,bg=black]#(cat ~/.vi-mode | awk '/-- NORMAL --/ {print \"#[fg=blue]#[bg=black]-- NORMAL --\"} /-- INSERT --/ {print \"#[fg=green]#[bg=black]-- INSERT --\"}')" + +## Reload Status with IP addr, Cpu, Mem and Date +bind a run-shell ~/.config/tmux/tmux-toggle-option.sh + +## Reload Config/Status silently +bind b source-file ~/.config/tmux/tmux.conf + +set-option -g default-shell "/usr/bin/zsh" + + +#―――――――――――――――――――――――――――――――――――――――――― + +### Plugin Install ### + +set -g @plugin "tmux-plugins/tpm" +#set -g @plugin "tmux-plugins/tmux-sensible" +set -g @plugin "tmux-plugins/tmux-resurrect" +set -g @plugin "tmux-plugins/tmux-continuum" +set -g @plugin "christoomey/vim-tmux-navigator" +#set -g @plugin "tmux-plugins/tmux-yank" +#set -g @plugin 'srdusr/tmux-vi-mode' +#set -g @plugin 'vi-mode ~/.config/tmux/plugins/vi-mode.sh' + + +#―――――――――――――――――――――――――――――――――――――――――― + +### Plugins Settings ### + +# Plugin to save and restore tmux sessions after restart +# * Save with: <Prefix> + Ctrl-s +# * Restore with: <Prefix> + Ctlr-r +# Change default save and restore keybindings + set -g @resurrect-save "W" # <Prefix> + W + set -g @resurrect-restore "E" # <Prefix> + E + +# Restore vim and nvim sessions as well +# For vim: + set -g @resurrect-strategy-vim "session" +# For neovim: + set -g @resurrect-strategy-nvim "session" + +# Automatic restore + #set -g @continuum-restore "on" + #set -g @continuum-boot "on" + +# Restore Panes + set -g @resurrect-capture-pane-contents "on" + +# This is a hook for tmux-resurrect which tells it to kill session 0 before restoring the panels + set -g @resurrect-hook-pre-restore-pane-processes "tmux switch-client -n && tmux kill-session -t=0" + +# Plugin uninstall + # Delete or comment out the plugin in .tmux.conf. + # Press <prefix> + alt + u to remove the plugin. + +# TMUX plugin manager (keep at the bottom of tmux.conf) + #run "~/.config/tmux/plugins/tpm/tpm" + if "test ! -d ~/.config/tmux/plugins/tpm" \ + "run 'git clone https://github.com/tmux-plugins/tpm ~/.config/tmux/plugins/tpm && ~/.config/tmux/plugins/tpm/bin/install_plugins'" +run -b "~/.config/tmux/plugins/tpm/tpm" +# Load the vi-mode plugin + +#run-shell '~/.config/tmux/plugins/tmux-vi-mode/tmux-vi-mode.tmux' +#run-shell '~/.config/tmux/vi-mode' +# Load the vi-mode plugin +#run '~/.config/tmux/plugins/tpm/plugins/tmux-vi-mode/tmux-vi-mode.tmux' +#―――――――――――――――――――――――――――――――――――――――――― diff --git a/.config/user-dirs.dirs b/.config/user-dirs.dirs new file mode 100644 index 0000000..0db0cae --- /dev/null +++ b/.config/user-dirs.dirs @@ -0,0 +1,15 @@ +# This file is written by xdg-user-dirs-update +# If you want to change or add directories, just edit the line you're +# interested in. All local changes will be retained on the next run. +# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped +# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an +# absolute path. No other format is supported. +# +XDG_DESKTOP_DIR="$HOME/" +XDG_DOWNLOAD_DIR="$HOME/downloads" +XDG_TEMPLATES_DIR="$HOME/" +XDG_PUBLICSHARE_DIR="$HOME/" +XDG_DOCUMENTS_DIR="$HOME/documents" +XDG_MUSIC_DIR="$HOME/music" +XDG_PICTURES_DIR="$HOME/pictures" +XDG_VIDEOS_DIR="$HOME/videos" diff --git a/.config/user-dirs.locale b/.config/user-dirs.locale new file mode 100644 index 0000000..3e0b419 --- /dev/null +++ b/.config/user-dirs.locale @@ -0,0 +1 @@ +en_US
\ No newline at end of file diff --git a/.config/waybar/config.jsonc b/.config/waybar/config.jsonc new file mode 100644 index 0000000..dbf6556 --- /dev/null +++ b/.config/waybar/config.jsonc @@ -0,0 +1,292 @@ +{ + "layer": "top", // Waybar at top layer + "position": "top", // Waybar position (top|bottom|left|right) + //"gtk-layer-shell": "false", + "height": 45, // Waybar height (to be removed for auto height) + // "width": 2560, // Waybar width + "spacing": 0, // Gaps between modules (0px) Adjusted in the css + "margin-top": 0, + //"margin-bottom":-10, + "margin-left": 10, + "margin-right": 10, + // Choose the order of the modules + "modules-left": [ + "custom/launcher", + "wlr/workspaces", + "cpu", + "memory", + "temperature", + "disk", + "custom/updates" + ], + "modules-center": [ + "custom/music" + ], + "modules-right": [ + "network", + "pulseaudio", + "backlight", + "battery", + "custom/notifications", + "tray", + "clock", + "custom/weather", + "custom/cycle_wall", + "custom/clipboard", + "custom/power", + "custom/custom" + ], + "custom/launcher": { + "format": "{}", + "tooltip": true, + "exec": "echo '{\"text\":\"💧\",\"tooltip\":\"Drun | Run\"}'", + "return-type": "json", + "on-click": "pkill wofi || wofi --show drun -n", + "on-click-right": "pkill wofi || wofi --show run -n", + }, + "wlr/workspaces": { + // "format": "{icon} {name}", + "format": "", + "format-icons": { + "active": "", + "default": "" + }, + "on-scroll-up": "hyprctl dispatch workspace e-1", + "on-scroll-down": "hyprctl dispatch workspace e+1", + "on-click": "activate" + }, + "cpu": { + "format": " {usage}%", + "tooltip": true, + "on-click": "kitty --start-as=fullscreen --title all_is_kitty sh -c 'btop'", + "interval": 2 + }, + "memory": { + "format": " {}%", + "tooltip": true, + "on-click": "kitty --start-as=fullscreen --title all_is_kitty sh -c 'btop'", + "interval": 2 + }, + "temperature": { + // "thermal-zone": 2, + // "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input", + "critical-threshold": 40, + "format-critical": "{icon} {temperatureC}°C", + "format": "{icon} {temperatureC}°C", + "format-icons": [ + "", + "", + "" + ], + "tooltip": true, + "on-click": "kitty --start-as=fullscreen --title all_is_kitty sh -c 'btop'", + "interval": 2 + }, + "disk": { + "format": " {percentage_used}% ({free})", + "tooltip": true, + "on-click": "kitty --start-as=fullscreen --title all_is_kitty sh -c 'btop'", + "interval": 2 + }, + "custom/updates": { + "format": "{}", + "exec": "~/.scripts/updates", + "on-click": "~/.scripts/updates update", + "interval": 300, + "tooltip": true, + // "tooltip-format": "{}", + // "exec-tooltip": "~/.scripts/updates tooltip" + }, + "custom/music": { + "format": "{icon}{}", + "format-icons": { + // "Playing": " ", // Uncomment if not using the dynamic script + "Paused": " ", + "Stopped": "‭ﭥ " // This stop symbol is RTL. So ‭ is left-to-right override. + }, + "escape": true, + "tooltip": true, + "exec": "~/.scripts/caway -b 10", + "return-type": "json", + "on-click": "playerctl play-pause", + "on-scroll-up": "playerctl previous", + "on-scroll-down": "playerctl next", + "on-click-right": "g4music", + "max-length": 35 + }, + "hyprland/window": { + "format": "{}", + "separate-outputs": true, + "max-length": 35 + }, + "network": { + // "interface": "wlp2*", // (Optional) To force the use of this interface + "format": "↕{bandwidthTotalBytes}", + "format-disconnected": "{icon} No Internet", + "format-linked": " {ifname} (No IP)", + "format-alt": "↕{bandwidthUpBytes} | ↕{bandwidthDownBytes}", + "tooltip-format": "{ifname}: {ipaddr}/{cidr} {gwaddr}", + "tooltip-format-wifi": "{icon} {essid} ({signalStrength}%)", + "tooltip-format-ethernet": "{icon} {ipaddr}/{cidr}", + "tooltip-format-disconnected": "{icon} Disconnected", + "on-click-right": "nm-connection-editor", + "format-icons": { + "ethernet": "", + "disconnected": "⚠", + "wifi": [ + "睊", + "直" + ] + }, + "interval": 2 + }, + "pulseaudio": { + // "scroll-step": 1, // %, can be a float + "format": "{icon} {volume}%", // {format_source} + "format-bluetooth": "{icon} {volume}%", // {format_source} + "format-bluetooth-muted": "", // {format_source} + "format-muted": "", // {format_source} + "format-source": "{volume}% ", + "format-source-muted": "", + "format-icons": { + "headphone": "", + "headset": "", + "phone": "", + "portable": "", + "car": " ", + "default": [ + "", + "", + "" + ] + }, + "on-click": "pavucontrol" + }, + "backlight": { + // "device": "acpi_video1", + "format": "{icon} {percent}%", + "format-icons": [ + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "on-scroll-up": "light -A 1", + "on-scroll-down": "light -U 1", + "interval": 2 + }, + "battery": { + "states": { + "good": 100, + "warning": 30, + "critical": 10 + }, + "format": "{icon} {capacity}%", + "format-charging": " {capacity}%", + "format-plugged": " {capacity}%", + "format-alt": "{icon} {time}", + // "format-good": "", // An empty format will hide the module + "format-full": " {capacity}%", + "format-icons": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "interval": 2 + }, + "custom/notifications": { + "tooltip": false, + "format": "{icon}", + "format-icons": { + "notification": "<span foreground='red'><sup></sup></span>", + "none": "", + "dnd-notification": "<span foreground='red'><sup></sup></span>", + "dnd-none": "" + }, + "return-type": "json", + "exec-if": "which swaync-client", + "exec": "swaync-client -swb", + "on-click": "swaync-client -t -sw", + "on-click-right": "swaync-client -d -sw", + "escape": true + }, + "tray": { + "icon-size": 15, + "spacing": 15 + }, + "clock": { + "timezone": "Asia/Calcutta", + "format": " {:%d <small>%a</small> %H:%M}", + //"format": " {:%a %b %d %Y | %H:%M}", + "format-alt": " {:%A %B %d %Y (%V) | %r}", + "tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>", + "calendar-weeks-pos": "right", + "today-format": "<span color='#f38ba8'><b><u>{}</u></b></span>", + "format-calendar": "<span color='#f2cdcd'><b>{}</b></span>", + "format-calendar-weeks": "<span color='#94e2d5'><b>W{:%U}</b></span>", + "format-calendar-weekdays": "<span color='#f9e2af'><b>{}</b></span>", + "interval": 60 + }, + "idle_inhibitor": { + "format": "{icon}", + "format-icons": { + "activated": "", + "deactivated": "" + } + }, + "custom/weather": { + "tooltip": true, + "format": "{}", + "exec": "~/.scripts/tools/expand weather", + "return-type": "json" + }, + "custom/ss": { + "format": "{}", + "exec": "~/./scripts/tools/expand ss-icon", + "return-type": "json", + "on-click": "~/.scripts/screenshot_full" + }, + "custom/cycle_wall": { + "format": "{}", + "exec": "~/.scripts/tools/expand wall", + "return-type": "json", + // "interval": 1, + "on-click": "~/.scripts/tools/expand cycle", + "on-click-right": "~/.scripts/tools/expand cycler" + }, + "custom/clipboard": { + "format": "{}", + "exec": "~/.scripts/tools/expand clipboard", + "return-type": "json", + // Here "-l top_right -x -15 -y 10" doesn't matter as '-n' mode is used + // Window position is managed in Hyperland config's windowrulev2 + "on-click": "pkill wofi || cliphist list | wofi --dmenu -p clippick -l top_right -x -15 -y 10 -n | cliphist decode | wl-copy", + "on-click-middle": "rm -f ~/.cache/cliphist/db", + "on-click-right": "pkill wofi || cliphist list | wofi --dmenu -p clippick -l top_right -x -15 -y 10 -n | cliphist delete", + "escape": true + }, + "custom/power": { + "format": "{}", + "exec": "~/.scripts/tools/expand power", + "return-type": "json", + "on-click": "~/.config/wlogout/launch.sh" + }, + "custom/custom": { + "format": "{}", + "exec": "~/.scripts/tools/expand arrow-icon", + "on-click": "~/.scripts/tools/expand_toolbar", + "return-type": "json" + } +} diff --git a/.config/waybar/style.css b/.config/waybar/style.css new file mode 100644 index 0000000..348bb04 --- /dev/null +++ b/.config/waybar/style.css @@ -0,0 +1,434 @@ +/* +@import "catppuccin/mocha.css"; +*/ + +/* +* Catppuccin Mocha palette +*/ + +@define-color base #1e1e2e; +@define-color mantle #181825; +@define-color crust #11111b; + +@define-color text #cdd6f4; +@define-color subtext0 #a6adc8; +@define-color subtext1 #bac2de; + +@define-color surface0 rgba(22, 25, 37, 0.9); +@define-color surface1 #45475a; +@define-color surface2 #585b70; +@define-color surface3 #394161; + +@define-color overlay0 #6c7086; +@define-color overlay1 #7f849c; +@define-color overlay2 #9ba3c3; + +@define-color blue #89b4fa; +@define-color lavender #b4befe; +@define-color sapphire #74c7ec; +@define-color sky #89dceb; +@define-color teal #94e2d5; +@define-color green #a6e3a1; +@define-color yellow #f9e2af; +@define-color peach #fab387; +@define-color maroon #eba0ac; +@define-color red #f38ba8; +@define-color mauve #cba6f7; +@define-color pink #f5c2e7; +@define-color flamingo #f2cdcd; +@define-color rosewater #f5e0dc; + +/* =============================== */ +/* Universal Styling */ +* { + border: none; + border-radius: 0; + font-family: 'CaskaydiaCove Nerd Font', monospace; + font-size: 13px; + min-height: 0; +} + +/* =============================== */ + + +/* =============================== */ +/* Bar Styling */ +#waybar { + background: transparent; + color: @text; +} + +/* =============================== */ + + +/* =============================== */ +/* Main Modules */ +#custom-launcher, +#workspaces, +#window, +#tray, +#backlight, +#clock, +#battery, +#pulseaudio, +#network, +#mpd, +#cpu, +#memory, +#disk, +#temperature, +#custom-music, +#custom-updates, +#custom-nordvpn, +#custom-notifications, +#custom-power, +#custom-custom, +#custom-cycle_wall, +#custom-clipboard, +#custom-ss, +#custom-weather { + background-color: @surface0; + color: @text; + border-radius: 16px; + padding: 0.5rem 1rem; + box-shadow: rgba(0, 0, 0, 0.116) 2px 2px 5px 2px; + margin-top: 10px; + /* + margin-bottom: 10px; +*/ + margin-right: 10px; +} + +/* =============================== */ +/* Launcher Module */ +#custom-launcher { + color: @green; + padding-top: 0px; + padding-bottom: 0px; + padding-right: 10px; +} + +/* =============================== */ +/* Workspaces */ +#workspaces { + padding-left: 8px; + padding-right: 8px; +} + +#workspaces * { + font-size: 0px; +} + +#workspaces button { + background-color: @surface3; + color: @mauve; + border-radius: 100%; + min-height: 14px; + min-width: 14px; + margin: 5px 8px; + padding: 0px; + /*transition: all 0.5s cubic-bezier(0.33, 1.0, 0.68, 1.0); easeInOutCubic */ + transition: all 0.5s cubic-bezier(.55, -0.68, .48, 1.68); + box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px; +} + +#workspaces button.active { + /*color: @surface0; + border-radius: 1rem; + padding: 0rem 10px;*/ + background: radial-gradient(circle, rgba(203, 166, 247, 1) 0%, rgba(193, 168, 247, 1) 12%, rgba(249, 226, 175, 1) 19%, rgba(189, 169, 247, 1) 20%, rgba(182, 171, 247, 1) 24%, rgba(198, 255, 194, 1) 36%, rgba(177, 172, 247, 1) 37%, rgba(170, 173, 248, 1) 48%, rgba(255, 255, 255, 1) 52%, rgba(166, 174, 248, 1) 52%, rgba(160, 175, 248, 1) 59%, rgba(148, 226, 213, 1) 66%, rgba(155, 176, 248, 1) 67%, rgba(152, 177, 248, 1) 68%, rgba(205, 214, 244, 1) 77%, rgba(148, 178, 249, 1) 78%, rgba(144, 179, 250, 1) 82%, rgba(180, 190, 254, 1) 83%, rgba(141, 179, 250, 1) 90%, rgba(137, 180, 250, 1) 100%); + background-size: 400% 400%; + animation: gradient_f 20s ease-in-out infinite; + transition: all 0.3s cubic-bezier(.55, -0.68, .48, 1.682); +} + +#workspaces button:hover { + background-color: @mauve; +} + +@keyframes gradient { + 0% { + background-position: 0% 50%; + } + + 50% { + background-position: 100% 30%; + } + + 100% { + background-position: 0% 50%; + } +} + +@keyframes gradient_f { + 0% { + background-position: 0% 200%; + } + + 50% { + background-position: 200% 0%; + } + + 100% { + background-position: 400% 200%; + } +} + +@keyframes gradient_f_nh { + 0% { + background-position: 0% 200%; + } + + 100% { + background-position: 200% 200%; + } +} + +/* =============================== */ + + +/* =============================== */ +/* System Monitoring Modules */ +#cpu, +#memory, +#temperature { + color: @blue; +} + +#cpu { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + margin-right: 0px; + padding-right: 5px; +} + +#memory { + border-radius: 0px; + margin-right: 0px; + padding-left: 5px; + padding-right: 5px; +} + +#temperature { + border-radius: 0px; + margin-right: 0px; + padding-left: 5px; + padding-right: 5px; +} + +#disk { + color: @peach; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + padding-left: 5px; + padding-right: 1rem; +} + +/* Updates Module */ +#custom-updates { + color: @sky; +} + +/* =============================== */ + + +/* =============================== */ +/* Clock Module */ +#clock { + color: @flamingo; +} + +/* =============================== */ + + +#custom-music.low { + background: rgb(148, 226, 213); + background: linear-gradient(52deg, rgba(148, 226, 213, 1) 0%, rgba(137, 220, 235, 1) 19%, rgba(116, 199, 236, 1) 43%, rgba(137, 180, 250, 1) 56%, rgba(180, 190, 254, 1) 80%, rgba(186, 187, 241, 1) 100%); + background-size: 300% 300%; + text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.377); + animation: gradient 15s ease infinite; + font-weight: bold; + color: #fff; +} + +#custom-music.random { + background: rgb(148, 226, 213); + background: radial-gradient(circle, rgba(148, 226, 213, 1) 0%, rgba(156, 227, 191, 1) 21%, rgba(249, 226, 175, 1) 34%, rgba(158, 227, 186, 1) 35%, rgba(163, 227, 169, 1) 59%, rgba(148, 226, 213, 1) 74%, rgba(164, 227, 167, 1) 74%, rgba(166, 227, 161, 1) 100%); + background-size: 400% 400%; + animation: gradient_f 4s ease infinite; + text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.377); + font-weight: bold; + color: #fff; +} + +#custom-music.critical { + background: rgb(235, 160, 172); + background: linear-gradient(52deg, rgba(235, 160, 172, 1) 0%, rgba(243, 139, 168, 1) 30%, rgba(231, 130, 132, 1) 48%, rgba(250, 179, 135, 1) 77%, rgba(249, 226, 175, 1) 100%); + background-size: 300% 300%; + animation: gradient 15s cubic-bezier(.55, -0.68, .48, 1.68) infinite; + text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.377); + font-weight: bold; + color: #fff; +} + +#custom-music.Playing { + background: rgb(137, 180, 250); + background: radial-gradient(circle, rgba(137, 180, 250, 120) 0%, rgba(142, 179, 250, 120) 6%, rgba(148, 226, 213, 1) 14%, rgba(147, 178, 250, 1) 14%, rgba(155, 176, 249, 1) 18%, rgba(245, 194, 231, 1) 28%, rgba(158, 175, 249, 1) 28%, rgba(181, 170, 248, 1) 58%, rgba(205, 214, 244, 1) 69%, rgba(186, 169, 248, 1) 69%, rgba(195, 167, 247, 1) 72%, rgba(137, 220, 235, 1) 73%, rgba(198, 167, 247, 1) 78%, rgba(203, 166, 247, 1) 100%); + background-size: 400% 400%; + animation: gradient_f 9s cubic-bezier(.72, .39, .21, 1) infinite; + text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.377); + font-weight: bold; + color: #fff; +} + +#custom-music.Paused, +#custom-music.Stopped { + background: @surface0; +} + + +/* =============================== */ +/* Music/PlayerCTL Module */ +#custom-music { + color: @mauve; +} + +/* =============================== */ + + +/* =============================== */ +/* Network Module */ +#network { + color: @blue; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + margin-right: 0px; + padding-right: 5px; +} + +/* =============================== */ + + +/* =============================== */ +/* PulseAudio Module */ +#pulseaudio { + color: @mauve; + border-radius: 0; + margin-right: 0px; + padding-left: 5px; + padding-right: 5px; +} + +/* =============================== */ + + +/* =============================== */ +/* Backlight Module */ +#backlight { + color: @teal; + border-radius: 0; + margin-right: 0px; + padding-left: 5px; + padding-right: 5px; +} + +/* =============================== */ + + +/* =============================== */ +/* Battery Module */ +#battery { + color: @green; + border-radius: 0; + margin-right: 0px; + padding-left: 5px; + padding-right: 5px; +} + +#battery.charging { + color: @green; +} + +#battery.warning:not(.charging) { + color: @maroon; +} + +#battery.critical:not(.charging) { + color: @red; + animation-name: blink; + animation-duration: 1s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +@keyframes blink { + to { + background: @red; + color: @surface1; + } +} + +/* =============================== */ + +/* Notifications Module */ +#custom-notifications { + color: @mauve; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + padding-left: 5px; + padding-right: 1.25rem; +} + + +/* =============================== */ +/* Tray Module */ +#tray { + color: @mauve; + padding-right: 1.25rem; +} + +/* =============================== */ + + +/* =============================== */ +/* | Custom Modules | */ +/* =============================== */ +#custom-custom { + color: @peach; + padding-right: 1.25rem; + margin-right: 0px; +} + +/* Screenshot */ +#custom-ss { + color: @mauve; + padding-right: 1.5rem; +} + +/* Wallpaper */ +#custom-cycle_wall { + background: linear-gradient(45deg, rgba(245, 194, 231, 1) 0%, rgba(203, 166, 247, 1) 0%, rgba(243, 139, 168, 1) 13%, rgba(235, 160, 172, 1) 26%, rgba(250, 179, 135, 1) 34%, rgba(249, 226, 175, 1) 49%, rgba(166, 227, 161, 1) 65%, rgba(148, 226, 213, 1) 77%, rgba(137, 220, 235, 1) 82%, rgba(116, 199, 236, 1) 88%, rgba(137, 180, 250, 1) 95%); + background-size: 500% 500%; + animation: gradient 7s linear infinite; +} + +/* Notifications Module */ +#custom-clipboard { + color: @mauve; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + margin-right: 0px; + padding-right: 8px; +} + +/* Powermenu Module */ +#custom-power { + color: @mauve; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + padding-left: 8px; + padding-right: 1.20rem; +} + +/* =============================== */ diff --git a/.config/wezterm/wezterm.lua b/.config/wezterm/wezterm.lua new file mode 100644 index 0000000..20e7490 --- /dev/null +++ b/.config/wezterm/wezterm.lua @@ -0,0 +1,211 @@ +local wezterm = require("wezterm") + +---- Function to unset Ctrl+C keybinding +--local function unsetCtrlCKeybinding(window) +-- local keys = window:get_config().keys +-- for i, key in ipairs(keys) do +-- if key.key == 'c' and key.mods == 'CTRL' then +-- table.remove(keys, i) +-- break +-- end +-- end +-- window:set_config({ keys = keys }) +--end +-- +---- Event handler to unset Ctrl+C keybinding when using nvim +--wezterm.on("spawn_command", function(window, pane) +-- local cmd = pane:get_command() +-- if cmd and cmd[1] == "nvim" then +-- unsetCtrlCKeybinding(window) +-- end +--end) + +--local function isNvimRunning(window) +-- local pane = window.active_pane +-- local cmd = pane:get_command() +-- return cmd and cmd[1] == "nvim" +--end +-- +---- Function to modify keybindings based on the current program +--local function updateKeybindings(window) +-- local isNvim = isNvimRunning(window) +-- +-- local keys = {} +-- if not isNvim then +-- -- Add the default Ctrl+C keybinding +-- keys = { +-- { +-- key = "c", +-- mods = "CTRL", +-- action = wezterm.action{CopyTo = "ClipboardAndPrimarySelection"} +-- } +-- } +-- end +-- +-- window:set_config({ +-- keys = keys +-- }) +--end +-- +---- Event handler to update keybindings when the active program changes +--wezterm.on("update-right-status", function(window) +-- updateKeybindings(window) +--end) + +wezterm.on("toggle-opacity", function(window) + local overrides = window:get_config_overrides() or {} + if not overrides.window_background_opacity then + overrides.window_background_opacity = 1.0 + elseif overrides.window_background_opacity == 1.0 then + overrides.window_background_opacity = 0.6 + else + overrides.window_background_opacity = nil + end + window:set_config_overrides(overrides) +end) + +return { + front_end = "OpenGL", + --font = wezterm.font 'JetBrains Mono', + font = wezterm.font_with_fallback({ + { + family = "JetBrains Mono", + --intensity = 'Normal', + weight = "Medium", + italic = false, + harfbuzz_features = { "calt=0", "clig=0", "liga=0" }, + }, + { family = "Hack Nerd Font", weight = "Medium" }, + { + family = "Fira Code", + harfbuzz_features = { "zero" }, + }, + { family = "Terminus", weight = "Bold" }, + "Noto Color Emoji", + }), + font_size = 9, + warn_about_missing_glyphs = false, + adjust_window_size_when_changing_font_size = false, + line_height = 1.0, + --dpi = 96.0, + -- Keybinds + disable_default_key_bindings = true, + use_dead_keys = false, + mouse_bindings = { + -- Ctrl-click will open the link under the mouse cursor + { + event = { Up = { streak = 1, button = "Left" } }, + mods = "CTRL", + action = wezterm.action.OpenLinkAtMouseCursor, + }, + }, + keys = { + --leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 1000 }, + { + key = "O", + mods = "CTRL|SHIFT", + action = wezterm.action({ EmitEvent = "toggle-opacity" }), + }, + { key = "R", mods = "CTRL", action = "ReloadConfiguration" }, + { key = "Y", mods = "CTRL", action = "ShowDebugOverlay" }, + { + key = "-", + mods = "CTRL", + action = wezterm.action.DecreaseFontSize, + }, + { + key = "=", + mods = "CTRL", + action = wezterm.action.IncreaseFontSize, + }, + { + key = "0", + mods = "CTRL", + action = wezterm.action.ResetFontSize, + }, + { + key = "v", + mods = "CTRL", + action = wezterm.action({ PasteFrom = "Clipboard" }), + }, + --{ + -- key = "c", + -- mods = "CTRL", + -- action = wezterm.action({ CopyTo = "ClipboardAndPrimarySelection" }), + --}, + { + key = "c", + mods = "CTRL", + action = wezterm.action_callback(function(window, pane) + local has_selection = window:get_selection_text_for_pane(pane) ~= "" + if has_selection then + window:perform_action( + wezterm.action({ CopyTo = "ClipboardAndPrimarySelection" }), + pane + ) + window:perform_action("ClearSelection", pane) + else + window:perform_action( + wezterm.action({ SendKey = { key = "c", mods = "CTRL" } }), + pane + ) + end + end), + }, + }, + -- Aesthetic Night Colorscheme + --bold_brightens_ansi_colors = true, + -- Padding + window_padding = { + left = 5, + right = 5, + top = 6, + bottom = 4, + }, + -- Cursor style + --default_cursor_style = "BlinkingUnderline", + default_cursor_style = "BlinkingBar", + cursor_blink_rate = 700, + -- needed to prevent 'easing' from using 40%+ cpu util ... + --animation_fps = 1, + force_reverse_video_cursor = true, + colors = { + cursor_bg = "white", + compose_cursor = "orange", + --cursor_border = 'white', + }, + + -- Tab Bar + enable_tab_bar = false, + --hide_tab_bar_if_only_one_tab = true, + --show_tab_index_in_tab_bar = false, + tab_bar_at_bottom = false, + + -- General + -- X11 + enable_wayland = false, + audible_bell = "Disabled", + + visual_bell = { + fade_in_duration_ms = 5, + fade_out_duration_ms = 5, + target = "CursorColor", + }, + automatically_reload_config = true, + scrollback_lines = 3500, + --inactive_pane_hsb = { saturation = 1.0, brightness = 1.0 }, + --text_background_opacity = 0.3, + window_background_opacity = 0.8, + --window_background_image = '/path/to/wallpaper.jpg', + --window_background_image_hsb = { + -- -- Darken the background image by reducing it to 1/3rd + -- brightness = 0.3, + -- -- You can adjust the hue by scaling its value. + -- -- a multiplier of 1.0 leaves the value unchanged. + -- hue = 1.0, + -- -- You can adjust the saturation also. + -- saturation = 1.0, + --}, + window_close_confirmation = "NeverPrompt", + --color_scheme = 'transparent', +} diff --git a/.config/wofi/config b/.config/wofi/config new file mode 100644 index 0000000..d1ea4c8 --- /dev/null +++ b/.config/wofi/config @@ -0,0 +1,17 @@ +width=420 +height=550 +location=center +show=drun +matching=fuzzy +prompt=Search... +filter_rate=100 +allow_markup=true +no_actions=true +halign=fill +orientation=vertical +content_halign=fill +insensitive=true +allow_images=true +image_size=28 +gtk_dark=false +term=kitty diff --git a/.config/wofi/style.css b/.config/wofi/style.css new file mode 100644 index 0000000..6fb5107 --- /dev/null +++ b/.config/wofi/style.css @@ -0,0 +1,99 @@ +* { + transition: 0.2s; +} + +window { + font-family: "FiraCode Nerd Font Mono"; + font-size: 13px; +} + +window { + margin: 0px; + border: 2px solid #cba6f7; +/* + background-color: #161925; +*/ + background-color: transparent; + border-radius: 16px; +} + +#input { + padding: 4px; + margin: 20px; + padding-left: 20px; + border: none; + color: #fff; + font-weight: bold; + background: linear-gradient(90deg, #cba6f7 0%, #94e2d5 100%); + outline: none; + border-radius: 16px; +} + +#input image { + color: #fff; +} + +#input:focus { + border: none; + outline: none; +} + +#inner-box { + margin: 20px; + margin-top: 0px; + border: none; + color: #cba6f7; + border-radius: 16px; +} + +#inner-box * { + transition: none; +} + +#outer-box { + margin: 0px; + border: none; + padding: 0px; + border-radius: 16px; +} + +#scroll { + margin-top: 5px; + border: none; + border-radius: 16px; + margin-bottom: 5px; +} + +#text:selected { + color: #fff; + font-weight: bold; +} + +#img { + margin-right: 20px; + background: transparent; +} + +#text { + margin: 0px; + border: none; + padding: 0px; + background: transparent; +} + +#entry { + margin: 0px; + border: none; + border-radius: 16px; + background-color: transparent; + min-height:32px; + font-weight: bold; +} + +#entry:selected { + outline: none; + margin: 0px; + border: none; + border-radius: 16px; + background: linear-gradient(90deg, #cba6f7 0%, #94e2d5 100%); +} diff --git a/.config/xkb/symbols/vim_keys b/.config/xkb/symbols/vim_keys new file mode 100644 index 0000000..34f2ca5 --- /dev/null +++ b/.config/xkb/symbols/vim_keys @@ -0,0 +1,52 @@ +// ~/.config/xkb/symbols/vim_keys + +xkb_symbols "basic" { + include "us(basic)" + include "custom(altgr)" + + clear lock; + clear mod5; + clear control; + + // Define a custom modifier (Mode_switch) + modifier_map Mod5 { <MDSW> }; + + // Remap Caps Lock to AltGr (ISO_Level3_Shift) + key <CAPS> { + type[Group1] = "ONE_LEVEL", + symbols[Group1] = [ ISO_Level3_Shift ], + actions[Group1] = [ SetMods(modifiers=Mod5) ] + }; + + // Remap h, j, k, l to arrow keys when Mode_switch is active + key <AC06> { [ Left ] }; + key <AC07> { [ Down ] }; + key <AC08> { [ Up ] }; + key <AC09> { [ Right ] }; + + // Assign keys to the CtrlMod modifier + key <RCTL> { [ Control_R, Control_R ] }; + key <LCTL> { [ Control_L, Control_L ] }; + + // Define Ctrl+Mode_switch+J as PageDown + key <I194> { [ Control_R, ISO_Level3_Shift, Prior ] }; + key <I194> { [ Control_L, ISO_Level3_Shift, Prior ] }; + + // Define Ctrl+Mode_switch+K as PageUp + key <I196> { [ Control_R, ISO_Level3_Shift, Next ] }; + key <I196> { [ Control_L, ISO_Level3_Shift, Next ] }; + + // Define Ctrl+Mode_switch+H as Home + key <AC06> { [ Control_R, ISO_Level3_Shift, Home ] }; + key <AC06> { [ Control_L, ISO_Level3_Shift, Home ] }; + + // Define Ctrl+Mode_switch+L as End + key <AC09> { [ Control_R, ISO_Level3_Shift, End ] }; + key <AC09> { [ Control_L, ISO_Level3_Shift, End ] }; + + // Make 'q' act as Escape when in Mode_switch + key <AD03> { [ q, Q, Escape ] }; + + // Shift+Caps to use normal Caps Lock + modifier_map Mod5 { Shift+CapsLock, <MDSW> }; +}; diff --git a/.config/zathura/zathurarc b/.config/zathura/zathurarc new file mode 100644 index 0000000..78d66a1 --- /dev/null +++ b/.config/zathura/zathurarc @@ -0,0 +1,27 @@ +set window-title-basename "true" + + + + +# Basic Settings + +set highlight-transparency .1 +set zoom-center "true" +set selection-clipboard "clipboard" +set render-loading "false" +set pages-per-row 1 +set scroll-page-aware "true" +set scroll-full-overlap 0.01 +set scroll-step 50 +set zoom-min 10 +set guioptions "" +set render-loading "false" + + +# Startup options +set adjust-open "best-fit" +set recolor true + +# Side by side view (view 2 pages like an open book) +map D set "first-page-column 1:1" +map <C-d> set "first-page-column 1:2" diff --git a/.config/zsh/.zshenv b/.config/zsh/.zshenv new file mode 100644 index 0000000..147b5e7 --- /dev/null +++ b/.config/zsh/.zshenv @@ -0,0 +1,259 @@ +# Load local/system wide binaries and scripts +export PATH=$HOME/.bin:$HOME/.local/bin:$HOME/.local/bin/scripts:/usr/local/bin:/sbin:/usr/sbin:$PATH +export PATH="/data/data/com.termux/files/usr/local/bin:$PATH" + +# Skip the not really helping Ubuntu global compinit +skip_global_compinit=1 + +## Conditionally set WM(window manager) +available_wms=("bspwm" "mutter" "i3") +for wm in "${available_wms[@]}"; do + if command -v "$wm" &> /dev/null; then + export WM="$wm" + break + fi +done + +# Set a flag to indicate if the display server type is found +display_server_found=0 + +# Conditionally set Display server +available_displays=("wayland" "x11") +for display in "${available_displays[@]}"; do + if [ "$WAYLAND_DISPLAY" = "$display" ]; then + export XDG_SESSION_TYPE="$display" + display_server_found=1 + break + fi +done + +# Check if XDG_SESSION_TYPE is "x11" and set X11-specific variables +if [ "$display_server_found" -eq 1 ] && [ "$XDG_SESSION_TYPE" == "x11" ]; then + # X11-specific variables + export XINITRC="$HOME/.config/X11/.xinitrc" + export XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc" + export USERXSESSION="$XDG_CONFIG_HOME/X11/xsession" + export USERXSESSIONRC="$XDG_CONFIG_HOME/X11/xsessionrc" + export ALTUSERXSESSION="$XDG_CONFIG_HOME/X11/Xsession" + export ERRFILE="$XDG_CONFIG_HOME/X11/xsession-errors" + export ICEAUTHORITY="$XDG_CACHE_HOME/.ICEauthority" +fi + +# Conditionally set default term +available_terms=("wezterm" "alacritty" "xterm") +for term in "${available_terms[@]}"; do + if command -v "$term" &> /dev/null; then + export TERMINAL="$term" + break + fi +done + +# Default Programs: +export EDITOR=$(command -v nvim || echo "vim") +export VISUAL=$EDITOR +export COLORTERM="truecolor" +export TERM="xterm-256color" +export READER="zathura" +export BROWSER="firefox" +export OPENER="xdg-open" +export MANPAGER="echo \$EDITOR +Man!" +export PAGER="less" +export FAQ_STYLE='github' +export VIDEO="vlc" +export IMAGE="sxiv" + +# XDG Paths: +export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} +export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} +export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} +export INPUTRC="${XDG_CONFIG_HOME:-$HOME/.config}/inputrc" +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" +export HISTFILE="$ZDOTDIR/.zhistory" # History filepath +export HISTSIZE=1000000 # Maximum events for internal history +export SAVEHIST=1000000 # Maximum events in history file +export BANG_HIST # Treat the '!' character specially during expansion. +export EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. +export INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. +export SHARE_HISTORY # Share history between all sessions. +export HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history. +export HIST_IGNORE_DUPS # Don't record an entry that was just recorded again. +export HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. +export HIST_FIND_NO_DUPS # Do not display a line previously found. +export HIST_IGNORE_SPACE # Don't record an entry starting with a space. +export HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. +export HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. +export HIST_VERIFY # Don't execute immediately upon history expansion. +export HIST_BEEP # Beep when accessing nonexistent history. + +# Customize `ls` colours +export LSCOLORS=ExGxBxDxCxEgEdxbxgxcxd + +# Other XDG paths: +export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME/ripgrep/ripgreprc" +export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" +export VSCODE_PORTABLE="$XDG_DATA_HOME/vscode" +export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" +export PATH="/usr/bin/cmake:$PATH" +export PATH=$PATH:/opt/google/chrome + +# Manage Arch linux build sources +export ASPROOT="${XDG_CACHE_HOME:-$HOME/.cache}/asp" + +# GnuPG +export GPG_TTY=$(tty) +export GNUPGHOME="$XDG_CONFIG_HOME/gnupg" + +# Fzf +export PATH="$PATH:/usr/local/bin/fzf/bin" +export FZF_BASE="/usr/local/bin/fzf" + +# Android Home +export ANDROID_HOME=/opt/android-sdk +export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$PATH +#export PATH=$ANDROID_HOME/cmdline-tools/bin:$PATH +export PATH=$ANDROID_HOME/tools:$PATH +export PATH=$ANDROID_HOME/tools/bin:$PATH +export PATH=$ANDROID_HOME/platform-tools:$PATH +# Android emulator PATH +export PATH=$ANDROID_HOME/emulator:$PATH +# Android SDK ROOT PATH +export ANDROID_SDK_ROOT=/opt/android-sdk +export PATH=$ANDROID_SDK_ROOT:$PATH +#export ANDROID_SDK_HOME="${XDG_CONFIG_HOME:-$HOME/.config}/android" + +# Programming Environment Variables: + +# Rust +export RUSTUP_HOME=${XDG_DATA_HOME:-$HOME/.local/share}/rustup +export CARGO_HOME=${XDG_DATA_HOME:-$HOME/.local/share}/cargo +#[[ -d $CARGO_HOME/bin ]] && path=($CARGO_HOME/bin $path) +#if which rustc > /dev/null; then export RUST_BACKTRACE=1; fi +#export PATH="$HOME/.cargo/bin:$PATH" +#export CARGO_HOME=${XDG_DATA_HOME}/cargo +#export RUSTUP_HOME=${XDG_DATA_HOME}/rustup +#export PATH="${CARGO_HOME}/bin:${RUSTUP_HOME}/bin:$PATH" + + +# Java +#export JAVA_HOME=/usr/lib/jvm/default-java +#export JAVA_HOME='/usr/lib/jvm/java-8-openjdk' +#export JAVA_HOME='/usr/lib/jvm/java-10-openjdk' +#export JAVA_HOME='/usr/lib/jvm/java-11-openjdk' +#export JAVA_HOME='/usr/lib/jvm/java-17-openjdk' +export JAVA_HOME='/usr/lib/jvm/java-20-openjdk' +#export PATH=$JAVA_HOME/bin:$PATH +export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME"/java +#export DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions' +#export _JAVA_AWT_WM_NONREPARENTING=1 +#export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' +#export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.xml.bind' +#Windows: +#set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee + +# Dart/Flutter +export PATH="/opt/flutter/bin:/usr/lib/dart/bin:$PATH" + +# Go +export GO_PATH=${XDG_DATA_HOME}/go + + +# Javascript +# global node installs (gross) +[[ -d "$XDG_DATA_HOME/node/bin" ]] && path=($XDG_DATA_HOME/node/bin $path) +export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history +export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc +#export NPM_CONFIG_INIT_AUTHOR_NAME='srdusr' +#export NPM_CONFIG_INIT_AUTHOR_EMAIL='trevorgray@srdusr.com' +#export NPM_CONFIG_INIT_AUTHOR_URL='https://srdusr.com' +#export NPM_CONFIG_INIT_LICENSE='GPL-3.0' +#export NPM_CONFIG_INIT_VERSION='0.0.0' +#export NPM_CONFIG_SIGN_GIT_TAG='true' +export NVM_DIR="$HOME/.config/nvm" +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + + +# Ruby +export GEM_PATH="$XDG_DATA_HOME/ruby/gems" +export GEM_SPEC_CACHE="$XDG_DATA_HOME/ruby/specs" +export GEM_HOME="$XDG_DATA_HOME/ruby/gems" +#if [[ -d ~/.gem/ruby ]]; then +# ver=$(find ~/.gem/ruby/* -maxdepth 0 | sort -rV | head -n 1) +# export PATH="$PATH:${ver}/bin" +#fi + + +# Python +# lazy load pyenv +#export PYENV_ROOT=${PYENV_ROOT:-$HOME/.pyenv} +#[[ -a $PYENV_ROOT/bin/pyenv ]] && path=($PYENV_ROOT/bin $path) +#if type pyenv &> /dev/null || [[ -a $PYENV_ROOT/bin/pyenv ]]; then +# function pyenv() { +# unset pyenv +# path=($PYENV_ROOT/shims $path) +# eval "$(command pyenv init -)" +# if which pyenv-virtualenv-init > /dev/null; then +# eval "$(pyenv virtualenv-init -)" +# export PYENV_VIRTUALENV_DISABLE_PROMPT=1 +# fi +# pyenv $@ +# } +#fi +export WORKON_HOME="$XDG_DATA_HOME/virtualenvs" +export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME/jupyter" +export IPYTHONDIR="$XDG_CONFIG_HOME/jupyter" +export VIRTUAL_ENV_DISABLE_PROMPT=true + +# PHP +PATH="$HOME/.config/composer/vendor/bin:$PATH" + + +# Lua +export PATH=$PATH:/usr/local/luarocks/bin +#export PATH="$XDG_DATA_HOME/luarocks/bin:$PATH" + +#ver=$(find lua* -maxdepth 0 | sort -rV | head -n 1) +#export LUA_PATH="$LUA_PATH:${ver}/share/lua/5.1/?.lua;${ver}/share/lua/5.1/?/init.lua;;" +#export LUA_CPATH="$LUA_CPATH:${ver}/lib/lua/5.1/?.so;;" + +#LUAROCKS_PREFIX=/usr/local +#export LUA_PATH="$LUAROCKS_PREFIX/share/lua/5.1/?.lua;$LUAROCKS_PREFIX/share/lua/5.1/?/init.lua;;" +#export LUA_CPATH="$LUAROCKS_PREFIX/lib/lua/5.1/?.so;;" + +#export LUA_PATH="<path-to-add>;;" +#export LUA_CPATH="./?.so;/usr/local/lib/lua/5.3/?.so; +# /usr/local/share/lua/5.3/?.so;<path-to-add>" + + +# Program settings +#export MOZ_USE_XINPUT2="1" # Mozilla smooth scrolling/touchpads. + + +# Scaling +#export QT_AUTO_SCREEN_SCALE_FACTOR=0 +#export QT_SCALE_FACTOR=1 +#export QT_SCREEN_SCALE_FACTORS="1;1;1" +#export GDK_SCALE=1 +#export GDK_DPI_SCALE=1 + + +#typeset -U PATH path +export GTK_IM_MODULE='fcitx' +export QT_IM_MODULE='fcitx' +export SDL_IM_MODULE='fcitx' +export XMODIFIERS='@im=fcitx' + + +# Start blinking +#export LESS_TERMCAP_mb=$(tput bold; tput setaf 2) # green +# Start bold +#export LESS_TERMCAP_md=$(tput bold; tput setaf 2) # green +# Start stand out +#export LESS_TERMCAP_so=$(tput bold; tput setaf 3) # yellow +# End standout +#export LESS_TERMCAP_se=$(tput rmso; tput sgr0) +# Start underline +#export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 1) # red +# End Underline +#export LESS_TERMCAP_ue=$(tput sgr0) +# End bold, blinking, standout, underline +#export LESS_TERMCAP_me=$(tput sgr0). diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc new file mode 100644 index 0000000..a891772 --- /dev/null +++ b/.config/zsh/.zshrc @@ -0,0 +1,579 @@ + +# ███████╗███████╗██╗ ██╗██████╗ ██████╗ +# ╚══███╔╝██╔════╝██║ ██║██╔══██╗██╔════╝ +# ███╔╝ ███████╗███████║██████╔╝██║ +# ███╔╝ ╚════██║██╔══██║██╔══██╗██║ +# ███████╗███████║██║ ██║██║ ██║╚██████╗ +# ╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +if [[ -n "$SSH_CLIENT" ]]; then + export KEYTIMEOUT=1 +else + export KEYTIMEOUT=15 +fi + +# Tmux default session +if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then + tmux a -t tmux || exec tmux new -s tmux && exit; +fi + +# Enable various options +setopt interactive_comments beep extendedglob nomatch notify completeinword prompt_subst + +########## Vi mode ########## +bindkey -v +bindkey -M viins '^?' backward-delete-char +bindkey -M viins '^[[3~' delete-char +bindkey -M vicmd '^[[3~' delete-char +bindkey -v '^?' backward-delete-char +bindkey -r '\e/' +bindkey -s jk '\e' +bindkey "^W" backward-kill-word +bindkey "^H" backward-delete-char # Control-h also deletes the previous char +bindkey "^U" backward-kill-line +bindkey "^[j" history-search-forward # or you can bind it to the down key "^[[B" +bindkey "^[k" history-search-backward # or you can bind it to Up key "^[[A" + +# Define the 'autosuggest-execute' and 'autosuggest-accept' ZLE widgets +autoload -Uz autosuggest-execute autosuggest-accept +zle -N autosuggest-execute +zle -N autosuggest-accept +bindkey '^X' autosuggest-execute +bindkey '^Y' autosuggest-accept + +# Edit line in vim with alt-e +autoload edit-command-line; zle -N edit-command-line +bindkey '^e' edit-command-line +bindkey '^[e' edit-command-line # alt + e + +# Allow CTRL+D to exit zsh with partial command line (non empty line) +exit_zsh() { exit } +zle -N exit_zsh +bindkey '^D' exit_zsh + +# Auto-completion +autoload -Uz compinit +if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then + compinit; +else + compinit -C; +fi; + +# Accept completion with <tab> or Ctrl+i and go to next/previous suggestions with Vi like keys: Ctrl+n/p +zmodload -i zsh/complist +accept-and-complete-next-history() { + zle expand-or-complete-prefix +} + +zle -N accept-and-complete-next-history +bindkey -M menuselect '^i' accept-and-complete-next-history +bindkey '^n' expand-or-complete +bindkey '^p' reverse-menu-complete +zstyle ':completion:*' menu select=1 + +# Some other useful functionalities +setopt autocd # Automatically cd into typed directory. +stty intr '^q' # free Ctrl+C for copy use Ctrl+q instead +stty lnext '^-' # free Ctrl+V for paste use ^- instead +stty stop undef # Disable ctrl-s to freeze terminal. +stty start undef +#unsetopt BEEP + +########## Prompt(s) ########## + +# Enable colors +autoload -U colors && colors + +# Prompt with Vi insert-mode/normal-mode and blinking '$', note blinking '$' only works on some terminals. +terminfo_down_sc=$terminfo[cud1]$terminfo[cuu1]$terminfo[sc]$terminfo[cud1] +git_branch_test_color() { + local ref=$(git symbolic-ref --short HEAD 2> /dev/null) + if [ -n "${ref}" ]; then + if [ -n "$(git status --porcelain)" ]; then + local gitstatuscolor='%F{196}' + else + local gitstatuscolor='%F{82}' + fi + echo "${gitstatuscolor}${ref}" + else + echo "" + fi +} + +# Job indicator +jobs_status_indicator() { + local jobs_output + declare -p jobs_output >/dev/null 2>&1 + if [[ $? -eq 0 ]]; then + unset jobs_output + fi + jobs_output=$(jobs -s) + if [[ -n "$jobs_output" ]]; then + local jobs_count=$(echo "$jobs_output" | wc -l) + echo "jobs: ${jobs_count}" + fi +} + +remote_indicator() { + if [[ -n "$SSH_CONNECTION" || -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + echo 'ssh ' + else + echo '' + fi +} + +# Version control (git) +autoload -Uz add-zsh-hook vcs_info +zstyle ':vcs_info:*' stagedstr ' +%F{15}staged%f' +zstyle ':vcs_info:*' unstagedstr ' -%F{15}unstaged%f' +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:*' actionformats '%F{5}%F{2}%b%F{3}|%F{1}%a%F{5}%f ' +zstyle ':vcs_info:*' formats '%F{208} '$'\uE0A0'' %f$(git_branch_test_color)%f%F{76}%c%F{3}%u%f ' +zstyle ':vcs_info:git*+set-message:*' hooks git-untracked +zstyle ':vcs_info:*' enable git ++vi-git-untracked() { + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ + [[ $(git ls-files --other --directory --exclude-standard | sed q | wc -l | tr -d ' ') == 1 ]] ; then + hook_com[unstaged]+='%F{196} !%f%F{15}untracked%f' + fi +} + +# Prompt +function insert-mode() { + echo "-- INSERT --" +} + +function normal-mode() { + echo "-- NORMAL --" +} + +function my_precmd () { + vcs_info + PS1="%{┌─[%F{145}%n%f] %F{39}%0~%f%} ${vcs_info_msg_0_} \$(remote_indicator)\$(jobs_status_indicator) + %{%{$terminfo_down_sc$(insert-mode)$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" +} + +add-zsh-hook precmd my_precmd + +function set-prompt() { + if [[ ${KEYMAP} == vicmd || ${KEYMAP} == vi-cmd-mode ]]; then + echo -ne '\e[1 q' + VI_MODE=$(normal-mode) + elif [[ ${KEYMAP} == main || ${KEYMAP} == viins || ${KEYMAP} == '' ]]; then + echo -ne '\e[5 q' + VI_MODE=$(insert-mode) + fi + PS1="%{┌─[%F{145}%n%f] %F{39}%0~%f%} ${vcs_info_msg_0_} \$(remote_indicator)\$(jobs_status_indicator) + %{%{$terminfo_down_sc$VI_MODE$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" +} + +function update-mode-file() { + set-prompt + local current_mode=$(cat ~/.vi-mode) + local new_mode="$VI_MODE" + if [[ "$new_mode" != "$current_mode" ]]; then + echo "$new_mode" >| ~/.vi-mode + fi + if command -v tmux &>/dev/null && [[ -n "$TMUX" ]]; then + tmux refresh-client -S + fi +} + +function check-nvim-running() { + if pgrep -x "nvim" > /dev/null; then + VI_MODE="" + update-mode-file + if command -v tmux &>/dev/null && [[ -n "$TMUX" ]]; then + tmux refresh-client -S + fi + else + if [[ ${KEYMAP} == vicmd || ${KEYMAP} == vi-cmd-mode ]]; then + VI_MODE=$(normal-mode) + elif [[ ${KEYMAP} == main || ${KEYMAP} == viins || ${KEYMAP} == '' ]]; then + VI_MODE=$(insert-mode) + fi + update-mode-file + if command -v tmux &>/dev/null && [[ -n "$TMUX" ]]; then + tmux refresh-client -S + fi + fi +} + +function zle-line-init() { + zle reset-prompt + case "${KEYMAP}" in + vicmd) + echo -ne '\e[1 q' + ;; + main|viins|*) + echo -ne '\e[5 q' + ;; + esac +} + +function zle-keymap-select() { + update-mode-file + zle reset-prompt + case "${KEYMAP}" in + vicmd) + echo -ne '\e[1 q' + ;; + main|viins|*) + echo -ne '\e[5 q' + ;; + esac +} + +preexec () { print -rn -- $terminfo[el]; echo -ne '\e[5 q' ; } + +zle -N zle-line-init +zle -N zle-keymap-select + +TRAPWINCH() { # Trap the WINCH signal to update the mode file on window size changes + update-mode-file +} + +#function nvim-listener() { +# local prev_nvim_status="inactive" +# local nvim_pid="" +# while true; do +# local current_nvim_pid=$(pgrep -x "nvim") +# if [[ -n "$current_nvim_pid" && "$current_nvim_pid" != "$nvim_pid" ]]; then +# # Neovim started +# prev_nvim_status="active" +# nvim_pid="$current_nvim_pid" +# VI_MODE="" # Clear VI_MODE to show Neovim mode +# update-mode-file +# if command -v tmux &>/dev/null && [[ -n "$TMUX" ]]; then +# tmux refresh-client -S +# fi +# elif [[ -z "$current_nvim_pid" && "$prev_nvim_status" == "active" ]]; then +# # Neovim stopped +# prev_nvim_status="inactive" +# nvim_pid="" +# if [[ ${KEYMAP} == vicmd || ${KEYMAP} == vi-cmd-mode ]]; then +# VI_MODE=$(normal-mode) +# elif [[ ${KEYMAP} == main || ${KEYMAP} == viins || ${KEYMAP} == '' ]]; then +# VI_MODE=$(insert-mode) +# fi +# update-mode-file +# if command -v tmux &>/dev/null && [[ -n "$TMUX" ]]; then +# tmux refresh-client -S +# fi +# fi +# done +#} + +# Start Neovim listener in the background +#nvim-listener &! +set-prompt + +RPROMPT='%(?..[%F{196}%?%f] )' + + +########## Useful Commands/Alias ########## + +alias s="systemctl" +alias j="journalctl xe" + +# Enter directory and list contents +cd() { + if [ -n "$1" ]; then + builtin cd "$@" && ls -pvA --color=auto --group-directories-first + else + builtin cd ~ && ls -pvA --color=auto --group-directories-first + fi +} + +# cd into $XDG_CONFIG_HOME/$1 directory +c() { + local root=${XDG_CONFIG_HOME:-~/.config} + local dname="$root/$1" + if [[ ! -d "$dname" ]]; then + return + fi + cd "$dname" +} + +# Make and cd into directory and any parent directories +mkcd () { + if [[ -z "$1" ]]; then + echo "Usage: mkcd <dir>" 1>&2 + return 1 + fi + mkdir -p "$1" + cd "$1" +} + +# Back up a file. Usage "backupthis <filename>" +backupthis() { + cp -riv $1 ${1}-$(date +%Y%m%d%H%M).backup; +} + +# Let FZF use ripgrep by default +if type rg &> /dev/null; then + export FZF_DEFAULT_COMMAND='rg --files' + export FZF_DEFAULT_OPTS='-m --height 50% --border' +fi + +# wget does not support environment variables +alias wget=wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" + +# Spawn a clone of current terminal +putstate () { + declare +x >~/environment.tmp + declare -x >>~/environment.tmp + echo cd "$PWD" >>~/environment.tmp +} + +getstate () { + . ~/environment.tmp +} + +# use ctrl-z to toggle in and out of bg +function toggle_fg_bg() { + if [[ $#BUFFER -eq 0 ]]; then + BUFFER="fg" + zle accept-line + else + BUFFER="" + zle clear-screen + fi +} +zle -N toggle_fg_bg +bindkey '^Z' toggle_fg_bg + +# cd using "up n" as a command up as many directories, example "up 3" +up() { + # default parameter to 1 if non provided + declare -i d=${@:-1} + # ensure given parameter is non-negative. Print error and return if it is + (( $d < 0 )) && (>&2 echo "up: Error: negative value provided") && return 1; + # remove last d directories from pwd, append "/" in case result is empty + cd "$(pwd | sed -E 's;(/[^/]*){0,'$d'}$;;')/"; +} + +# Tmux layout +openSession () { + tmux split-window -h -t + tmux split-window -v -t + tmux resize-pane -U 5 +} + +# More history for cd and use "cd -TAB" +setopt AUTO_PUSHD # pushes the old directory onto the stack +zstyle ':completion:*:directory-stack' list-colors '=(#b) #([0-9]#)*( *)==95=38;5;12' + +# List upto last 10 visited directories using "d" and quickly cd into any specific one +# using just a number from "0" to "9" +alias d="dirs -v | head -10" +alias 0="cd +0" +alias 1="cd +1" +alias 2="cd +2" +alias 3="cd +3" +alias 4="cd +4" +alias 5="cd +5" +alias 6="cd +6" +alias 7="cd +7" +alias 8="cd +8" +alias 9="cd +9" + +# Allow nnn filemanager to cd on quit +nnn() { + declare -x +g NNN_TMPFILE=$(mktemp --tmpdir $0.XXXX) + trap "rm -f $NNN_TMPFILE" EXIT + =nnn $@ + [ -s $NNN_TMPFILE ] && source $NNN_TMPFILE +} + +# Extract with one command +extract () { + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) rar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via extract()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + +# Time aliases +alias ber='TZ=Europe/Berlin date' +alias nyc='TZ=America/New_York date' +alias sfo='TZ=America/Los_Angeles date' +alias utc='TZ=Etc/UTC date' + +### Dotfiles +alias config='git --git-dir=$HOME/.cfg --work-tree=$HOME' + +# Set bare dotfiles repository git environment variables dynamically +function set_git_env_vars() { + # Check if the current command is a package manager command + if [[ "${(%)${(z)history[1]}}" =~ ^(pacman|yay|apt|dnf|brew|npm|pip|gem|go|cargo) ]]; then + return + fi + local git_dir="$(git rev-parse --git-dir -C . 2>/dev/null)" + if [[ -n "$git_dir" ]]; then + local is_bare="$(git -C "$git_dir" rev-parse --is-bare-repository 2>/dev/null)" + if [[ "$is_bare" == "true" ]]; then + export GIT_DIR="$HOME/.cfg" + export GIT_WORK_TREE=$(realpath $(eval echo ~)) + else + unset GIT_DIR + unset GIT_WORK_TREE + fi + else + local root_dir="$(git rev-parse --show-toplevel 2>/dev/null)" + if [[ -n "$root_dir" ]]; then + unset GIT_DIR + export GIT_WORK_TREE="$root_dir" + else + export GIT_DIR="$HOME/.cfg" + export GIT_WORK_TREE=$(realpath $(eval echo ~)) + fi + fi +} + +# Define an auto_cd hook to automatically update Git environment variables +function chpwd() { + set_git_env_vars +} +# Call the function to set Git environment variables when the shell starts up +set_git_env_vars + +function gsp +{ + # Config file for subtrees + # + # Format: + # <prefix>;<remote address>;<remote branch> + # # Lines starting with '#' will be ignored + GIT_SUBTREE_FILE="$PWD/.gitsubtrees" + + if [ ! -f $GIT_SUBTREE_FILE ]; then + echo "Nothing to do - file <`basename $GIT_SUBTREE_FILE`> does not exist." + return + fi + + OLD_IFS=$IFS + IFS=$'\n' + for LINE in $(cat $GIT_SUBTREE_FILE); do + + # Skip lines starting with '#'. + if [[ $LINE = \#* ]]; then + continue + fi + + # Parse the current line. + PREFIX=`echo $LINE | cut -d';' -f 1` + REMOTE=`echo $LINE | cut -d';' -f 2` + BRANCH=`echo $LINE | cut -d';' -f 3` + + # Push to the remote. + echo "config subtree pull --prefix=$PREFIX $REMOTE $BRANCH" + config subtree pull --prefix=$PREFIX $REMOTE $BRANCH + done +} + +# Define alias for nvim/vim (fallback to vim) +if command -v nvim > /dev/null; then + alias vi='nvim' +else + alias vi='vim' +fi + +alias nv='nvim' +alias trash_restore='gio trash --restore "$(gio trash --list | fzf | cut -f 1)"' +alias ec='$EDITOR $HOME/.config/zsh/.zshrc' +alias sc="source $HOME/.config/zsh/.zshrc" +alias keyname="xev | sed -n 's/[ ]*state.* \([^ ]*\)).*/\1/p'" + +# Print previous command into a file +getlast () { + fc -nl $((HISTCMD - 1)) +} + +alias pp='getlast 2>&1 |&tee -a output.txt' + +# Print output of a command NOTE: Must be used in conjunction but no need for "|" symbol +alias -g cap='2>&1 | tee -a output.txt' + +# confirmation # +alias mv='mv -i' +alias cp='cp -i' +alias ln='ln -i' +alias rm='rm -i' + +# Suspend(sleep)/hibernate and lock screen if using systemctl +alias suspend='systemctl suspend && betterlockscreen --lock dimblur' +alias hibernate='systemctl hibernate' + +# Kubernetes +# kubernetes aliases +if command -v kubectl > /dev/null; then + replaceNS() { kubectl config view --minify --flatten --context=$(kubectl config current-context) | yq ".contexts[0].context.namespace=\"$1\"" ; } + alias kks='KUBECONFIG=<(replaceNS "kube-system") kubectl' + alias kam='KUBECONFIG=<(replaceNS "authzed-monitoring") kubectl' + alias kas='KUBECONFIG=<(replaceNS "authzed-system") kubectl' + alias kar='KUBECONFIG=<(replaceNS "authzed-region") kubectl' + alias kt='KUBECONFIG=<(replaceNS "tenant") kubectl' + + if command -v kubectl-krew > /dev/null; then + path=($XDG_CONFIG_HOME/krew/bin $path) + fi + + rmfinalizers() { + kubectl get deployment "$1" -o json | jq '.metadata.finalizers = null' | kubectl apply -f - + } +fi + +# Alias for android-studio +alias android-studio='/opt/android-studio/bin/studio.sh' + +# NVM +#nvm() { +# local green_color +# green_color=$(tput setaf 2) +# local reset_color +# reset_color=$(tput sgr0) +# echo -e "${green_color}nvm${reset_color} $@" +#} + +if [ -s "$NVM_DIR/nvm.sh" ]; then + nvm_cmds=(nvm node npm yarn) + for cmd in "${nvm_cmds[@]}"; do + alias "$cmd"="unalias ${nvm_cmds[*]} && unset nvm_cmds && . $NVM_DIR/nvm.sh && $cmd" + done +fi + + +########## Source Plugins, should be last ########## +#source /usr/share/nvm/init-nvm.sh + +# Load fzf keybindings and completion +source /usr/local/bin/fzf/shell/key-bindings.zsh +source /usr/local/bin/fzf/shell/completion.zsh + +# Suggest aliases for commands +source ~/.config/zsh/plugins/zsh-you-should-use/you-should-use.plugin.zsh + +# Load zsh-syntax-highlighting +source ~/.config/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + +# Load fish like auto suggestions +source ~/.config/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh +source ~/.config/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh |
