From cc2a13c3a4f94dde4e76f433c2277be7c51dd35e Mon Sep 17 00:00:00 2001 From: Carlo Gravador Date: Sun, 17 Dec 2023 10:08:04 +0800 Subject: [PATCH] Update --- .gitconfig | 20 +++++ .gitmodules | 3 + bat/themes/bat_dracula_patched | 1 + nvim/init.lua | 32 ++++++++ nvim/lua/lsp_config.lua | 6 ++ nvim/lua/packer_config.lua | 13 +++ nvim/lua/treesitter_config.lua | 16 ++-- nvim/plugin/packer_compiled.lua | 139 -------------------------------- skhd/skhdrc | 44 ++++++++++ skhd/yabai_maxmize_window.sh | 16 ++++ yabai/yabairc | 27 +++++++ 11 files changed, 170 insertions(+), 147 deletions(-) create mode 100644 .gitconfig create mode 160000 bat/themes/bat_dracula_patched delete mode 100644 nvim/plugin/packer_compiled.lua create mode 100644 skhd/skhdrc create mode 100755 skhd/yabai_maxmize_window.sh create mode 100755 yabai/yabairc diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..86af821 --- /dev/null +++ b/.gitconfig @@ -0,0 +1,20 @@ +[core] + editor = vim +[difftool] + prompt = true +[diff] + tool = nvimdiff +[difftool "nvimdiff"] + cmd = "vim -d \"$LOCAL\" \"$REMOTE\"" +[user] + name = Carlo Gravador + email = cce.gravador@gmail.com +[pager] + branch = false +[merge] + tool = vimdiff +[mergetool] + keepBackup = false + +[mergetool "vimdiff"] + cmd = vim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J' diff --git a/.gitmodules b/.gitmodules index e69de29..339db70 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "bat/themes/bat_dracula_patched"] + path = bat/themes/bat_dracula_patched + url = git@github.com:carlogravador/sublime.git diff --git a/bat/themes/bat_dracula_patched b/bat/themes/bat_dracula_patched new file mode 160000 index 0000000..f8129a0 --- /dev/null +++ b/bat/themes/bat_dracula_patched @@ -0,0 +1 @@ +Subproject commit f8129a0f1762aef0469a032d7a10c865dc03ac58 diff --git a/nvim/init.lua b/nvim/init.lua index a356557..613f4ac 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -29,3 +29,35 @@ require('nvim_tree_config') require('comment_nvim_config') require('terminal_config') + +require 'colorizer'.setup { + filetypes = { "css", "scss" }, + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + -- names = true, -- "Name" codes like Blue or blue + RRGGBBAA = false, -- #RRGGBBAA hex codes + AARRGGBB = false, -- 0xAARRGGBB hex codes + -- rgb_fn = false, -- CSS rgb() and rgba() functions + rgb_fn = true, -- CSS rgb() and rgba() functions + hsl_fn = false, -- CSS hsl() and hsla() functions + css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Available modes for `mode`: foreground, background, virtualtext + mode = "background", -- Set the display mode. + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal + tailwind = false, -- Enable tailwind colors + -- parsers can contain values used in |user_default_options| + sass = { enable = false, parsers = { "css" }, }, -- Enable sass colors + virtualtext = "■", + -- update color values even if buffer is not focused + -- example use: cmp_menu, cmp_docs + always_update = false + }, + -- all the sub-options of filetypes apply to buftypes + buftypes = {}, + +} +-- require('nvim-highlight-colors').setup {} +vim.g.python3_host_prog = '/usr/bin/python3' diff --git a/nvim/lua/lsp_config.lua b/nvim/lua/lsp_config.lua index e878d0d..06f3e55 100644 --- a/nvim/lua/lsp_config.lua +++ b/nvim/lua/lsp_config.lua @@ -95,6 +95,12 @@ for _, lsp in ipairs(servers) do }) end +require('lspconfig')['clangd'].setup({ + on_attach = on_attach, + flags = lsp_flags, +}) + + -- Addtional mappings for LSP local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) diff --git a/nvim/lua/packer_config.lua b/nvim/lua/packer_config.lua index db8b536..120435a 100644 --- a/nvim/lua/packer_config.lua +++ b/nvim/lua/packer_config.lua @@ -48,6 +48,19 @@ return require('packer').startup( requires = { 'nvim-tree/nvim-web-devicons', -- optional, for file icons }, + } + + -- use 'brenoprata10/nvim-highlight-colors' + -- use 'ap/vim-css-color' + use 'NvChad/nvim-colorizer.lua' + + use 'tpope/vim-surround' + + use({ + "iamcco/markdown-preview.nvim", + run = function() vim.fn["mkdp#util#install"]() end, + }) + end ) diff --git a/nvim/lua/treesitter_config.lua b/nvim/lua/treesitter_config.lua index 25dfdd0..287951b 100644 --- a/nvim/lua/treesitter_config.lua +++ b/nvim/lua/treesitter_config.lua @@ -22,7 +22,7 @@ require'nvim-treesitter.configs'.setup({ "dockerfile", "git_rebase", "gitcommit", - "help", + "vimdoc", "html", "htmldjango", "ini", @@ -59,13 +59,13 @@ require'nvim-treesitter.configs'.setup({ -- list of language that will be disabled -- disable = { "c", "rust" }, -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files - disable = function(lang, buf) - local max_filesize = 100 * 1024 -- 100 KB - local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) - if ok and stats and stats.size > max_filesize then - return true - end - end, + -- disable = function(lang, buf) + -- local max_filesize = 100 * 1024 -- 100 KB + -- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + -- if ok and stats and stats.size > max_filesize then + -- return true + -- end + -- end, -- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). diff --git a/nvim/plugin/packer_compiled.lua b/nvim/plugin/packer_compiled.lua deleted file mode 100644 index 1d4ef25..0000000 --- a/nvim/plugin/packer_compiled.lua +++ /dev/null @@ -1,139 +0,0 @@ --- Automatically generated packer.nvim plugin loader code - -if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then - vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') - return -end - -vim.api.nvim_command('packadd packer.nvim') - -local no_errors, error_msg = pcall(function() - -_G._packer = _G._packer or {} -_G._packer.inside_compile = true - -local time -local profile_info -local should_profile = false -if should_profile then - local hrtime = vim.loop.hrtime - profile_info = {} - time = function(chunk, start) - if start then - profile_info[chunk] = hrtime() - else - profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 - end - end -else - time = function(chunk, start) end -end - -local function save_profiles(threshold) - local sorted_times = {} - for chunk_name, time_taken in pairs(profile_info) do - sorted_times[#sorted_times + 1] = {chunk_name, time_taken} - end - table.sort(sorted_times, function(a, b) return a[2] > b[2] end) - local results = {} - for i, elem in ipairs(sorted_times) do - if not threshold or threshold and elem[2] > threshold then - results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' - end - end - if threshold then - table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') - end - - _G._packer.profile_output = results -end - -time([[Luarocks path setup]], true) -local package_path_str = "/Users/carlogravador/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/carlogravador/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/carlogravador/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/carlogravador/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" -local install_cpath_pattern = "/Users/carlogravador/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" -if not string.find(package.path, package_path_str, 1, true) then - package.path = package.path .. ';' .. package_path_str -end - -if not string.find(package.cpath, install_cpath_pattern, 1, true) then - package.cpath = package.cpath .. ';' .. install_cpath_pattern -end - -time([[Luarocks path setup]], false) -time([[try_loadstring definition]], true) -local function try_loadstring(s, component, name) - local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) - if not success then - vim.schedule(function() - vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) - end) - end - return result -end - -time([[try_loadstring definition]], false) -time([[Defining packer_plugins]], true) -_G.packer_plugins = { - ["Comment.nvim"] = { - loaded = true, - path = "/Users/carlogravador/.local/share/nvim/site/pack/packer/start/Comment.nvim", - url = "https://github.com/numToStr/Comment.nvim" - }, - ["fzf-lua"] = { - loaded = true, - path = "/Users/carlogravador/.local/share/nvim/site/pack/packer/start/fzf-lua", - url = "https://github.com/ibhagwan/fzf-lua" - }, - ["lualine.nvim"] = { - loaded = true, - path = "/Users/carlogravador/.local/share/nvim/site/pack/packer/start/lualine.nvim", - url = "https://github.com/nvim-lualine/lualine.nvim" - }, - ["nvim-lspconfig"] = { - loaded = true, - path = "/Users/carlogravador/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", - url = "https://github.com/neovim/nvim-lspconfig" - }, - ["nvim-tree.lua"] = { - loaded = true, - path = "/Users/carlogravador/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", - url = "https://github.com/nvim-tree/nvim-tree.lua" - }, - ["nvim-treesitter"] = { - loaded = true, - path = "/Users/carlogravador/.local/share/nvim/site/pack/packer/start/nvim-treesitter", - url = "https://github.com/nvim-treesitter/nvim-treesitter" - }, - ["nvim-web-devicons"] = { - loaded = true, - path = "/Users/carlogravador/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", - url = "https://github.com/nvim-tree/nvim-web-devicons" - }, - ["packer.nvim"] = { - loaded = true, - path = "/Users/carlogravador/.local/share/nvim/site/pack/packer/start/packer.nvim", - url = "https://github.com/wbthomason/packer.nvim" - }, - vim = { - loaded = true, - path = "/Users/carlogravador/.local/share/nvim/site/pack/packer/start/vim", - url = "https://github.com/dracula/vim" - } -} - -time([[Defining packer_plugins]], false) - -_G._packer.inside_compile = false -if _G._packer.needs_bufread == true then - vim.cmd("doautocmd BufRead") -end -_G._packer.needs_bufread = false - -if should_profile then save_profiles() end - -end) - -if not no_errors then - error_msg = error_msg:gsub('"', '\\"') - vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') -end diff --git a/skhd/skhdrc b/skhd/skhdrc new file mode 100644 index 0000000..a02a6d1 --- /dev/null +++ b/skhd/skhdrc @@ -0,0 +1,44 @@ +# Changing Window focus within space +alt - j : yabai -m window --focus south +alt - k : yabai -m window --focus north +alt - h : yabai -m window --focus west +alt - l : yabai -m window --focus east + +# Change focus between external displays +alt - u : yabai -m display --focus north +alt - d : yabai -m display --focus south + +# Modifying the layout +# rotate clockwise +shift + alt - r : yabai -m space --rotate 270 +# flip along y axis +shift + alt - y : yabai -m space --mirror y-axis +# flip along x axis +shift + alt - x : yabai -m space --mirror x-axis +# toggle window float +shift + alt - t : yabai -m window --toggle float --grid 4:4:1:1:2:2 +# Toggle split orientation +shift + alt - space : yabai -m window --toggle split + +# Modifying window size +# Maximize window +# shift + alt - m : yabai -m window --toggle zoom-fullscreen +shift + alt - m : ~/.config/skhd/yabai_maxmize_window.sh +shift + alt - e : yabai -m space --balance + +# Moving windows around +shift + alt - j : yabai -m window --swap south +shift + alt - k : yabai -m window --swap north +shift + alt - h : yabai -m window --swap west +shift + alt - l : yabai -m window --swap east + +# Moving windows and split +shift + alt - j : yabai -m window --swap south +shift + alt - k : yabai -m window --swap north +shift + alt - h : yabai -m window --swap west +shift + alt - l : yabai -m window --swap east + +ctrl + alt - j : yabai -m window --warp south +ctrl + alt - k : yabai -m window --warp north +ctrl + alt - h : yabai -m window --warp west +ctrl + alt - l : yabai -m window --warp east diff --git a/skhd/yabai_maxmize_window.sh b/skhd/yabai_maxmize_window.sh new file mode 100755 index 0000000..370389b --- /dev/null +++ b/skhd/yabai_maxmize_window.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +# Get the window information in JSON format +window_info=$(yabai -m query --windows --window) + +# Check if the currently focused window is floating +is_floating=$(echo "$window_info" | jq '.["is-floating"]') +echo "${is_floating}" + +if [ "${is_floating}" = "true" ]; then + # If the window is not maximized, maximize it + yabai -m window --grid 1:1:0:0:1:1 + +else + yabai -m window --toggle zoom-fullscreen +fi diff --git a/yabai/yabairc b/yabai/yabairc new file mode 100755 index 0000000..f103f7a --- /dev/null +++ b/yabai/yabairc @@ -0,0 +1,27 @@ +# bsp, stack, float +yabai -m config layout bsp + +yabai -m config window_placement second_child + +# padding +yabai -m config top_padding 12 +yabai -m config bottom_padding 12 +yabai -m config left_padding 12 +yabai -m config right_padding 12 +yabai -m config window_gap 12 + +# mouse settings +yabai -m config mouse_follows_focus on + +yabai -m config mouse_modifier alt +# left click + drag +yabai -m config mouse_action1 move +# right click + drag +yabai -m config mouse_action2 resize + +yabai -m mouse_drop_action swap + +# Disable specific apps +yabai -m rule --add app="^System Settings$" manage=off +yabai -m rule --add app="^Calculator$" manage=off +yabai -m rule --add app="^Karabiner-Elements$" manage=off