diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa1cb74 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +palette.yml diff --git a/README.md b/README.md index f2dedb9..4c1ad77 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ ## dotfiles v2 -This is the continuation of my old dotfiles, which now only contains stuff I really need. +This is the continuation of [my old dotfiles](https://git.disroot.org/FollieHiyuki/dotfiles), now contains only stuff I really need. + Managed with `ansible`. -### Notes +### 📓 Notes -I use Alpine-edge aka. the best binary distro on Earth :). Therefore some tasks won't work on other distros (eg. `apk` tasks) +I use Alpine-edge aka. the best binary distro on Earth 😃. Therefore some tasks won't work on other distros (eg. `apk` tasks) ### 🌟 Credits diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..e577f1e --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory = ./hosts +display_skipped_hosts = False +host_key_checking = False +interpreter_python = auto_silent diff --git a/dotfiles.yml b/dotfiles.yml index c087451..3b175f5 100644 --- a/dotfiles.yml +++ b/dotfiles.yml @@ -1,4 +1,14 @@ -- name: Setup local dotfiles - hosts: localhost +--- +- hosts: all + gather_facts: yes + +- hosts: all roles: + - palette + +- hosts: all + vars_files: + - '{{ ansible_env.PWD }}/palette.yml' + roles: + - alacritty - nvim diff --git a/group_vars/all.yml b/group_vars/all.yml new file mode 100644 index 0000000..5f90aed --- /dev/null +++ b/group_vars/all.yml @@ -0,0 +1,6 @@ +--- +user_name: FollieHiyuki +user_email: folliekazetani@protonmail.com +term_font: Iosevka Nerd Font +cjk_font: Sarasa Mono J +theme: nord diff --git a/roles/alacritty/tasks/main.yml b/roles/alacritty/tasks/main.yml new file mode 100644 index 0000000..6126797 --- /dev/null +++ b/roles/alacritty/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- name: Create config directory + file: + path: ~/.config/alacritty + state: directory + +- name: Copy config + template: + src: alacritty.j2 + dest: ~/.config/alacritty/alacritty.yml + force: yes diff --git a/roles/alacritty/templates/alacritty.j2 b/roles/alacritty/templates/alacritty.j2 new file mode 100644 index 0000000..be51874 --- /dev/null +++ b/roles/alacritty/templates/alacritty.j2 @@ -0,0 +1,373 @@ +# Configuration for Alacritty, the GPU enhanced terminal emulator. + +env: + TERM: alacritty + +window: + padding: + x: 2 + y: 2 + + dynamic_padding: false + + decorations: none + + title: Alacritty + + class: + instance: Alacritty + general: Alacritty + + gtk_theme_variant: dark + + dynamic_title: true + +scrolling: + history: 50000 + + multiplier: 5 + +font: + normal: + family: {{ term_font }} + style: Regular + + bold: + family: {{ term_font }} + style: Bold + + italic: + family: {{ term_font }} + style: Italic + + bold_italic: + family: {{ term_font }} + style: Bold Italic + + size: 14 + + offset: + x: 0 + y: 0 + + glyph_offset: + x: 0 + y: 0 + +draw_bold_text_with_bright_colors: false + +colors: + primary: + background: '{{ background }}' + foreground: '{{ foreground }}' + + cursor: + text: '{{ background }}' + cursor: '{{ foreground }}' + + selection: + text: '{{ background }}' + background: '{{ foreground }}' + + normal: + black: '{{ color0 }}' + red: '{{ color1 }}' + green: '{{ color2 }}' + yellow: '{{ color3 }}' + blue: '{{ color4 }}' + magenta: '{{ color5 }}' + cyan: '{{ color6 }}' + white: '{{ color7 }}' + + bright: + black: '{{ color8 }}' + red: '{{ color9 }}' + green: '{{ color10 }}' + yellow: '{{ color11 }}' + blue: '{{ color12 }}' + magenta: '{{ color13 }}' + cyan: '{{ color14 }}' + white: '{{ color15 }}' + +background_opacity: 1.0 + +selection: + #semantic_escape_chars: ",│`|:\"' ()[]{}<>\t" + + # When set to `true`, selected text will be copied to the primary clipboard. + save_to_clipboard: false + +cursor: + # Cursor style + # + # Values for `style`: + # - ▇ Block + # - _ Underline + # - | Beam + style: Block + #vi_mode_style: None + + # If this is `true`, the cursor will be rendered as a hollow box when the + # window is not focused. + unfocused_hollow: true + +# Live config reload (changes require restart) +live_config_reload: false + +#shell: +# program: /bin/bash +# args: +# - --login + +# Startup directory +# +# Directory the shell is started in. If this is unset, or `None`, the working +# directory of the parent process will be used. +working_directory: None + +# Send ESC (\x1b) before characters when alt is pressed. +#alt_send_esc: true + +mouse: +# Click settings +# +# The `double_click` and `triple_click` settings control the time +# alacritty should wait for accepting multiple clicks as one double +# or triple click. + double_click: { threshold: 300 } + triple_click: { threshold: 300 } + + # If this is `true`, the cursor is temporarily hidden when typing. + hide_when_typing: true + +url: +# URL launcher +# +# This program is executed when clicking on a text which is recognized as a URL. +# The URL is always added to the command as the last parameter. +# +# When set to `None`, URL launching will be disabled completely. +# +# Default: +# - (macOS) open +# - (Linux/BSD) xdg-open +# - (Windows) explorer + launcher: + program: xdg-open + args: [] + + # URL modifiers + # + # These are the modifiers that need to be held down for opening URLs when clicking + # on them. The available modifiers are documented in the key binding section. + modifiers: None + +# Mouse bindings +# +# Mouse bindings are specified as a list of objects, much like the key +# bindings further below. +# +# To trigger mouse bindings when an application running within Alacritty captures the mouse, the +# `Shift` modifier is automatically added as a requirement. +# +# Each mouse binding will specify a: +# +# - `mouse`: +# +# - Middle +# - Left +# - Right +# - Numeric identifier such as `5` +# +# - `action` (see key bindings) +# +# And optionally: +# +# - `mods` (see key bindings) +mouse_bindings: + - { mouse: Middle, action: PasteSelection } + +# Key bindings +# +# Key bindings are specified as a list of objects. For example, this is the +# default paste binding: +# +# `- { key: V, mods: Control|Shift, action: Paste }` +# +# Each key binding will specify a: +# +# - `key`: Identifier of the key pressed +# +# - A-Z +# - F1-F24 +# - Key0-Key9 +# +# A full list with available key codes can be found here: +# https://docs.rs/glutin/*/glutin/event/enum.VirtualKeyCode.html#variants +# +# Instead of using the name of the keys, the `key` field also supports using +# the scancode of the desired key. Scancodes have to be specified as a +# decimal number. This command will allow you to display the hex scancodes +# for certain keys: +# +# `showkey --scancodes`. +# +# Then exactly one of: +# +# - `chars`: Send a byte sequence to the running application +# +# The `chars` field writes the specified string to the terminal. This makes +# it possible to pass escape sequences. To find escape codes for bindings +# like `PageUp` (`"\x1b[5~"`), you can run the command `showkey -a` outside +# of tmux. Note that applications use terminfo to map escape sequences back +# to keys. It is therefore required to update the terminfo when changing an +# escape sequence. +# +# - `action`: Execute a predefined action +# +# - Copy +# - Paste +# - PasteSelection +# - IncreaseFontSize +# - DecreaseFontSize +# - ResetFontSize +# - ScrollPageUp +# - ScrollPageDown +# - ScrollLineUp +# - ScrollLineDown +# - ScrollToTop +# - ScrollToBottom +# - ClearHistory +# - Hide +# - Minimize +# - Quit +# - ToggleFullscreen +# - SpawnNewInstance +# - ClearLogNotice +# - ReceiveChar +# - None +# +# (macOS only): +# - ToggleSimpleFullscreen: Enters fullscreen without occupying another space +# +# - `command`: Fork and execute a specified command plus arguments +# +# The `command` field must be a map containing a `program` string and an +# `args` array of command line parameter strings. For example: +# `{ program: "alacritty", args: ["-e", "vttest"] }` +# +# And optionally: +# +# - `mods`: Key modifiers to filter binding actions +# +# - Command +# - Control +# - Option +# - Super +# - Shift +# - Alt +# +# Multiple `mods` can be combined using `|` like this: +# `mods: Control|Shift`. +# Whitespace and capitalization are relevant and must match the example. +# +# - `mode`: Indicate a binding for only specific terminal reported modes +# +# This is mainly used to send applications the correct escape sequences +# when in different modes. +# +# - AppCursor +# - AppKeypad +# - Alt +# +# A `~` operator can be used before a mode to apply the binding whenever +# the mode is *not* active, e.g. `~Alt`. +# +# Bindings are always filled by default, but will be replaced when a new +# binding with the same triggers is defined. To unset a default binding, it can +# be mapped to the `ReceiveChar` action. Alternatively, you can use `None` for +# a no-op if you do not wish to receive input characters for that binding. +# +# If the same trigger is assigned to multiple actions, all of them are executed +# at once. +key_bindings: + - { key: V, mods: Control|Shift, action: Paste } + - { key: C, mods: Control|Shift, action: Copy } + - { key: Insert, mods: Shift, action: PasteSelection } + - { key: Key0, mods: Control, action: ResetFontSize } + - { key: Equals, mods: Control, action: IncreaseFontSize } + - { key: Minus, mods: Control, action: DecreaseFontSize } + + - { key: Paste, action: Paste } + - { key: Copy, action: Copy } + - { key: L, mods: Control, action: ClearLogNotice } + - { key: L, mods: Control, chars: "\x0c" } + - { key: PageUp, mods: Shift, action: ScrollPageUp, mode: ~Alt } + - { key: PageDown, mods: Shift, action: ScrollPageDown, mode: ~Alt } + - { key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt } + - { key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt } + + # Vi Mode + - { key: Space, mods: Shift|Control, mode: Vi, action: ScrollToBottom } + - { key: Space, mods: Shift|Control, action: ToggleViMode } + - { key: Escape, mode: Vi, action: ClearSelection } + - { key: I, mode: Vi, action: ScrollToBottom } + - { key: I, mode: Vi, action: ToggleViMode } + - { key: Y, mods: Control, mode: Vi, action: ScrollLineUp } + - { key: E, mods: Control, mode: Vi, action: ScrollLineDown } + - { key: G, mode: Vi, action: ScrollToTop } + - { key: G, mods: Shift, mode: Vi, action: ScrollToBottom } + - { key: B, mods: Control, mode: Vi, action: ScrollPageUp } + - { key: F, mods: Control, mode: Vi, action: ScrollPageDown } + - { key: U, mods: Control, mode: Vi, action: ScrollHalfPageUp } + - { key: D, mods: Control, mode: Vi, action: ScrollHalfPageDown } + - { key: Y, mode: Vi, action: Copy } + - { key: Y, mode: Vi, action: ClearSelection } + - { key: Copy, mode: Vi, action: ClearSelection } + - { key: V, mode: Vi, action: ToggleNormalSelection } + - { key: V, mods: Shift, mode: Vi, action: ToggleLineSelection } + - { key: V, mods: Control, mode: Vi, action: ToggleBlockSelection } + - { key: V, mods: Alt, mode: Vi, action: ToggleSemanticSelection } + - { key: Return, mode: Vi, action: Open } + - { key: K, mode: Vi, action: Up } + - { key: J, mode: Vi, action: Down } + - { key: H, mode: Vi, action: Left } + - { key: L, mode: Vi, action: Right } + - { key: Up, mode: Vi, action: Up } + - { key: Down, mode: Vi, action: Down } + - { key: Left, mode: Vi, action: Left } + - { key: Right, mode: Vi, action: Right } + - { key: Key0, mode: Vi, action: First } + - { key: Key4, mods: Shift, mode: Vi, action: Last } + - { key: Key6, mods: Shift, mode: Vi, action: FirstOccupied } + - { key: H, mods: Shift, mode: Vi, action: High } + - { key: M, mods: Shift, mode: Vi, action: Middle } + - { key: L, mods: Shift, mode: Vi, action: Low } + - { key: B, mode: Vi, action: SemanticLeft } + - { key: W, mode: Vi, action: SemanticRight } + - { key: E, mode: Vi, action: SemanticRightEnd } + - { key: B, mods: Shift, mode: Vi, action: WordLeft } + - { key: W, mods: Shift, mode: Vi, action: WordRight } + - { key: E, mods: Shift, mode: Vi, action: WordRightEnd } + - { key: Key5, mods: Shift, mode: Vi, action: Bracket } + - { key: Slash, mode: Vi, action: SearchForward } + - { key: Slash, mods: Shift, mode: Vi, action: SearchBackward } + - { key: N, mode: Vi, action: SearchNext } + - { key: N, mods: Shift, mode: Vi, action: SearchPrevious } + +debug: + render_timer: false + persistent_logging: false + + # Log level + # + # Values for `log_level`: + # - None + # - Error + # - Warn + # - Info + # - Debug + # - Trace + log_level: Warn + + print_events: false diff --git a/roles/nvim/files/init.lua b/roles/nvim/files/init.lua index 81d1bf5..678f374 100644 --- a/roles/nvim/files/init.lua +++ b/roles/nvim/files/init.lua @@ -1,13 +1,11 @@ -local async -async = vim.loop.new_async(vim.schedule_wrap(function() - require('autocmd') - require('plugins') - require('mappings') - async:close() -end)) - local options = require('options') options.disable_default_plugins() options.load_options() -async:send() +require('mappings').setup() +require('autocmd').setup() + +-- packer_compiled.lua exists, so don't need to load this early +vim.defer_fn(function() + require('plugins') +end, 0) diff --git a/roles/nvim/files/lua/autocmd.lua b/roles/nvim/files/lua/autocmd.lua index 6a9b5cf..76f1bcc 100644 --- a/roles/nvim/files/lua/autocmd.lua +++ b/roles/nvim/files/lua/autocmd.lua @@ -1,4 +1,6 @@ -local definitions = { +local M = {} + +local augroups = { bufs = { -- Reload vim config automatically {'BufWritePost', [[$VIM_PATH/{*.vim,*.yaml,vimrc} nested source $MYVIMRC | redraw]]}, @@ -26,12 +28,20 @@ local definitions = { } } -for group_name, definition in pairs(definitions) do - vim.api.nvim_command('augroup ' .. group_name) - vim.api.nvim_command('autocmd!') - for _, def in ipairs(definition) do - local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ') - vim.api.nvim_command(command) +local load_autocmd = function(definitions) + for group_name, definition in pairs(definitions) do + vim.api.nvim_command('augroup ' .. group_name) + vim.api.nvim_command('autocmd!') + for _, def in ipairs(definition) do + local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ') + vim.api.nvim_command(command) + end + vim.api.nvim_command('augroup END') end - vim.api.nvim_command('augroup END') end + +function M.setup() + load_autocmd(augroups) +end + +return M diff --git a/roles/nvim/files/lua/mappings.lua b/roles/nvim/files/lua/mappings.lua index 4dc5e75..312987f 100644 --- a/roles/nvim/files/lua/mappings.lua +++ b/roles/nvim/files/lua/mappings.lua @@ -1,29 +1,8 @@ local api = vim.api local wk = require('which-key') +local M = {} --- Escape to normal mode in terminal buffer -api.nvim_set_keymap('t', '', '', {noremap = true, silent = true}) - --- Continuous indent -api.nvim_set_keymap('v', '<', '', '>gv', {noremap = true, silent = true}) - --- Also move up/down virual lines (:set wrap) -api.nvim_set_keymap('n', 'j', 'gj', {noremap = true, silent = true}) -api.nvim_set_keymap('n', 'k', 'gk', {noremap = true, silent = true}) - --- winshift.nvim -api.nvim_set_keymap('n', '', ':WinShift', {noremap = true, silent = true}) -api.nvim_set_keymap('n', 'm', ':WinShift', {noremap = true, silent = true}) -api.nvim_set_keymap('n', '', ':WinShift left', {noremap = true, silent = true}) -api.nvim_set_keymap('n', '', ':WinShift down', {noremap = true, silent = true}) -api.nvim_set_keymap('n', '', ':WinShift up', {noremap = true, silent = true}) -api.nvim_set_keymap('n', '', ':WinShift right', {noremap = true, silent = true}) - ------------------ --- Normal mode -- ------------------ -wk.register({ +local normal_mappings = { -- Better Y Y = {'y$', 'Yank to eol'}, @@ -70,45 +49,16 @@ wk.register({ -- Naming common keys ['['] = { name = 'Block motions (previous)', - d = {':Lspsaga diagnostic_jump_prev', 'Previous diagnostics'}, - g = 'Previous git hunk', - m = 'Previous start of outer class', - M = 'Previous end of outer class', - ['['] = 'Previous start of outer function', - [']'] = 'Previous end of outer function' + g = 'Previous git hunk' }, [']'] = { name = 'Block motions (next)', - d = {':Lspsaga diagnostic_jump_next', 'Next diagnostics'}, - g = 'Next git hunk', - m = 'Next start of outer class', - M = 'Next end of outer class', - ['['] = 'Next start of outer function', - [']'] = 'Next end of outer function' + g = 'Next git hunk' }, g = { name = 'Goto motions', - b = { - name = 'Block', - c = 'Comment' - }, - c = { - name = 'Comment', - c = 'Current line' - }, - d = {':lua vim.lsp.buf.definition()', 'Go to definition'}, - D = {':lua vim.lsp.buf.declaration()', 'Go to declaration'}, - i = {':Lspsaga implement', 'Implementations'}, - I = {':Telescope lsp_implementations', 'Implementations (Telescope)'}, - n = { - name = 'Incremental selection', - i = 'Initialize selection' - }, - r = {':TroubleToggle lsp_references', 'References'}, - R = {':Telescope lsp_references', 'References (Telescope)'}, t = {':TodoTrouble', 'Todo list'} }, - K = {':Lspsaga hover_doc', 'Hover doc'}, z = {name = 'Misc utils'}, -- Move between tabs @@ -126,54 +76,9 @@ wk.register({ S = {':HopWord', 'Hop to word'}, [''] = {':HopChar1', 'Hop to character'}, [''] = {':HopPattern', 'Hop to pattern'} -}) - ------------------ --- Visual mode -- ------------------ -wk.register({ - a = { - c = 'Outer class', - f = 'Outer function' - }, - - i = { - c = 'Inner class', - f = 'Inner function' - }, - - g = { - c = 'Comment', - n = { - name = 'Incremental selection', - n = 'Increment node', - s = 'Increment scope', - m = 'Decrement node' - } - } -}, {mode = 'v'}) - ------------------------------------ --- Normal mode (with leader key) -- ------------------------------------ -wk.register({ - b = { - name = 'Buffer', - c = {':ColorizerToggle', 'Colorizer'}, - d = { - name = 'Delete', - a = {':BDelete all', 'All buffers'}, - d = {':BDelete this', 'Current buffer'}, - h = {':BDelete hidden', 'Hidden buffers'}, - n = {':BDelete nameless', 'Buffers without name'}, - o = {':BDelete other', 'Other buffers'} - }, - j = {':BufferLineCyclePrev', 'Previous buffer'}, - k = {':BufferLineCycleNext', 'Next buffer'}, - n = {':enew', 'New buffer'}, - u = {':UndotreeToggle', 'Undotree'} - }, +} +local normal_leader_mappings = { d = { name = 'DAP', b = 'Toggle breakpoint', @@ -205,23 +110,22 @@ wk.register({ if venn_enabled == 'nil' then vim.b.venn_enabled = true vim.api.nvim_command('setlocal virtualedit=all') - -- Draw lines with HJKL keystroke - vim.api.nvim_buf_set_keymap(0, 'n', 'H', 'h:VBox', {noremap = true, silent = true}) - vim.api.nvim_buf_set_keymap(0, 'n', 'J', 'j:VBox', {noremap = true, silent = true}) - vim.api.nvim_buf_set_keymap(0, 'n', 'K', 'k:VBox', {noremap = true, silent = true}) - vim.api.nvim_buf_set_keymap(0, 'n', 'L', 'l:VBox', {noremap = true, silent = true}) + -- Draw lines with WASD keystroke + vim.api.nvim_buf_set_keymap(0, 'n', 'A', 'h:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', 'S', 'j:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', 'W', 'k:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', 'D', 'l:VBox', {noremap = true, silent = true}) -- Draw boxes by pressing 'f' with visual selection vim.api.nvim_buf_set_keymap(0, 'v', 'f', ':VBox', {noremap = true, silent = true}) vim.notify('Virtual box edit enabled.', vim.log.levels.INFO) else vim.b.venn_enabled = nil vim.api.nvim_command('setlocal virtualedit=block') - -- vim.api.nvim_command('mapclear ') -- quicker, but also deletes buf keymap for lsp vim.api.nvim_buf_del_keymap(0, 'v', 'f') - vim.api.nvim_buf_del_keymap(0, 'n', 'H') - vim.api.nvim_buf_del_keymap(0, 'n', 'J') - vim.api.nvim_buf_del_keymap(0, 'n', 'K') - vim.api.nvim_buf_del_keymap(0, 'n', 'L') + vim.api.nvim_buf_del_keymap(0, 'n', 'A') + vim.api.nvim_buf_del_keymap(0, 'n', 'S') + vim.api.nvim_buf_del_keymap(0, 'n', 'W') + vim.api.nvim_buf_del_keymap(0, 'n', 'D') vim.notify('Virtual box edit disabled.', vim.log.levels.INFO) end end, @@ -287,37 +191,11 @@ wk.register({ c = {'cw=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]', 'Translate and replace with direction'} }, - l = { - name = 'LSP', - a = {':lua vim.lsp.buf.add_workspace_folder()', 'Add workspace folder'}, - b = {':TroubleToggle lsp_document_diagnostics', 'Buffer diagnostics'}, - B = {':Telescope lsp_document_diagnostics', 'Buffer diagnostics (Telescope)'}, - c = {':Lspsaga code_action', 'Code action'}, - C = {':Telescope lsp_code_actions', 'Code action (Telescope)'}, - d = {':TroubleToggle lsp_definitions', 'Definitions'}, - D = {':Telescope lsp_definitions', 'Definitions (Telescope)'}, - e = {':Lspsaga show_line_diagnostics', 'Line diagnostics'}, - f = {':Lspsaga lsp_finder', 'Finder'}, - g = {':SymbolsOutline', 'Symbol outline'}, - l = {':TroubleToggle loclist', 'Diagnostics loclist'}, - n = {':Lspsaga rename', 'Rename'}, - o = 'Format buffer', - p = {':Lspsaga preview_definition', 'Preview definition'}, - r = {':lua vim.lsp.buf.remove_workspace_folder()', 'Remove workspace folder'}, - s = {':Telescope lsp_document_symbols', 'Buffer symbols'}, - S = {':Telescope lsp_workspace_symbols', 'Workspace symbols'}, - t = {':TroubleToggle', 'Toggle Trouble'}, - w = {':TroubleToggle lsp_workspace_diagnostics', 'Workspace diagnostics'}, - W = {':Telescope lsp_workspace_diagnostics', 'Workspace diagnostics (Telescope)'}, - x = {':lua vim.lsp.buf.signature_help()', 'Signature help'}, - y = {':lua vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders()), vim.log.levels.INFO)', 'List workspace folders'} - }, - p = { name = 'Find/Replace', o = 'Open spectre', p = 'Search in current file', - w = 'Find/replace cursorword' + w = 'Find/Replace cursorword' }, r = { @@ -337,14 +215,11 @@ wk.register({ w = {':WindowPick', 'Pick window'} -}, {prefix = ''}) +} ------------------------------------ --- Visual mode (with leader key) -- ------------------------------------ -wk.register({ - a = { - name = 'Action', +local visual_leader_mappings = { + e = { + name = 'Editor', a = {':EasyAlign', 'Range align'} }, @@ -368,77 +243,72 @@ wk.register({ c = {'c=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]', 'Translate and replace with direction'} }, - l = { - name = 'LSP', - c = {':Lspsaga range_code_action', 'Range code action'}, - C = {':Telescope lsp_range_code_actions', 'Range code action (Telescope)'}, - o = 'Range format' - }, - p = 'Find/Replace' -}, {mode = 'v', prefix = ''}) +} ------------------------- --- Filetype specified -- ------------------------- --- FIX: not working????? -vim.api.nvim_command [[ -autocmd FileType org lua WhichkeyOrg() -autocmd FileType markdown lua WhichkeyMarkdown() -autocmd FileType html lua WhichkeyHtml() -]] - -function WhichkeyOrg() - wk.register({ - ['o'] = { - name = 'Org', - a = 'Agenda', - A = 'Toggle ARCHIVE', - c = 'Capture', - e = 'Export', - i = { - name = 'Insert', - h = 'Add headline', - t = 'Add TODO heading and content', - T = 'Add TODO heading', +local localleader_mappings = function() + vim.api.nvim_command('autocmd BufReadPre,BufNewFile * lua WhichkeyLocal()') + function WhichkeyLocal() + local bufnr = vim.api.nvim_get_current_buf() + wk.register({ + c = {':ColorizerToggle', 'Colorizer'}, + d = { + name = 'Delete', + a = {':BDelete all', 'All buffers'}, + d = {':BDelete this', 'Current buffer'}, + h = {':BDelete hidden', 'Hidden buffers'}, + n = {':BDelete nameless', 'Buffers without name'}, + o = {':BDelete other', 'Other buffers'} }, - J = 'Move subtree down', - K = 'Move subtree up', - o = 'Open at point', - r = 'Refile', - t = 'Set tags', - ['$'] = 'Archive current headline' - }, - [''] = 'Org meta return', - [''] = 'Org increase date', - [''] = 'Org decrease date', - ['cid'] = 'Org change date', - ['cit'] = 'Org TODO', - ['ciT'] = 'Org TODO prev', - [''] = 'Org toggle checkbox', - [''] = 'Org cycle folding', - [''] = 'Org cycle global folding', - ['<<'] = 'Org promote headline', - ['>>'] = 'Org demote headline', - ['s'] = 'Org demote subtree', - ['}'] = 'Org next visible heading', - ['{'] = 'Org previous visible heading', - [']]'] = 'Org forward heading', - ['[['] = 'Org backward heading', - ['g{'] = 'Org parent heading', - ['?'] = 'Org help' - }, {buffer = vim.api.nvim_get_current_buf()}) + j = {':BufferLineCyclePrev', 'Previous buffer'}, + k = {':BufferLineCycleNext', 'Next buffer'}, + n = {':enew', 'New buffer'}, + u = {':UndotreeToggle', 'Undotree'} + }, {buffer = bufnr, prefix = ''}) + end + + vim.api.nvim_command('autocmd FileType markdown lua WhichkeyMarkdown()') + function WhichkeyMarkdown() + wk.register({ + p = {':MarkdownPreviewToggle', 'Preview markdown'} + }, {buffer = vim.api.nvim_get_current_buf(), prefix = ''}) + end + + vim.api.nvim_command('autocmd FileType html lua WhichkeyHtml()') + function WhichkeyHtml() + wk.register({ + p = {':Bracey', 'Preview html'} + }, {buffer = vim.api.nvim_get_current_buf(), prefix = ''}) + end end -function WhichkeyMarkdown() - wk.register({ - ['bp'] = {':MarkdownPreviewToggle', 'Preview markdown'} - }, {buffer = vim.api.nvim_get_current_buf()}) +local undefined_mappings = function() + -- Escape to normal mode in terminal buffer + api.nvim_set_keymap('t', '', '', {noremap = true, silent = true}) + + -- Continuous indent + api.nvim_set_keymap('v', '<', '', '>gv', {noremap = true, silent = true}) + + -- Also move up/down virual lines (:set wrap) + api.nvim_set_keymap('n', 'j', 'gj', {noremap = true, silent = true}) + api.nvim_set_keymap('n', 'k', 'gk', {noremap = true, silent = true}) + + -- winshift.nvim + api.nvim_set_keymap('n', '', ':WinShift', {noremap = true, silent = true}) + api.nvim_set_keymap('n', 'm', ':WinShift', {noremap = true, silent = true}) + api.nvim_set_keymap('n', '', ':WinShift left', {noremap = true, silent = true}) + api.nvim_set_keymap('n', '', ':WinShift down', {noremap = true, silent = true}) + api.nvim_set_keymap('n', '', ':WinShift up', {noremap = true, silent = true}) + api.nvim_set_keymap('n', '', ':WinShift right', {noremap = true, silent = true}) end -function WhichkeyHtml() - wk.register({ - ['bp'] = {':Bracey', 'Preview html'} - }, {buffer = vim.api.nvim_get_current_buf()}) +function M.setup() + undefined_mappings() + localleader_mappings() + wk.register(normal_mappings) + wk.register(normal_leader_mappings, {prefix = ''}) + wk.register(visual_leader_mappings, {mode = 'v', prefix = ''}) end + +return M diff --git a/roles/nvim/files/lua/modules/editor.lua b/roles/nvim/files/lua/modules/editor.lua index 2cd53f1..6cb2f7d 100644 --- a/roles/nvim/files/lua/modules/editor.lua +++ b/roles/nvim/files/lua/modules/editor.lua @@ -47,6 +47,101 @@ function M.blankline_conf() -- vim.api.nvim_command('autocmd CursorMoved * IndentBlanklineRefresh') end +function M.orgmode_conf() + local c = require('themes.' .. vim.g.colors_name .. '.colors') + + require('orgmode').setup { + -- General settings + org_agenda_files = {'~/Documents/Org/agenda/*'}, + org_default_notes_file = '~/Documents/Org/notes.org', + org_todo_keywords = { + 'TODO', 'PROJ', 'LOOP', 'STRT', 'WAIT', 'HOLD', 'IDEA', 'DONE', 'KILL', + '[ ]', '[-]', '[X]' , '|', 'OKAY', 'YES', 'NO' + }, + org_todo_keyword_faces = { + TODO = ':foreground ' .. c.green .. ' :weight bold', + PROJ = ':foreground ' .. c.grey_bright .. ' :weight bold :slant italic', + LOOP = ':foreground ' .. c.green .. ' :weight bold :underline on', + STRT = ':foreground ' .. c.blue .. ' :weight bold', + WAIT = ':foreground ' .. c.yellow .. ' :weight bold', + HOLD = ':foreground ' .. c.yellow .. ' :weight bold :slant italic', + IDEA = ':foreground ' .. c.green .. ' :weight bold :slant italic', + DONE = ':foreground ' .. c.grey2 .. ' :weight bold', + KILL = ':foreground ' .. c.red .. ' :weight bold', + OKAY = ':foreground ' .. c.grey1 .. ' :weight bold :slant italic', + YES = ':foreground ' .. c.grey1 .. ' :weight bold :underline on', + NO = ':foreground ' .. c.red .. ' :weight bold :underline on' + }, + org_hide_leading_stars = true, + org_highlight_latex_and_related = 'entities', + + -- Agenda settings + org_deadline_warning_days = 7, + org_agenda_span = 'week', + org_agenda_start_on_weekday = 7, -- Start a week in Sunday + org_agenda_min_height = 15, + + -- Tags settings + org_use_tag_inheritance = false + } + + -- Define mappings's names + vim.api.nvim_command('autocmd FileType org lua WhichkeyOrg()') + local wk = require('which-key') + function WhichkeyOrg() + wk.register({ + ['o'] = { + name = 'Org', + a = 'Agenda', + A = 'Toggle ARCHIVE', + c = 'Capture', + e = 'Export', + i = { + name = 'Insert', + h = 'Add headline', + t = 'Add TODO heading and content', + T = 'Add TODO heading' + }, + J = 'Move subtree down', + K = 'Move subtree up', + o = 'Open at point', + r = 'Refile', + t = 'Set tags', + ['$'] = 'Archive current headline' + }, + [''] = 'Org meta return', + [''] = 'Org increase date', + [''] = 'Org decrease date', + ['cid'] = 'Org change date', + ['cit'] = 'Org TODO', + ['ciT'] = 'Org TODO prev', + [''] = 'Org toggle checkbox', + [''] = 'Org cycle folding', + [''] = 'Org cycle global folding', + ['<<'] = 'Org promote headline', + ['>>'] = 'Org demote headline', + ['s'] = 'Org demote subtree', + ['}'] = 'Org next visible heading', + ['{'] = 'Org previous visible heading', + [']]'] = 'Org forward heading', + ['[['] = 'Org backward heading', + ['g{'] = 'Org parent heading', + ['?'] = 'Org help' + }, {buffer = vim.api.nvim_get_current_buf()}) + end +end + +function M.bullets_conf() + require('org-bullets').setup { + symbols = {'', '', '', ''} + } +end + +function M.headlines_conf() + require('headlines').setup() +end + function M.treesitter_conf() -- Additional parser for rest.nvim (*.http files) local parser_configs = require('nvim-treesitter.parsers').get_parser_configs() @@ -145,6 +240,52 @@ function M.treesitter_conf() -- tree-sitter based folding vim.opt.foldmethod = 'expr' vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' + + -- Define mappings' names + local wk = require('which-key') + local mappings = { + ['['] = { + m = 'Previous start of outer class', + M = 'Previous end of outer class', + ['['] = 'Previous start of outer function', + [']'] = 'Previous end of outer function' + }, + [']'] = { + m = 'Next start of outer class', + M = 'Next end of outer class', + ['['] = 'Next start of outer function', + [']'] = 'Next end of outer function' + }, + g = { + n = { + name = 'Incremental selection', + i = 'Initialize selection' + } + } + } + local visual_mappings = { + a = { + c = 'Outer class', + f = 'Outer function' + }, + + i = { + c = 'Inner class', + f = 'Inner function' + }, + + g = { + n = { + name = 'Incremental selection', + n = 'Increment node', + s = 'Increment scope', + m = 'Decrement node' + } + } + } + + wk.register(mappings) + wk.register(visual_mappings, {mode = 'v'}) end function M.iswap_conf() diff --git a/roles/nvim/files/lua/modules/lsp.lua b/roles/nvim/files/lua/modules/lsp.lua index 8880f12..abfaa54 100644 --- a/roles/nvim/files/lua/modules/lsp.lua +++ b/roles/nvim/files/lua/modules/lsp.lua @@ -12,7 +12,7 @@ function M.signature_conf() transpancy = 5, handler_opts = {border = 'single'}, zindex = 50, -- set to 200 to make the float window on top of others - toggle_key = '' + toggle_key = '' } end @@ -62,30 +62,83 @@ end function M.lsp_conf() local lspconf = require('lspconfig') + local lsp_mappings = { + g = { + d = {':lua vim.lsp.buf.definition()', 'Goto definition'}, + D = {':lua vim.lsp.buf.declaration()', 'Goto declaration'}, + i = {':Lspsaga implement', 'Implementations'}, + I = {':Telescope lsp_implementations', 'Implementations (Telescope)'}, + r = {':TroubleToggle lsp_references', 'References'}, + R = {':Telescope lsp_references', 'References (Telescope)'} + }, + K = {':Lspsaga hover_doc', 'Hover doc'}, + ['[d'] = {':Lspsaga diagnostic_jump_prev', 'Previous diagnostics'}, + [']d'] = {':Lspsaga diagnostic_jump_next', 'Next diagnostics'} + } + local lsp_leader_mappings = { + l = { + name = 'LSP', + a = {':lua vim.lsp.buf.add_workspace_folder()', 'Add workspace folder'}, + b = {':TroubleToggle lsp_document_diagnostics', 'Buffer diagnostics'}, + B = {':Telescope lsp_document_diagnostics', 'Buffer diagnostics (Telescope)'}, + c = {':Lspsaga code_action', 'Code action'}, + C = {':Telescope lsp_code_actions', 'Code action (Telescope)'}, + d = {':TroubleToggle lsp_definitions', 'Definitions'}, + D = {':Telescope lsp_definitions', 'Definitions (Telescope)'}, + e = {':Lspsaga show_line_diagnostics', 'Line diagnostics'}, + f = {':Lspsaga lsp_finder', 'Finder'}, + g = {':SymbolsOutline', 'Symbol outline'}, + i = {':LspInfo', 'Lsp info'}, + l = {':TroubleToggle loclist', 'Diagnostics loclist'}, + n = {':Lspsaga rename', 'Rename'}, + p = {':Lspsaga preview_definition', 'Preview definition'}, + r = {':lua vim.lsp.buf.remove_workspace_folder()', 'Remove workspace folder'}, + s = {':Telescope lsp_document_symbols', 'Buffer symbols'}, + S = {':Telescope lsp_workspace_symbols', 'Workspace symbols'}, + t = {':TroubleToggle', 'Toggle Trouble'}, + w = {':TroubleToggle lsp_workspace_diagnostics', 'Workspace diagnostics'}, + W = {':Telescope lsp_workspace_diagnostics', 'Workspace diagnostics (Telescope)'}, + x = {':lua vim.lsp.buf.signature_help()', 'Signature help'}, + y = {':lua vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders()), vim.log.levels.INFO)', 'List workspace folders'} + } + } + local lsp_visual_mappings = { + l = { + name = 'LSP', + c = {':Lspsaga range_code_action', 'Range code action'}, + C = {':Telescope lsp_range_code_actions', 'Range code action (Telescope)'} + } + } local on_attach = function(client, bufnr) vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - local function buf_set_keymap(...) - vim.api.nvim_buf_set_keymap(bufnr, ...) - end + local wk = require('which-key') + wk.register(lsp_mappings, {buffer = bufnr}) + wk.register(lsp_leader_mappings, {buffer = bufnr, prefix = ''}) + wk.register(lsp_visual_mappings, {buffer = bufnr, prefix = '', mode = 'v'}) local opts = {noremap = true, silent = true} - buf_set_keymap('n', '', ':lua require("lspsaga.action").smart_scroll_with_saga(1)', opts) - buf_set_keymap('n', '', ':lua require("lspsaga.action").smart_scroll_with_saga(-1)', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', ':lua require("lspsaga.action").smart_scroll_with_saga(1)', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', ':lua require("lspsaga.action").smart_scroll_with_saga(-1)', opts) if client.resolved_capabilities.document_formatting then - buf_set_keymap('n', 'lo', ':lua vim.lsp.buf.formatting()', opts) + wk.register({ + ['lo'] = {':lua vim.lsp.buf.formatting()', 'Format buffer'} + }, {buffer = bufnr, prefix = ''}) -- vim.api.nvim_command('autocmd BufWritePre lua vim.lsp.buf.formatting_sync()') elseif client.resolved_capabilities.document_range_formatting then - buf_set_keymap('n', 'lo', ':lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})', opts) - buf_set_keymap('v', 'lo', ':lua vim.lsp.buf.range_formatting()', opts) + wk.register({ + ['lo'] = {':lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})', 'Format buffer'} + }, {buffer = bufnr, prefix = ''}) + wk.register({ + ['lo'] = {':lua vim.lsp.buf.range_formatting()', 'Format range'} + }, {buffer = bufnr, prefix = '', mode = 'v'}) -- vim.api.nvim_command('autocmd BufWritePre lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})') end end local capabilities = vim.lsp.protocol.make_client_capabilities() - -- Add additional capabilities supported by nvim-cmp local completionItem = capabilities.textDocument.completion.completionItem completionItem.documentationFormat = {'markdown', 'plaintext'} @@ -662,6 +715,7 @@ function M.dapui_conf() 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', mappings = { close = {'q', ''} } diff --git a/roles/nvim/files/lua/modules/tools.lua b/roles/nvim/files/lua/modules/tools.lua index 15f0991..1e14ebf 100644 --- a/roles/nvim/files/lua/modules/tools.lua +++ b/roles/nvim/files/lua/modules/tools.lua @@ -107,55 +107,6 @@ function M.rest_conf() } end -function M.orgmode_conf() - local c = require('themes.' .. vim.g.colors_name .. '.colors') - - require('orgmode').setup { - -- General settings - org_agenda_files = {'~/Documents/Org/agenda/*'}, - org_default_notes_file = '~/Documents/Org/notes.org', - org_todo_keywords = { - 'TODO', 'PROJ', 'LOOP', 'STRT', 'WAIT', 'HOLD', 'IDEA', 'DONE', 'KILL', - '[ ]', '[-]', '[X]' , '|', 'OKAY', 'YES', 'NO' - }, - org_todo_keyword_faces = { - TODO = ':foreground ' .. c.green .. ' :weight bold', - PROJ = ':foreground ' .. c.grey_bright .. ' :weight bold :slant italic', - LOOP = ':foreground ' .. c.green .. ' :weight bold :underline on', - STRT = ':foreground ' .. c.blue .. ' :weight bold', - WAIT = ':foreground ' .. c.yellow .. ' :weight bold', - HOLD = ':foreground ' .. c.yellow .. ' :weight bold :slant italic', - IDEA = ':foreground ' .. c.green .. ' :weight bold :slant italic', - DONE = ':foreground ' .. c.grey2 .. ' :weight bold', - KILL = ':foreground ' .. c.red .. ' :weight bold', - OKAY = ':foreground ' .. c.grey1 .. ' :weight bold :slant italic', - YES = ':foreground ' .. c.grey1 .. ' :weight bold :underline on', - NO = ':foreground ' .. c.red .. ' :weight bold :underline on' - }, - org_hide_leading_stars = true, - org_highlight_latex_and_related = 'entities', - - -- Agenda settings - org_deadline_warning_days = 7, - org_agenda_span = 'week', - org_agenda_start_on_weekday = 7, -- Start a week in Sunday - org_agenda_min_height = 15, - - -- Tags settings - org_use_tag_inheritance = false - } -end - -function M.bullets_conf() - require('org-bullets').setup { - symbols = {'', '', '', ''} - } -end - -function M.headlines_conf() - require('headlines').setup() -end - function M.spectre_conf() require('spectre').setup() diff --git a/roles/nvim/files/lua/plugins.lua b/roles/nvim/files/lua/plugins.lua index 62c9461..ea99517 100644 --- a/roles/nvim/files/lua/plugins.lua +++ b/roles/nvim/files/lua/plugins.lua @@ -1,22 +1,23 @@ +-- TODO: rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, nvim-bqf, +-- nvim-comment-frame, nvim-revJ.lua, nvim-remote-containers, tex.nvim, +-- telescope-dap.nvim, fcitx.nvim, pandoc.nvim local packer = require('modules.pack') -- This is recommended when using `luafile ` a lot --- packer.reset() +packer.reset() -return packer.startup(function(use) +-- Necessary stuff +local needed_plugins = function(use) use {'wbthomason/packer.nvim', opt = true} - --------------------------------- - -- Plugins used by many others -- - --------------------------------- use {'kyazdani42/nvim-web-devicons', module = 'nvim-web-devicons'} use {'nvim-lua/plenary.nvim', module = 'plenary'} use {'nvim-lua/popup.nvim', module = 'popup'} +end - -------- - -- UI -- - -------- - local ui = require('modules.ui') +-- UI components +local ui = require('modules.ui') +local ui_plugins = function(use) use { 'goolord/alpha-nvim', event = 'VimEnter', @@ -40,7 +41,6 @@ return packer.startup(function(use) } use { 'folke/which-key.nvim', - event = 'VimEnter', config = ui.whichkey_conf } use { @@ -49,11 +49,11 @@ return packer.startup(function(use) wants = 'plenary.nvim', config = ui.gitsigns_conf } +end - ------------ - -- Editor -- - ------------ - local editor = require('modules.editor') +-- Editing-related plugins +local editor = require('modules.editor') +local editor_plugins = function(use) use { 'norcalli/nvim-colorizer.lua', cmd = 'ColorizerToggle', @@ -68,6 +68,23 @@ return packer.startup(function(use) 'Olical/conjure', ft = {'clojure', 'fennel', 'scheme', 'hy', 'janet', 'racket'} } + use { -- TODO: check out neorg + 'kristijanhusak/orgmode.nvim', + ft = 'org', + requires = { + { + 'akinsho/org-bullets.nvim', + after = 'orgmode.nvim', + config = editor.bullets_conf + }, + { + 'lukas-reineke/headlines.nvim', + after = 'orgmode.nvim', + config = editor.headlines_conf + } + }, + config = editor.orgmode_conf + } use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', @@ -176,11 +193,11 @@ return packer.startup(function(use) config = editor.gitlinker_conf } use {'jbyuki/venn.nvim', cmd = 'VBox'} +end - --------- - -- LSP -- - --------- - local lsp = require('modules.lsp') +-- LSP-related +local lsp = require('modules.lsp') +local lsp_plugins = function(use) use { 'neovim/nvim-lspconfig', event = 'BufReadPre', @@ -242,11 +259,11 @@ return packer.startup(function(use) }}, config = lsp.dapui_conf } +end - ---------------- - -- Completion -- - ---------------- - local completion = require('modules.completion') +-- Completion +local completion = require('modules.completion') +local completion_plugins = function(use) use { 'hrsh7th/nvim-cmp', event = {'InsertEnter', 'CmdlineEnter'}, @@ -291,11 +308,11 @@ return packer.startup(function(use) wants = 'nvim-treesitter', config = completion.autotag_conf } +end - ----------- - -- Tools -- - ----------- - local tools = require('modules.tools') +-- Other tools +local tools = require('modules.tools') +local tools_plugins = function(use) use { -- TODO: check out fzf-lua 'nvim-telescope/telescope.nvim', cmd = 'Telescope', @@ -360,23 +377,6 @@ return packer.startup(function(use) run = 'npm install --prefix server', cmd = 'Bracey' } - use { -- TODO: check out neorg - 'kristijanhusak/orgmode.nvim', - requires = { - { - 'akinsho/org-bullets.nvim', - after = 'orgmode.nvim', - config = tools.bullets_conf - }, - { - 'lukas-reineke/headlines.nvim', - after = 'orgmode.nvim', - config = tools.headlines_conf - } - }, - ft = 'org', - config = tools.orgmode_conf - } use { 'windwp/nvim-spectre', keys = 'p', @@ -451,11 +451,19 @@ return packer.startup(function(use) config = tools.distant_conf } use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking +end - -- TODO: rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, nvim-bqf, - -- nvim-comment-frame, nvim-revJ.lua, nvim-remote-containers, tex.nvim, - -- telescope-dap.nvim, fcitx.nvim, pandoc.nvim +-- Merge everything together +local sumary = function(use) + needed_plugins(use) + ui_plugins(use) + editor_plugins(use) + lsp_plugins(use) + completion_plugins(use) + tools_plugins(use) -- Install plugins if missing packer.install() -end) +end + +return packer.startup(sumary) diff --git a/roles/nvim/files/lua/themes/nord/init.lua b/roles/nvim/files/lua/themes/nord/init.lua index 11df62f..b3c5dd2 100644 --- a/roles/nvim/files/lua/themes/nord/init.lua +++ b/roles/nvim/files/lua/themes/nord/init.lua @@ -74,6 +74,7 @@ function M.highlight_editor() hi('Directory', c.cyan, '', '', '') -- Prompt + cmd('hi! link MsgArea Normal') hi('ErrorMsg' , c.fg , c.red , '', '') hi('ModeMsg' , c.fg , '' , '', '') hi('MoreMsg' , c.cyan , '' , '', '') @@ -132,7 +133,7 @@ function M.highlight_syntax() hi('Structure', c.blue, '', '', '') hi('Tag', c.fg, '', '', '') hi('Todo', c.yellow, '', '', '') - hi('Type', c.orange, '', '', '') + hi('Type', c.dark_blue, '', 'bold', '') hi('Typedef', c.blue, '', '', '') cmd('hi! link Macro Define') cmd('hi! link PreCondit PreProc') @@ -217,8 +218,8 @@ function M.highlight_treesitter() hi('TSStringRegex', c.teal, '', '', '') hi('TSStringEscape', c.purple, '', '', '') hi('TSSymbol', c.purple, '', '', '') - hi('TSType', c.orange, '', '', '') - hi('TSTypeBuiltin', c.orange, '', '', '') + hi('TSType', c.dark_blue, '', 'bold', '') + hi('TSTypeBuiltin', c.dark_blue, '', 'bold', '') hi('TSTag', c.fg, '', '', '') hi('TSTagDelimiter', c.purple, '', '', '') hi('TSText', c.fg, '', '', '') @@ -226,8 +227,9 @@ function M.highlight_treesitter() hi('TSStrong' , c.fg, '', 'bold', '') hi('TSEmphasis', c.fg, '', 'bold,italic', '') hi('TSUnderline', '', '', 'underline', '') + hi('TSStrike', c.orange, '', 'italic', '') hi('TSTitle', c.dark_blue, '', 'bold', '') - hi('TSLiteral', c.fg, '', '', '') + hi('TSLiteral', c.green, '', 'italic', '') hi('TSURI', c.green, '', 'underline', '') cmd('hi! link TSComment Comment') @@ -286,7 +288,7 @@ function M.highlight_plugins() hi('CmpItemAbbr', c.fg, '', '', '') hi('CmpItemAbbrMatch', c.yellow, '', '', '') hi('CmpItemAbbrMatchFuzzy', c.yellow, '', '', '') - hi('CmpItemKind', c.orange, '', '', '') + hi('CmpItemKind', c.green, '', '', '') hi('CmpItemMenu', c.blue, '', '', '') -- LuaSnip diff --git a/roles/nvim/tasks/main.yml b/roles/nvim/tasks/main.yml index 8840004..99f5920 100644 --- a/roles/nvim/tasks/main.yml +++ b/roles/nvim/tasks/main.yml @@ -1,3 +1,4 @@ +--- - name: Create config directory file: path: ~/.config/nvim @@ -5,7 +6,7 @@ - name: Copy config copy: - src: "{{ ansible_env.PWD }}/roles/nvim/files/{{ item }}" + src: '{{ item }}' dest: ~/.config/nvim force: yes loop: @@ -16,9 +17,15 @@ - asynctasks.ini - init.lua +- name: Copy options.lua + template: + src: options.j2 + dest: ~/.config/nvim/lua/options.lua + force: yes + - name: Copy helper scripts copy: - src: "{{ ansible_env.PWD }}/roles/nvim/files/scripts" + src: scripts dest: ~/.config/nvim mode: u+x force: yes diff --git a/roles/nvim/files/lua/options.lua b/roles/nvim/templates/options.j2 similarity index 98% rename from roles/nvim/files/lua/options.lua rename to roles/nvim/templates/options.j2 index 5bdeceb..7952208 100644 --- a/roles/nvim/files/lua/options.lua +++ b/roles/nvim/templates/options.j2 @@ -25,9 +25,10 @@ end function M.load_options() -- This is the same as `:colorscheme nord/onedark` - vim.g.colors_name = 'nord' + vim.g.colors_name = '{{ theme }}' -- Leader key vim.g.mapleader = ' ' + vim.g.maplocalleader = ',' -- Python path vim.g.python3_host_prog = '/usr/bin/python3' diff --git a/roles/palette/tasks/main.yml b/roles/palette/tasks/main.yml new file mode 100644 index 0000000..ea5d027 --- /dev/null +++ b/roles/palette/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- name: Check theme name + fail: + msg: Theme needs to be 'nord' or 'onedark' + when: theme != 'nord' and theme != 'onedark' + +- name: Create color variables + template: + src: palette.j2 + dest: '{{ ansible_env.PWD }}/palette.yml' + force: yes diff --git a/roles/palette/templates/palette.j2 b/roles/palette/templates/palette.j2 new file mode 100644 index 0000000..d31876a --- /dev/null +++ b/roles/palette/templates/palette.j2 @@ -0,0 +1,42 @@ +--- +{% if theme == 'nord' %} +# Terminal colors +foreground: '#d8dee9' +background: '#2e3440' +color0: '#3b4252' +color1: '#bf616a' +color2: '#a3be8c' +color3: '#ebcb8b' +color4: '#81a1c1' +color5: '#b48ead' +color6: '#88c0d0' +color7: '#e5e9f0' +color8: '#4c566a' +color9: '#bf616a' +color10: '#a3be8c' +color11: '#ebcb8b' +color12: '#81a1c1' +color13: '#b48ead' +color14: '#8fbcbb' +color15: '#eceff4' +{% elif theme == 'onedark' %} +# Terminal colors +foreground: '#abb2bf' +background: '#282c34' +color0: '#3e4452' +color1: '#be5046' +color2: '#98c379' +color3: '#d19a66' +color4: '#61afef' +color5: '#c678dd' +color6: '#56b6c2' +color7: '#abb2bf' +color8: '#4b5263' +color9: '#e06c75' +color10: '#98c379' +color11: '#e5c07b' +color12: '#61afef' +color13: '#c678dd' +color14: '#56b6c2' +color15: '#bbc2cf' +{% endif %} diff --git a/test/Dockerfile b/test/Dockerfile new file mode 100644 index 0000000..7333922 --- /dev/null +++ b/test/Dockerfile @@ -0,0 +1,18 @@ +FROM alpine:latest + +# Install stuff +RUN apk --no-cache add \ + sudo ansible git neovim fish bash + +# Assure correct permission on /tmp +RUN chmod 1777 /tmp + +# Create a test user +RUN adduser -h /home/kawaii -s /usr/bin/fish -D -G wheel kawaii \ + && echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel + +# Enter testing environment +USER kawaii +WORKDIR /home/kawaii +COPY ../hosts . +CMD ["/usr/bin/fish"]