diff --git a/.gitignore b/.gitignore index 39abca8..6c7f1e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,2 @@ .DS_Store -.netrwhist -plugged/* -colors/.DS_Store -pack/* -packer_compiled.lua -.git/* -startup_time* - -colors/.DS_Store -.metals -rplugin -.luarc.json +ToDo.md \ No newline at end of file diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..88b82b3 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,133 @@ +{ + "workspace.library": [ + "/Users/Kevin/.local/share/nvim/lazy/neodev.nvim/types/nightly", + "/Users/Kevin/.local/nvim_macos/nvim_macos_nightly/share/nvim/runtime/lua", + "/Users/Kevin/.local/share/nvim/lazy/SchemaStore.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-ui-select.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-buffer/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-dap/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-web-devicons/lua", + "/Users/Kevin/.local/share/nvim/lazy/surround.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/peek.nvim/lua", + "/Users/Kevin/dev/knvim-theme.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-ts-context-commentstring/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-cmdline/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-navic/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-treesitter-refactor/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-calc/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-latex-symbols/lua", + "/Users/Kevin/.local/share/nvim/lazy/plenary.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/rainbow-delimiters.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-colorizer.lua/lua", + "/Users/Kevin/.local/share/nvim/lazy/toggleterm.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/symbols-outline.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/neodev.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/rest.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-notify/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-autopairs/lua", + "/Users/Kevin/.local/share/nvim/lazy/vim-dadbod-completion/lua", + "/Users/Kevin/.local/share/nvim/lazy/which-key.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-treesitter/lua", + "/Users/Kevin/.local/share/nvim/lazy/gitsigns.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/Comment.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/oil.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/lazy.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-emoji.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-lint/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-ufo/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-file-browser.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-dap-ui/lua", + "/Users/Kevin/.local/share/nvim/lazy/LuaSnip/lua", + "/Users/Kevin/.local/share/nvim/lazy/promise-async/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-lspconfig/lua", + "/Users/Kevin/.local/share/nvim/lazy/color-picker.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-env.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-project.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-luasnip.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-nvim-lsp/lua", + "/Users/Kevin/.local/share/nvim/lazy/mason.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/none-ls.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nui.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/zen-mode.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-dap/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp_luasnip/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-jdtls/lua", + "/Users/Kevin/.local/share/nvim/lazy/noice.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/todo-comments.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-cmp/lua", + "/Users/Kevin/.local/share/nvim/lazy/twilight.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-dap-virtual-text/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-treesitter-context/lua", + "/Users/Kevin/.local/share/nvim/lazy/mason-lspconfig.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-metals/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-path/lua", + "/Users/Kevin/.local/share/nvim/lazy/alpha-nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/neodev.nvim/types/nightly", + "/Users/Kevin/.local/nvim_macos/nvim_macos_nightly/share/nvim/runtime/lua", + "/Users/Kevin/.local/share/nvim/lazy/SchemaStore.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-ui-select.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-buffer/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-dap/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-web-devicons/lua", + "/Users/Kevin/.local/share/nvim/lazy/surround.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/peek.nvim/lua", + "/Users/Kevin/dev/knvim-theme.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-ts-context-commentstring/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-cmdline/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-navic/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-treesitter-refactor/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-calc/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-latex-symbols/lua", + "/Users/Kevin/.local/share/nvim/lazy/plenary.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/rainbow-delimiters.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-colorizer.lua/lua", + "/Users/Kevin/.local/share/nvim/lazy/toggleterm.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/symbols-outline.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/neodev.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/rest.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-notify/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-autopairs/lua", + "/Users/Kevin/.local/share/nvim/lazy/vim-dadbod-completion/lua", + "/Users/Kevin/.local/share/nvim/lazy/which-key.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-treesitter/lua", + "/Users/Kevin/.local/share/nvim/lazy/gitsigns.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/Comment.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/oil.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/lazy.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-emoji.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-lint/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-ufo/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-file-browser.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-dap-ui/lua", + "/Users/Kevin/.local/share/nvim/lazy/LuaSnip/lua", + "/Users/Kevin/.local/share/nvim/lazy/promise-async/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-lspconfig/lua", + "/Users/Kevin/.local/share/nvim/lazy/color-picker.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-env.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-project.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/telescope-luasnip.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-nvim-lsp/lua", + "/Users/Kevin/.local/share/nvim/lazy/mason.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/none-ls.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nui.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/zen-mode.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-dap/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp_luasnip/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-jdtls/lua", + "/Users/Kevin/.local/share/nvim/lazy/noice.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/todo-comments.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-cmp/lua", + "/Users/Kevin/.local/share/nvim/lazy/twilight.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-dap-virtual-text/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-treesitter-context/lua", + "/Users/Kevin/.local/share/nvim/lazy/mason-lspconfig.nvim/lua", + "/Users/Kevin/.local/share/nvim/lazy/nvim-metals/lua", + "/Users/Kevin/.local/share/nvim/lazy/cmp-path/lua", + "/Users/Kevin/.local/share/nvim/lazy/alpha-nvim/lua", + "/Users/Kevin/.MacDotfiles/nvim/.config/nvim/lua", + "/Users/Kevin/.MacDotfiles/nvim/.config/nvim/lua", + "${3rd}/luv/library" + ] +} \ No newline at end of file diff --git a/after/queries/markdown/highlights.scm b/after/queries/markdown/highlights.scm index 3401ac6..abd1dfc 100644 --- a/after/queries/markdown/highlights.scm +++ b/after/queries/markdown/highlights.scm @@ -47,6 +47,6 @@ ([ (block_quote_marker) + (block_continuation) ] @conceal (#set! conceal "|")) - diff --git a/after/syntax/kitty.vim b/after/syntax/kitty.vim index 755dfd7..fb3836e 100644 --- a/after/syntax/kitty.vim +++ b/after/syntax/kitty.vim @@ -1,6 +1,6 @@ " Vim syntax file " Language : Kitty -" Last Change : Mar 18, 2010 +" Last Change : 19/01/2024 - 17:54 " Source : https://github.com/fladson/vim-kitty/tree/main/syntax syn region kittyKeybind start=' ' end=' ' contains=kittyMod,kittyKey,kittyKeyComb contained nextgroup=kittyActionKW @@ -87,16 +87,16 @@ syn keyword kittyKeyword contained \ inactive_text_alpha initial_window_height initial_window_width input_delay italic_font kitten_alias kitty_mod linux_bell_theme \ linux_display_server listen_on macos_colorspace macos_custom_beam_cursor macos_hide_from_tasks macos_menubar_title_max_length macos_option_as_alt macos_quit_when_last_window_closed \ macos_show_window_title_in macos_thicken_font macos_titlebar_color macos_traditional_fullscreen macos_window_resizable map mark1_background mark1_foreground - \ mark2_background mark2_foreground mark3_background mark3_foreground modify_font mouse_hide_wait mouse_map narrow_symbols - \ open_url_with paste_actions placement_strategy pointer_shape_when_dragging pointer_shape_when_grabbed remember_window_size remote_control_password repaint_delay - \ resize_debounce_time resize_in_steps scrollback_fill_enlarged_window scrollback_lines scrollback_pager scrollback_pager_history_size select_by_word_characters select_by_word_characters_forward - \ selection_background selection_foreground shell shell_integration show_hyperlink_targets single_window_margin_width startup_session strip_trailing_spaces - \ symbol_map sync_to_monitor tab_activity_symbol tab_bar_align tab_bar_background tab_bar_edge tab_bar_margin_color tab_bar_margin_height - \ tab_bar_margin_width tab_bar_min_tabs tab_bar_style tab_fade tab_powerline_style tab_separator tab_switch_strategy tab_title_max_length - \ tab_title_template term text_composition_strategy text_fg_override_threshold touch_scroll_multiplier undercurl_style update_check_interval url_color - \ url_excluded_characters url_prefixes url_style visual_bell_color visual_bell_duration visual_window_select_characters watcher wayland_titlebar_color - \ wheel_scroll_min_lines wheel_scroll_multiplier window_alert_on_bell window_border_width window_logo_alpha window_logo_path window_logo_position window_margin_width - \ window_padding_width window_resize_step_cells window_resize_step_lines + \ mark2_background mark2_foreground mark3_background mark3_foreground menu_map modify_font mouse_hide_wait mouse_map + \ narrow_symbols notify_on_cmd_finish open_url_with paste_actions placement_strategy pointer_shape_when_dragging pointer_shape_when_grabbed remember_window_size + \ remote_control_password repaint_delay resize_debounce_time resize_in_steps scrollback_fill_enlarged_window scrollback_lines scrollback_pager scrollback_pager_history_size + \ select_by_word_characters select_by_word_characters_forward selection_background selection_foreground shell shell_integration show_hyperlink_targets single_window_margin_width + \ single_window_padding_width startup_session strip_trailing_spaces symbol_map sync_to_monitor tab_activity_symbol tab_bar_align tab_bar_background + \ tab_bar_edge tab_bar_margin_color tab_bar_margin_height tab_bar_margin_width tab_bar_min_tabs tab_bar_style tab_fade tab_powerline_style + \ tab_separator tab_switch_strategy tab_title_max_length tab_title_template term text_composition_strategy text_fg_override_threshold touch_scroll_multiplier + \ undercurl_style underline_hyperlinks update_check_interval url_color url_excluded_characters url_prefixes url_style visual_bell_color + \ visual_bell_duration visual_window_select_characters watcher wayland_titlebar_color wheel_scroll_min_lines wheel_scroll_multiplier window_alert_on_bell window_border_width + \ window_logo_alpha window_logo_path window_logo_position window_margin_width window_padding_width window_resize_step_cells window_resize_step_lines syn keyword kittyAction contained \ change_font_size clear_selection clear_terminal close_os_window close_other_tabs_in_os_window close_other_windows_in_tab close_shared_ssh_connections close_tab \ close_window close_window_with_confirmation combine copy_and_clear_or_interrupt copy_ansi_to_clipboard copy_or_interrupt copy_to_buffer copy_to_clipboard @@ -107,9 +107,10 @@ syn keyword kittyAction contained \ move_tab_forward move_window move_window_backward move_window_forward move_window_to_top neighboring_window new_os_window new_os_window_with_cwd \ new_tab new_tab_with_cwd new_window new_window_with_cwd next_layout next_tab next_window ninth_window \ no_op nth_os_window nth_window open_url open_url_with_hints pass_selection_to_program paste paste_from_buffer - \ paste_from_clipboard paste_from_selection paste_selection paste_selection_or_clipboard previous_tab previous_window quit remote_control - \ remove_marker reset_window_sizes resize_window scroll_end scroll_home scroll_line_down scroll_line_up scroll_page_down - \ scroll_page_up scroll_prompt_to_bottom scroll_prompt_to_top scroll_to_mark scroll_to_prompt second_window select_tab send_text - \ set_background_opacity set_colors set_tab_title seventh_window show_first_command_output_on_screen show_kitty_doc show_kitty_env_vars show_last_command_output - \ show_last_non_empty_command_output show_last_visited_command_output show_scrollback signal_child sixth_window sleep start_resizing_window swap_with_window - \ tenth_window third_window toggle_fullscreen toggle_layout toggle_macos_secure_keyboard_entry toggle_marker toggle_maximized + \ paste_from_clipboard paste_from_selection paste_selection paste_selection_or_clipboard pop_keyboard_mode previous_tab previous_window push_keyboard_mode + \ quit remote_control remote_control_script remove_marker reset_window_sizes resize_window scroll_end scroll_home + \ scroll_line_down scroll_line_up scroll_page_down scroll_page_up scroll_prompt_to_bottom scroll_prompt_to_top scroll_to_mark scroll_to_prompt + \ second_window select_tab send_key send_text set_background_opacity set_colors set_tab_title set_window_title + \ seventh_window show_error show_first_command_output_on_screen show_kitty_doc show_kitty_env_vars show_last_command_output show_last_non_empty_command_output show_last_visited_command_output + \ show_scrollback signal_child sixth_window sleep start_resizing_window swap_with_window tenth_window third_window + \ toggle_fullscreen toggle_layout toggle_macos_secure_keyboard_entry toggle_marker toggle_maximized diff --git a/lazy-lock.json b/lazy-lock.json index 42e0120..50f305c 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,8 +1,8 @@ { "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, - "LuaSnip": { "branch": "master", "commit": "57c9f5c31b3d712376c704673eac8e948c82e9c1" }, - "SchemaStore.nvim": { "branch": "main", "commit": "e4c127ef3888bf8a05ff51879c1b44f96e100cd6" }, - "alpha-nvim": { "branch": "main", "commit": "29074eeb869a6cbac9ce1fbbd04f5f5940311b32" }, + "LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" }, + "SchemaStore.nvim": { "branch": "main", "commit": "273cd742bf86aedc21c1154a2bcea044071f48d6" }, + "alpha-nvim": { "branch": "main", "commit": "1356b9ef31b985d541d94314f2cf73c61124bf1d" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-calc": { "branch": "main", "commit": "ce91d14d2e7a8b3f6ad86d85e34d41c1ae6268d9" }, "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, @@ -13,54 +13,55 @@ "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "color-picker.nvim": { "branch": "master", "commit": "06cb5f853535dea529a523e9a0e8884cdf9eba4d" }, "data-viewer.nvim": { "branch": "main", "commit": "40ddf37bb7ab6c04ff9e820812d1539afe691668" }, - "gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" }, - "image.nvim": { "branch": "master", "commit": "41f0f2643a09631bc0d8e2837b514667d423e440" }, - "jupytext.nvim": { "branch": "main", "commit": "f176a20c663f6216e0c95a44360845d4cec9ce00" }, - "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" }, - "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, - "molten-nvim": { "branch": "main", "commit": "1752f9d0027bf8ccb3440416e1112cae8f8f412c" }, - "neodev.nvim": { "branch": "main", "commit": "0afdcb703f265c3079a47857bda01e3ccf884558" }, - "noice.nvim": { "branch": "main", "commit": "92433164e2f7118d4122c7674c3834d9511722ba" }, - "none-ls.nvim": { "branch": "main", "commit": "bbd8c0c2b8a47ff2e0a97868afdf3fc640f1ad1e" }, - "nui.nvim": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" }, - "nvim-autopairs": { "branch": "master", "commit": "9fd41181693dd4106b3e414a822bb6569924de81" }, + "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, + "image.nvim": { "branch": "master", "commit": "21f2073505d8c475008512db59bbd82ccc9ec5d5" }, + "jupytext.nvim": { "branch": "main", "commit": "68fddf28119dbaddfaea6b71f3d6aa1e081afb93" }, + "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "b9084b1f42f790d6230dc66dbcb6bcc35b148552" }, + "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, + "mini.surround": { "branch": "main", "commit": "af8129efcabe95fc08a233e9f91569829bed031f" }, + "molten-nvim": { "branch": "main", "commit": "21d766c2d60e5f6e03f507e7f3e382a2a927ad41" }, + "neodev.nvim": { "branch": "main", "commit": "345ed5843405126464119154f394d4298c1314c7" }, + "noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" }, + "none-ls.nvim": { "branch": "main", "commit": "912f81829e9ab4ee3d54c3ea5a304c264f0003bc" }, + "nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" }, + "nvim-autopairs": { "branch": "master", "commit": "096d0baecc34f6c5d8a6dd25851e9d5ad338209b" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, - "nvim-dap": { "branch": "master", "commit": "f0dca670fa059eb89dda8869a6310c804241345c" }, - "nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" }, - "nvim-dap-virtual-text": { "branch": "master", "commit": "57f1dbd0458dd84a286b27768c142e1567f3ce3b" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, + "nvim-dap": { "branch": "master", "commit": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5" }, + "nvim-dap-ui": { "branch": "master", "commit": "d845ebd798ad1cf30aa4abd4c4eff795cdcfdd4f" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "d4542ac257d3c7ee4131350db6179ae6340ce40b" }, "nvim-jdtls": { "branch": "master", "commit": "66b5ace68a5d1c45fdfb1afa8d847e87af2aa1f8" }, - "nvim-lint": { "branch": "master", "commit": "32f98300881f38f4e022391f240188fec42f74db" }, - "nvim-lspconfig": { "branch": "master", "commit": "9099871a7c7e1c16122e00d70208a2cd02078d80" }, - "nvim-metals": { "branch": "main", "commit": "1e269f1f01e6b970603d51e9e044824d9d8114e7" }, + "nvim-lint": { "branch": "master", "commit": "8e5920f9ce9f24c283a2e64be5fe58d1d37d1744" }, + "nvim-lspconfig": { "branch": "master", "commit": "1759ea68fbbb1303192020d3e59936189359e0ed" }, + "nvim-metals": { "branch": "main", "commit": "d90ea43ded7ec651606b0a533ae9740083436e58" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, - "nvim-notify": { "branch": "master", "commit": "27a6649ba6b22828ccc67c913f95a5407a2d8bec" }, - "nvim-treesitter": { "branch": "master", "commit": "454c3a9ba86f841dc3b5bb17d150a873a16b77b4" }, - "nvim-treesitter-context": { "branch": "master", "commit": "c9f2b429a1d63023f7a33b5404616f4cd2a109c5" }, + "nvim-notify": { "branch": "master", "commit": "80b67b265530632505193553d05127ae7fe09ddd" }, + "nvim-treesitter": { "branch": "master", "commit": "ba6454783493ac3a5dd209c25e491640b07bd8de" }, + "nvim-treesitter-context": { "branch": "master", "commit": "9c06b115abc57c99cf0aa81dc29490f5001f57a1" }, "nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1277b4a1f451b0f18c0790e1a7f12e1e5fdebfee" }, - "nvim-ufo": { "branch": "main", "commit": "a15944ff8e3d570f504f743d55209275ed1169c4" }, - "nvim-web-devicons": { "branch": "master", "commit": "aff5f50b34754335a312c9b3dc5b245f605ce437" }, - "oil.nvim": { "branch": "master", "commit": "24027ed8d7f3ee5c38cfd713915e2e16d89e79b3" }, - "otter.nvim": { "branch": "main", "commit": "e4cfb3444e65750023d9db1947d1d12463d06eb5" }, + "nvim-ufo": { "branch": "main", "commit": "b0741a647efd98d9abb6cb653e056d24a07e4581" }, + "nvim-web-devicons": { "branch": "master", "commit": "aaec87dbdaa776bfa0a13c8694bec9bcb7454719" }, + "oil.nvim": { "branch": "master", "commit": "bf753c3e3f8736939ad5597f92329dfe7b1df4f5" }, + "otter.nvim": { "branch": "main", "commit": "151b75410e7b6041fb54f48443a80ecd518cb31e" }, "peek.nvim": { "branch": "master", "commit": "4163a48f190d2b2d94840be3eb38b4af83961ebe" }, - "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, "promise-async": { "branch": "main", "commit": "94f6f03c6c1e2aab551aacdf0c1e597a7269abb6" }, "quarto-nvim": { "branch": "main", "commit": "0a35b3890e9d723b730506d7d8b3ba3d0d6aae2e" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "a27051f08f6c03928ee9e94339f53da3107857db" }, - "rest.nvim": { "branch": "main", "commit": "84e81a19ab24ccf05c9233d34d4dfce61c233abe" }, - "surround.nvim": { "branch": "master", "commit": "36c253d6470910692491b13382f54c9bab2811e1" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "6c7d918621e93a045671e8f85c6dcc01783b82d0" }, + "rest.nvim": { "branch": "main", "commit": "2d7bd3d398940ce2692941e6cd052c072207b9f9" }, "telescope-env.nvim": { "branch": "master", "commit": "00a703cc7b713cdda0a981d88fddf3ce25502af5" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope-luasnip.nvim": { "branch": "master", "commit": "2ef7da3a363890686dbaad18ddbf59177cfe4f78" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "f336f8cfab38a82f9f00df380d28f0c2a572f862" }, - "todo-comments.nvim": { "branch": "main", "commit": "4a6737a8d70fe1ac55c64dfa47fcb189ca431872" }, - "toggleterm.nvim": { "branch": "main", "commit": "91be5f327e42aa016da13b277540de8dba0b14e3" }, + "telescope.nvim": { "branch": "master", "commit": "e54fbf4ab2b64640b639b75c006c23b4bc51c86f" }, + "todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" }, + "toggleterm.nvim": { "branch": "main", "commit": "b49df5cdce67a8964d1b027dae94bde212092b51" }, "twilight.nvim": { "branch": "main", "commit": "8b7b50c0cb2dc781b2f4262a5ddd57571556d1e4" }, - "vim-dadbod": { "branch": "master", "commit": "738cfc2ea6a1510fe23cba9006fef9291be70f7b" }, + "vim-dadbod": { "branch": "master", "commit": "9d3e3ce74a264642a41e8ae126be5afd095ef107" }, "vim-dadbod-completion": { "branch": "master", "commit": "c920cb0ba3dff4b1b0ed373e1c0b3007dec696c2" }, - "vim-dadbod-ui": { "branch": "master", "commit": "9ddb0623e69d696b7a8355b93e3950a8dc6e00a0" }, + "vim-dadbod-ui": { "branch": "master", "commit": "165699c573469e6a95b48d35052f848c340c5911" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, - "zen-mode.nvim": { "branch": "main", "commit": "50e2e2a36cc97847d9ab3b1a3555ba2ef6839b50" } + "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } } \ No newline at end of file diff --git a/lua/config/autocommands.lua b/lua/config/autocommands.lua index b14d4b9..507994c 100644 --- a/lua/config/autocommands.lua +++ b/lua/config/autocommands.lua @@ -2,7 +2,7 @@ -- File : autocommands.lua -- Description : Autocommands config -- Author : Kevin --- Last Modified: 03 Dec 2023, 10:45 +-- Last Modified: 25 Jan 2024, 12:39 ------------------------------------- local augroup = vim.api.nvim_create_augroup @@ -184,11 +184,11 @@ autocmd({ "FileType", "BufNewFile" }, { vim.filetype.add { extension = { conf = "config", - png = "image_nvim", - jpg = "image_nvim", - jpeg = "image_nvim", - gif = "image_nvim", - webp = "image_nvim", + -- png = "image_nvim", + -- jpg = "image_nvim", + -- jpeg = "image_nvim", + -- gif = "image_nvim", + -- webp = "image_nvim", -- md = "quarto", ipynb = "jupyter_notebook", dat = "xxd" @@ -213,9 +213,9 @@ autocmd({ "BufRead", "BufNewFile" }, { group = augroup("_kitty", { clear = true }), pattern = { "kitty.conf", "*/kitty/*.conf", "*/kitty/*.session" }, callback = function() - vim.api.nvim_buf_set_option(0, "filetype", "kitty") - vim.api.nvim_buf_set_option(0, "comments", ":#,:#\\:") - vim.api.nvim_buf_set_option(0, "commentstring", "# %s") + vim.api.nvim_set_option_value("filetype", "kitty", { buf = 0 }) + vim.api.nvim_set_option_value("comments", ":#,:#\\:", { buf = 0 }) + vim.api.nvim_set_option_value("commentstring", "# %s", { buf = 0 }) end }) @@ -224,7 +224,7 @@ autocmd({ "FileType" }, { group = augroup("_pdf_reader", { clear = true }), pattern = { "pdf", "PDF" }, callback = function(ev) - vim.api.nvim_buf_set_option(ev.buf, "readonly", true) + vim.api.nvim_set_option_value("readonly", true, { buf = ev.buf, scope = "local" }) if not vim.fn.executable "pdftotext" then vim.notify( "vim-pdf: pdftotext is not found.\nStop converting...", @@ -358,20 +358,20 @@ end, { desc = "Remove extra trailing white spaces" }) ---Delete Current Buffer (helper function for autocmd) user_command("DeleteCurrentBuffer", function() local cBuf = vim.api.nvim_get_current_buf() - local bufs = vim.fn.getbufinfo({ buflisted = true }) - if #bufs == 0 then - return - end - - for idx, buf in ipairs(bufs) do - if buf.bufnr == cBuf then - if idx == #bufs then - vim.cmd.bprevious {} - else - vim.cmd.bnext {} + local bufs = vim.fn.getbufinfo({ buflisted = true }) or {} + if #bufs ~= 0 then + for idx, buf in ipairs(bufs) do + if buf.bufnr == cBuf then + if idx == #bufs then + vim.cmd.bprevious {} + else + vim.cmd.bnext {} + end + break end - break end + else + return end vim.cmd.bdelete(cBuf) end, { desc = "Close current buffer and go to next" }) @@ -430,7 +430,7 @@ autocmd({ "FileType" }, { ---Wipe all Registers user_command("WipeReg", function() local regs = vim.fn.split( - 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"', '\\zs') + 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"', '\\zs') or {} for _, v in pairs(regs) do vim.call('setreg', v, '') end diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 43a9469..730326f 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -14,7 +14,7 @@ map("n", ".", function() title = "File Explorer", render = "wrapped-compact", timeout = 4, - on_open = function(win) + on_open = function(win) local buf = vim.api.nvim_win_get_buf(win) vim.api.nvim_buf_set_option(buf, "filetype", "markdown") end, @@ -22,10 +22,13 @@ map("n", ".", function() end, { desc = "Set cwd from current buffer " }) map({ "n", "v" }, "", "b", { remap = true }) map({ "n", "v" }, "", "E", { remap = true }) + map("n", "", "h") map("n", "", "j") map("n", "", "k") - +map("n", "", "l") +map("n", "", "zz") +map("n", "", "zz") map({ "n", "v" }, "R", function() end, { desc = "Run" }) @@ -59,22 +62,18 @@ map("n", "q", function() vim.cmd.bdelete() end, { desc = "Quit" }) map("n", "nn", function() - vim.cmd.Notifications {} + vim.cmd.Notifications() end, { desc = "Notifications" }) map("n", "nm", function() vim.cmd.messages() end, { desc = "Messages" }) map("n", "Q", function() - vim.cmd.copen() + pcall(vim.cmd.copen) end, { desc = "QuickFixList" }) map("n", "L", function() - vim.cmd.lopen() + pcall(vim.cmd.lopen) end, { desc = "LocationList" }) -map("n", "", "") -map("n", "", "l") -map("n", "", "zz") -map("n", "", "zz") map( "n", "", @@ -90,20 +89,22 @@ map("n", "Q", function() pcall(vim.cmd.DeleteCurrentBuffer) end) map("n", "U", "") map("n", "Y", "y$") map("n", "J", "mzJ`z") -map("n", "n", "nzzzv") -map("n", "N", "Nzzzv") +map("n", "n", "nzz") +map("n", "N", "Nzz") +map("n", "#", "#zz") +map("n", "g*", "g*zz") map("n", "S", ":%s///g") -map("n", "—", "| _") -map("n", "˝", "J") -map("n", "˛", "K") -map("n", "¸", "H") -map("n", "ˇ", "L") -map("n", "Ø", "Oj") -map("n", "ø", "ok") +map("n", "", "| _") +map("n", "", "J") +map("n", "", "K") +map("n", "", "H") +map("n", "", "L") +map("n", "", "Oj") +map("n", "", "ok") -- move text -map("n", "º", ":m .-2==", { silent = true }) -map("n", "ª", ":m .+1==", { silent = true }) +map("n", "", ":m .-2==", { silent = true }) +map("n", "", ":m .+1==", { silent = true }) -- delete & cut map("n", "x", [["_x]]) @@ -150,6 +151,12 @@ map("n", "fp", function() require("lib.utils").projects() end, { desc = "Projects" }) +map("n", "fx", function () + local file = vim.fn.expand "%:t" + vim.api.nvim_exec2(':!chmod +x %', {}) + local msg = string.format("File\n < %s >\n is now executable", file) + vim.notify(msg, vim.log.levels.INFO, { title = "File Info" }) +end, { desc = "File executable" }) -- TERMINAL MODE map("t", "", [[]]) @@ -196,7 +203,7 @@ map("v", "y", [["+y]], { desc = "Yank to clipboard" }) --set_keymap("v", "D", "\+D", { expr = true, desc = "Copy deletion to end into register \"" }) --set_keymap("v", "y", "\+y", { expr = true, desc = "Copy yank into register \"" }) --set_keymap("v", "", "\"+d", { desc = "Copy deletion into register \"" }) -map("v", "ga", function() +map("x", "ga", function() vim.cmd.normal "!" vim.ui.input({ prompt = "Align regex pattern: ", @@ -209,5 +216,10 @@ end, { desc = "Align from regex" }) -- move selected text map("x", "p", '"_dP') -map("x", "ª", [[:move '>+1gv-gv]], { silent = true }) -map("x", "º", [[:move '<-2gv-gv]], { silent = true }) \ No newline at end of file +map("x", "", [[:move '>+1gv-gv]], { silent = true }) +map("x", "", [[:move '<-2gv-gv]], { silent = true }) + +vim.cmd.cnoreabbrev("Wq", "wq") +vim.cmd.cnoreabbrev("Wq", "wq") +vim.cmd.cnoreabbrev("Xa", "xa") +vim.cmd.cnoreabbrev("XA", "xa") \ No newline at end of file diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 125b72b..0e12a26 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -101,9 +101,9 @@ lazy.setup({ "matchparen", "netrwPlugin", "tarPlugin", - "tohtml", + -- "tohtml", "tutor", - "zipPlugin", + -- "zipPlugin", "spellfile" } } @@ -116,7 +116,6 @@ local modules = { "config.vars", "config.autocommands", "config.keymaps", - -- "knvim.plugins.lazy" } for _, mod in ipairs(modules) do diff --git a/lua/config/prefs.lua b/lua/config/prefs.lua index 40664d9..dfb3363 100644 --- a/lua/config/prefs.lua +++ b/lua/config/prefs.lua @@ -2,105 +2,105 @@ -- File : prefs.lua -- Description : NeoVim & VimR preferences -- Author : Kevin --- Last Modified: 11 Oct 2023, 12:52 +-- Last Modified: 02 Jan 2024, 10:30 ------------------------------------- -local function opts() - return { - -- shell = vim.fn.split(vim.fn.system "which zsh", "\n")[1], - -- CURSOR { - guicursor = { -- cursor shape mode-based - "n-v-c:block", - "i-ci-ve:ver25", - "r-cr:hor20,o:hor50", - }, - -- } +local settings = { + -- shell = vim.fn.split(vim.fn.system "which zsh", "\n")[1], + -- CURSOR { + guicursor = { -- cursor shape mode-based + "n-v-c:block", + "i-ci-ve:ver25", + "r-cr:hor20,o:hor50", + }, + -- } - -- MOUSE: - mouse = "vnc", - fileencoding = "utf-8", + -- MOUSE: + mouse = "vnc", + fileencoding = "utf-8", - -- GRAPHIC: - termguicolors = true, - laststatus = 3, - guifont = "Source Code Pro:h13", -- font for gui-apps - -- clipboard = vim.opt.clipboard:append "unnamedplus", -- allow neovim access to system clipboardpre - relativenumber = true, -- Show line numbers - relativenumber from current - number = true, -- relativenumber but show current line number - showmode = false, -- show active mode in status line - scrolloff = 6, -- # of line leave above and below cursor - sidescrolloff = 6, -- # of columns on the sides - mat = 2, -- tenths of second to blink during matching brackets - visualbell = false, -- disable visual sounds - cursorline = true, -- highlight cursor line - showtabline = 1, -- show tabs if more than 1 - showmatch = true, -- Show matching brackets when over - signcolumn = "yes", -- always show signcolumns - cmdheight = 1, -- #lines for vim for commands/logs - pumheight = 16, -- popup menu height - pumblend = 8, -- popup menu transparency {0..100} - splitbelow = true, -- split below in horizontal split - splitright = true, -- split right in vertical split - updatetime = 100, -- lower than default for faster completion - updatecount = 0, -- do not create swap file - listchars = vim.opt.listchars:append { tab = "⇥ ", eol = "↲", trail = "~", space = "_", nbsp = "␣" }, - fillchars = [[eob: ,fold:󰇘,foldopen:,foldsep: ,foldclose:]], - -- syntax = "off", -- using treesitter - timeoutlen = 350, - ttimeoutlen = 100, - -- lazyredraw = true, - completeopt = { "menu", "menuone", "noselect" }, - matchpairs = vim.opt.matchpairs:append "<:>", - wildignore = { - "*.DS_Store", - "*.bak", - "*.gif", - "*.jpeg", - "*.jpg", - "*.png", - "*.swp", - "*.zip", - "*/.git/*", - }, - shortmess = vim.opt.shortmess:append "c", -- do not pass messages to ins-completion-menu + -- GRAPHIC: + termguicolors = true, + laststatus = 3, + guifont = "Source Code Pro:h13", -- font for gui-apps + -- clipboard = vim.opt.clipboard:append "unnamedplus", -- allow neovim access to system clipboardpre + relativenumber = true, -- Show line numbers - relativenumber from current + number = true, -- relativenumber but show current line number + showmode = false, -- show active mode in status line + scrolloff = 6, -- # of line leave above and below cursor + sidescrolloff = 6, -- # of columns on the sides + mat = 2, -- tenths of second to blink during matching brackets + visualbell = false, -- disable visual sounds + cursorline = true, -- highlight cursor line + showtabline = 1, -- show tabs if more than 1 + showmatch = true, -- Show matching brackets when over + signcolumn = "yes", -- always show signcolumns + cmdheight = 1, -- #lines for vim for commands/logs + pumheight = 16, -- popup menu height + pumblend = 8, -- popup menu transparency {0..100} + splitbelow = true, -- split below in horizontal split + splitright = true, -- split right in vertical split + updatetime = 100, -- lower than default for faster completion + updatecount = 0, -- do not create swap file + listchars = vim.opt.listchars:append { tab = "⇥ ", eol = "↲", trail = "~", space = "_", nbsp = "␣" }, + fillchars = [[eob: ,fold:󰇘,foldopen:,foldsep: ,foldclose:]], + -- syntax = "off", -- using treesitter + timeoutlen = 350, + ttimeoutlen = 100, + -- lazyredraw = true, + completeopt = { "menu", "menuone", "noselect" }, + matchpairs = vim.opt.matchpairs:append "<:>", + wildignore = { + "*.DS_Store", + "*.bak", + "*.gif", + "*.jpeg", + "*.jpg", + "*.png", + "*.swp", + "*.zip", + "*/.git/*", + }, + shortmess = vim.opt.shortmess:append "c", -- do not pass messages to ins-completion-menu - -- INDENTATION: - smartindent = true, -- enable smart indentation - tabstop = 2, -- number of spaces of - softtabstop = 2, -- :h softtabstop - expandtab = true, -- convert tabs to spaces - shiftwidth = 2, -- number of spaces for indentation + -- INDENTATION: + smartindent = true, -- enable smart indentation + tabstop = 2, -- number of spaces of + softtabstop = 2, -- :h softtabstop + expandtab = true, -- convert tabs to spaces + shiftwidth = 2, -- number of spaces for indentation - -- FOLDING: - wrap = false, -- Wrap long lines showing a linebreak - foldenable = true, -- enable code folding - linebreak = true, - -- foldmethod = "expr", -- method used to generate folds - -- foldexpr = "nvim_treesitter#foldexpr()", -- using treesitter to more folds - diffopt = { "internal", "filler", "closeoff", "vertical" }, + -- FOLDING: + wrap = false, -- Wrap long lines showing a linebreak + foldenable = true, -- enable code folding + linebreak = true, + -- foldmethod = "expr", -- method used to generate folds + -- foldexpr = "nvim_treesitter#foldexpr()", -- using treesitter to more folds + foldtext = '', - colorcolumn = "90", + diffopt = { "internal", "filler", "closeoff", "vertical" }, - -- FILE_MANAGEMENT: - autowrite = true, -- write files - autowriteall = true, -- write files on exit or other changes - undofile = true, -- enable undo - backup = false, -- disable backups - swapfile = false, -- disable swaps - undodir = vim.fn.expand "~/.cache/nvim/undo", -- path to undo directory + colorcolumn = "90", - -- SEARCH: - smartcase = true, -- smart case for search - ignorecase = true, -- case insensitive on search + -- FILE_MANAGEMENT: + autowrite = true, -- write files + autowriteall = true, -- write files on exit or other changes + undofile = true, -- enable undo + backup = false, -- disable backups + swapfile = false, -- disable swaps + undodir = vim.fn.expand "~/.cache/nvim/undo", -- path to undo directory - whichwrap = vim.opt.whichwrap:append "<,>,[,],h,l", + -- SEARCH: + smartcase = true, -- smart case for search + ignorecase = true, -- case insensitive on search - -- SESSION: (managed by auto-session) - sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal", - } -end + whichwrap = vim.opt.whichwrap:append "<,>,[,],h,l", + + -- SESSION: (managed by auto-session) + sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal", +} -- Sets all options to desired value -for k, v in pairs(opts()) do - vim.opt[k] = v +for k, v in pairs(settings) do + vim.opt[k] = v end \ No newline at end of file diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua index d8dc7ac..214c5b9 100644 --- a/lua/config/statusline.lua +++ b/lua/config/statusline.lua @@ -5,131 +5,136 @@ -- Last Modified: 05 Dec 2023, 17:38 ----------------------------------------- -local M = {} - -local icons = require "lib.icons" - -M.session_name = "" +local M = { + session_name = "" +} ---Table of preset width used to avoid display some elements ---if window width is not enough. local preset_width = setmetatable({ - filename = 60, - git_branch = 60, - git_status_full = 110, - diagnostic = 128, - row_onTot = 100, - lsp_info = 100, + filename = 60, + git_branch = 60, + git_status_full = 110, + diagnostic = 128, + row_onTot = 100, + lsp_info = 100, }, { - __index = function() + __index = function() return 80 - end -}) + end + }) ---Set highlight groups for StatusLine and relative colors. ---This is useful on first start, otherwise they are not overriden. local function set_color_groups() - vim.g.statusline_color = true - - local hls = { - -- StatusLine - StatusLine = { fg = "#626262", bg = "NONE" }, - StatusLineNC = { fg = "#868686", bg = "NONE" }, - StatusLineTerm = { fg = "#626262", bg = "NONE" }, - StatusLineTermNC = { fg = "#A9A9A9", bg = "#2c2c2c" }, - StatusLineMode = { fg = "#158C8A" }, - StatusLineGit = { fg = "#af8700", bg = "#2c2c2c" }, - StatusLineFileName = { fg = "#36FF5A", bg = "#2c2c2c" }, - StatusLineLspActive = { fg = "#4c4c4c", bg = "#2c2c2c" }, - StatusLineLspNotActive = { fg = "#3c3c3c", bg = "#2c2c2c" }, - StatusLineFileEncoding = { fg = "#86868B", bg = "#2c2c2c" }, - StatusLineFileType = { fg = "#158C8A", bg = "#2c2c2c" }, - StatusLineFileFormat = { fg = "#86868B", bg = "#2c2c2c" }, - StatusLineLocation = { fg = "#86868B", bg = "#2c2c2c" }, - StatusLineGpsDiagnostic = { fg = "#3c3c3c", bg = "NONE" }, - StatusLineInverted = { fg = "#1c1c1c", bg = "#2c2c2c" }, - StatusLineEmptyspace = { fg = "#2c2c2c", bg = "NONE" }, - StatusLineLite = { fg = "#dcdcdc", bg = "#262626" }, - StatusLineInactive = { fg = "#5c5c5c", bg = "#2c2c2c" }, - } - - for group, settings in pairs(hls) do - vim.api.nvim_set_hl(0, group, settings) - end + vim.g.statusline_color = true + + local hls = { + -- StatusLine + StatusLine = { fg = "#626262", bg = "#1c1c1c" }, + StatusLineNC = { fg = "#868686", bg = "#1c1c1c" }, + StatusLineTerm = { fg = "#626262", bg = "NONE" }, + StatusLineTermNC = { fg = "#A9A9A9", bg = "#2c2c2c" }, + StatusLineMode = { fg = "#158C8A" }, + StatusLineGit = { fg = "#af8700", bg = "#2c2c2c" }, + StatusLineFileName = { fg = "#36FF5A", bg = "#2c2c2c" }, + StatusLineLspActive = { fg = "#4c4c4c", bg = "#2c2c2c" }, + StatusLineLspNotActive = { fg = "#3c3c3c", bg = "#2c2c2c" }, + StatusLineFileEncoding = { fg = "#86868B", bg = "#2c2c2c" }, + StatusLineFileType = { fg = "#158C8A", bg = "#2c2c2c" }, + StatusLineFileFormatLocation = { fg = "#86868B", bg = "#2c2c2c" }, + StatusLineGpsDiagnostic = { fg = "#3c3c3c", bg = "#262626" }, + StatusLineInverted = { fg = "#1c1c1c", bg = "#2c2c2c" }, + StatusLineEmptyspace = { fg = "#3c3c3c", bg = "#262626" }, + StatusLineLite = { fg = "#dcdcdc", bg = "#1c1c1c" }, + StatusLineInactive = { fg = "#5c5c5c", bg = "#2c2c2c" }, + StatuslineSymbols = { fg = "#2c2c2c", bg = "#262626" }, + } + + for group, settings in pairs(hls) do + vim.api.nvim_set_hl(0, group, settings) + end end + local colors = { - inactive = "%#StatusLineInactive#", - mode = "%#StatusLineMode#", - git = "%#StatusLineGit#", - diag = "%#StatusLineGpsDiagnostic#", - diagError = "%#DiagnosticError#", - diagWarn = "%#DiagnosticWarn#", - diagInfo = "%#DiagnosticInfo#", - diagHint = "%#DiagnosticHint#", - lspactive = "%#StatusLineLspActive#", - lspnoactive = "%#StatusLineLspNotActive#", - ftype = "%#StatusLineFileType#", - empty = "%#StatusLineEmptyspace#", - lite = "%#StatusLineLite#", - name = "%#StatusLineFileName#", - encoding = "%#StatusLineFileEncoding#", - fformat = "%#StatusLineFileFormat#", - location = "%#StatusLineLocation#", - session = "%#StatusLineSession#", - inverted = "%#StatusLineInverted#", - Nmode = "%#Nmode#", - Vmode = "%#Vmode#", - Imode = "%#Imode#", - Cmode = "%#Cmode#", - Tmode = "%#Tmode#", - ShellMode = "%#Tmode#", + inactive = "%#StatusLineInactive#", + mode = "%#StatusLineMode#", + git = "%#StatusLineGit#", + diag = "%#StatusLineGpsDiagnostic#", + diagError = "%#DiagnosticError#", + diagWarn = "%#DiagnosticWarn#", + diagInfo = "%#DiagnosticInfo#", + diagHint = "%#DiagnosticHint#", + lspactive = "%#StatusLineLspActive#", + lspnoactive = "%#StatusLineLspNotActive#", + ftype = "%#StatusLineFileType#", + empty = "%#StatusLineEmptyspace#", + lite = "%#StatusLineLite#", + name = "%#StatusLineFileName#", + encoding = "%#StatusLineFileEncoding#", + fformatloc = "%#StatusLineFileFormatLocation#", + session = "%#StatusLineSession#", + inverted = "%#StatusLineInverted#", + symbols = "%#StatuslineSymbols#", + Nmode = "%#Nmode#", + Vmode = "%#Vmode#", + Imode = "%#Imode#", + Cmode = "%#Cmode#", + Tmode = "%#Tmode#", + ShellMode = "%#Tmode#", } local function get_mode() - local mode = { - ['n'] = colors.Nmode..'N', - ['no'] = colors.Nmode..'O·P', - ['nov'] = colors.Nmode..'O·P', - ['noV'] = colors.Nmode..'O·P', - ['no\22'] = colors.Nmode..'O·P', - ['niI'] = colors.Nmode..'N', - ['niR'] = colors.Nmode..'N', - ['niV'] = colors.Nmode..'N', - ['nt'] = colors.Nmode..'N', - ['ntT'] = colors.Nmode..'N', - ['v'] = colors.Vmode..'V', - ['vs'] = colors.Vmode..'V', - ['V'] = colors.Vmode..'V·L', - ['Vs'] = colors.Vmode..'V·L', - ['\22'] = colors.Vmode..'V·B', - ['\22s'] = colors.Vmode..'V·B', - ['s'] = colors.Vmode..'S', - ['S'] = colors.Vmode..'S·L', - ['\19'] = colors.Vmode..'S·B', - ['i'] = colors.Imode..'I', - ['ic'] = colors.Imode..'I', - ['ix'] = colors.Imode..'I', - ['R'] = colors.Cmode..'R', - ['Rc'] = colors.Cmode..'R', - ['Rx'] = colors.Cmode..'R', - ['Rv'] = colors.Cmode..'V·R', - ['Rvc'] = colors.Cmode..'V·R', - ['Rvx'] = colors.Cmode..'V·R', - ['c'] = colors.Cmode..'C', - ['cv'] = colors.Cmode..'EX', - ['ce'] = colors.Cmode..'EX', - ['r'] = colors.Tmode..'R', - ['rm'] = colors.Nmode..'M', - ['r?'] = colors.Nmode..'C', - ['!'] = colors.ShellMode..'S', - ['t'] = colors.Tmode..'T', - } - - local mode_code = vim.api.nvim_get_mode().mode - return mode[mode_code] or mode_code + local nmode = colors.Nmode + local vmode = colors.Vmode + local cmode = colors.Cmode + local tmode = colors.Tmode + local imode = colors.Imode + + local mode = { + ['n'] = nmode..'N', + ['no'] = nmode..'O·P', + ['nov'] = nmode..'O·P', + ['noV'] = nmode..'O·P', + ['no\22'] = nmode..'O·P', + ['niI'] = nmode..'N', + ['niR'] = nmode..'N', + ['niV'] = nmode..'N', + ['nt'] = nmode..'N', + ['ntT'] = nmode..'N', + ['v'] = vmode..'V', + ['vs'] = vmode..'V', + ['V'] = vmode..'V·L', + ['Vs'] = vmode..'V·L', + ['\22'] = vmode..'V·B', + ['\22s'] = vmode..'V·B', + ['s'] = vmode..'S', + ['S'] = vmode..'S·L', + ['\19'] = vmode..'S·B', + ['i'] = imode..'I', + ['ic'] = imode..'I', + ['ix'] = imode..'I', + ['R'] = cmode..'R', + ['Rc'] = cmode..'R', + ['Rx'] = cmode..'R', + ['Rv'] = cmode..'V·R', + ['Rvc'] = cmode..'V·R', + ['Rvx'] = cmode..'V·R', + ['c'] = cmode..'C', + ['cv'] = cmode..'EX', + ['ce'] = cmode..'EX', + ['r'] = tmode..'R', + ['rm'] = nmode..'M', + ['r?'] = nmode..'C', + ['!'] = colors.ShellMode..'S', + ['t'] = tmode..'T', + } + + local mode_code = vim.api.nvim_get_mode().mode + return mode[mode_code] or mode_code end @@ -141,285 +146,303 @@ end ---@return boolean win_is_smaller true if window width is smaller than passed args or ---between if 2 args are passed local function win_is_smaller(lower, upper) - upper = upper or nil - local win_size = vim.api.nvim_win_get_width(0) - return upper ~= nil and (win_size >= lower and win_size <= upper) or win_size < lower + upper = upper or nil + local win_size = vim.api.nvim_win_get_width(0) + return upper ~= nil and (win_size >= lower and win_size <= upper) or win_size < lower end ---Get location in current buffer (current row on total rows) local function get_line_onTot() - return win_is_smaller(preset_width.row_onTot) and string.format(" %s%%l%s+%%L ", colors.git, colors.location) - or colors.location .. " row " .. colors.git .. "%l" .. colors.location .. "÷%L " + return win_is_smaller(preset_width.row_onTot) and string.format(" %s%%l%s+%%L ", colors.git, colors.fformatloc) + or colors.fformatloc .. " row " .. colors.git .. "%l" .. colors.fformatloc .. "÷%L " end ---Get file name local function get_filename() - local cols = vim.o.columns - local fname = tostring(vim.fn.expand "%f ") - local to_trunc = #fname >= preset_width.filename or #fname >= (cols * 0.26) - local truncated_name = "..." .. string.sub(fname, #fname - (cols * 0.20), -1) + local cols = vim.o.columns + local fname = tostring(vim.fn.expand "%f ") + local to_trunc = #fname >= preset_width.filename or #fname >= (cols * 0.26) + local truncated_name = "..." .. string.sub(fname, #fname - (cols * 0.20), -1) - return to_trunc and truncated_name or fname + return to_trunc and truncated_name or fname end ---Get lsp diagnostics data local function get_lsp_diagnostic() - local do_not_show_diag = win_is_smaller(80) - - -- assign to relative vars the count of diagnostics - local errors = #vim.diagnostic.get(0, { severity = { vim.diagnostic.severity.ERROR }}) - local warns = #vim.diagnostic.get(0, { severity = { vim.diagnostic.severity.WARN }}) - local infos = #vim.diagnostic.get(0, { severity = { vim.diagnostic.severity.INFO }}) - local hints = #vim.diagnostic.get(0, { severity = { vim.diagnostic.severity.HINT }}) - - local status_ok = (errors + warns + infos + hints) == 0 - - -- display values only if there are any - return status_ok and colors.diag .. icons.diagnostics.status_ok or - do_not_show_diag and colors.diag .. icons.diagnostics.status_not_ok or - string.format( - "%s%s%s:%d %s%s:%d %s%s:%d %s%s:%d", - colors.diag, - colors.diagError, icons.diagnostics.Error, errors, - colors.diagWarn, icons.diagnostics.Warning, warns, - colors.diagInfo, icons.diagnostics.Information, infos, - colors.diagHint, icons.diagnostics.Hint, hints - ) + local do_not_show_diag = win_is_smaller(80) + + local diagnostics, errors, warns, infos, hints = nil, 0, 0, 0, 0 + local status_ok = false + + -- remove check when has nvim-0.10 + if vim.diagnostic.count ~= nil then + diagnostics = vim.diagnostic.count(0) + errors = diagnostics[vim.diagnostic.severity.ERROR] or 0 + warns = diagnostics[vim.diagnostic.severity.WARN] or 0 + infos = diagnostics[vim.diagnostic.severity.INFO] or 0 + hints = diagnostics[vim.diagnostic.severity.HINT] or 0 + status_ok = #diagnostics == 0 + else + -- assign to relative vars the count of diagnostics + errors = #vim.diagnostic.get(0, { severity = { vim.diagnostic.severity.ERROR }}) + warns = #vim.diagnostic.get(0, { severity = { vim.diagnostic.severity.WARN }}) + infos = #vim.diagnostic.get(0, { severity = { vim.diagnostic.severity.INFO }}) + hints = #vim.diagnostic.get(0, { severity = { vim.diagnostic.severity.HINT }}) + status_ok = (errors + warns + infos + hints) == 0 + end + + local icons = require "lib.icons" + + -- display values only if there are any + return status_ok and colors.diag .. icons.diagnostics.status_ok or + do_not_show_diag and colors.diag .. icons.diagnostics.status_not_ok or + string.format( + "%s%s%s:%d %s%s:%d %s%s:%d %s%s:%d", + colors.diag, + colors.diagError, icons.diagnostics.Error, errors, + colors.diagWarn, icons.diagnostics.Warning, warns, + colors.diagInfo, icons.diagnostics.Information, infos, + colors.diagHint, icons.diagnostics.Hint, hints + ) end ---Get git status with gitsigns local function get_git_status() - local signs = vim.b.gitsigns_status_dict or nil - if not signs then return "" end - - local add, change, remove = signs.added or 0, signs.changed or 0, signs.removed or 0 - - local no_changes = (add + change + remove) == 0 - - -- display based on size of window - -- if no changes, display only head (if available) - if signs.head ~= nil then - local head = signs.head - - if win_is_smaller(preset_width.git_branch) then - return "• " - elseif win_is_smaller(preset_width.git_branch, preset_width.git_status_full) or no_changes then - return string.format(" %s ", head) - else - return string.format("+%s ~%s -%s |  %s ", add, change, remove, head) - end - else - return "•" - end + local signs = vim.b['gitsigns_status_dict'] or nil + if not signs then return "" end + + local add, change, remove = signs.added or 0, signs.changed or 0, signs.removed or 0 + + local no_changes = (add + change + remove) == 0 + + -- display based on size of window + -- if no changes, display only head (if available) + if signs.head ~= nil then + local head = signs.head + + if win_is_smaller(preset_width.git_branch) then + return "• " + elseif win_is_smaller(preset_width.git_branch, preset_width.git_status_full) or no_changes then + return string.format(" %s ", head) + else + return string.format("+%s ~%s -%s |  %s ", add, change, remove, head) + end + else + return "•" + end end ---Get filetype with icon if available local function get_filetype() - local file_name, file_ext = vim.fn.expand "%:t", vim.fn.expand "%:e" - local has_devicons, devicons = pcall(require, "nvim-web-devicons") - local icon = "" - - if has_devicons ~= nil then - icon = devicons.get_icon(file_name, file_ext) - end - local file_type = vim.bo.filetype - - return file_type and has_devicons and { icon = icon, name = file_type } - or { name = file_type } - or icons.diagnostics.Error + local file_name, file_ext = vim.fn.expand "%:t", vim.fn.expand "%:e" + local has_devicons, devicons = pcall(require, "nvim-web-devicons") + local icons, icon = require "lib.icons", "" + + if has_devicons ~= nil then + icon = devicons.get_icon(file_name, file_ext) + end + local file_type = vim.bo.filetype + + return file_type and has_devicons and { icon = icon, name = file_type } + or { name = file_type } + or icons.diagnostics.Error end ---Get file encoding local function get_fencoding() - return not win_is_smaller(76) and " %{&fileencoding?&fileencoding:&encoding} " or "" + return not win_is_smaller(76) and " %{&fileencoding?&fileencoding:&encoding} " or "" end ---Get file format local function get_fformat() - return not win_is_smaller(76) and "%{&ff}" or "" + return not win_is_smaller(76) and "%{&ff}" or "" end ---Get session name if active local function session_name() - return M.session_name ~= "" and string.format("Session: %s%s", colors.session, M.session_name) or "" + return M.session_name ~= "" and string.format("Session: %s%s", colors.session, M.session_name) or "" end ---Get python virtual-env if is active and in python file local function get_python_env() - -- if vim.bo.filetype == "python" then - if not win_is_smaller(preset_width.git_branch) then - local venv = os.getenv "VIRTUAL_ENV" - if venv then - if string.find(venv, "/") then - local final_venv = venv - for w in venv:gmatch "([^/]+)" do - final_venv = w - end - venv = final_venv - end - local py_icon = '󰌠' - return string.format("%s (%s)", py_icon, venv) - end + -- if vim.bo.filetype == "python" then + if not win_is_smaller(preset_width.git_branch) then + local venv = os.getenv "VIRTUAL_ENV" + if venv then + if string.find(venv, "/") then + local final_venv = venv + for w in venv:gmatch "([^/]+)" do + final_venv = w + end + venv = final_venv end - -- end - return "" + return string.format(" 󰌠 (%s)", venv) + end + end + -- end + return "" end ---Get lsp status and if active get names of server running local function get_lsp_info() - -- TODO: remove when update to nvim-0.10 - local buf_clients = vim.fn.has("nvim-0.10") == 1 and vim.lsp.get_clients() or - vim.lsp.get_active_clients { bufnr = 0 } + -- TODO: remove when update to nvim-0.10 + local buf_clients = vim.fn.has("nvim-0.10") == 1 and vim.lsp.get_clients() or + vim.lsp.get_active_clients { bufnr = 0 } - return #buf_clients ~= 0 and - string.format("%s• ", colors.name) or - string.format("%s• ", colors.lspnoactive) + return #buf_clients ~= 0 and + string.format("%s• ", colors.name) or + string.format("%s• ", colors.lspnoactive) end ---Check if current filetype match the filetype to exclude ---@return boolean local function to_exclude() - local special_ft = { - alpha = true, - dashboard = true, - NvimTree = true, - lspinfo = true, - TelescopePrompt = true, - qf = true, - toggleterm = true, - lazy = true, - mason = true, - Outline = true, - noice = true, - checkhealth = true, - WhichKey = true, - query = true, - dbui = true, - oil = true - } - - return special_ft[vim.bo.filetype] + local special_ft = { + alpha = true, + dashboard = true, + NvimTree = true, + lspinfo = true, + TelescopePrompt = true, + qf = true, + toggleterm = true, + lazy = true, + mason = true, + Outline = true, + noice = true, + checkhealth = true, + WhichKey = true, + query = true, + dbui = true, + oil = true + } + + return special_ft[vim.bo.filetype] end ---Statusline disabled that display only filetype and current mode ---@return string simple_statusline M.off = function() - local ftype_name = string.format("%s %s", "", vim.bo.filetype) - local sideSep = "%=" - local modifiedReadOnlyFlags = "%m%r" - - local special_filetypes = { - dashboard = icons.ui.Plugin .. " Dashboard", - alpha = icons.ui.Plugin .. " Dashboard", - oil = icons.documents.OpenFolder .. " File Explorer", - lazy = icons.ui.PluginManager .. " Plugin Manager", - lspinfo = icons.ui.Health .. " LSP Status", - TelescopePrompt = icons.ui.Telescope .. " Telescope", - qf = icons.ui.Gear .. " QuickFix", - toggleterm = icons.misc.Robot .. "Terminal", - mason = icons.ui.List .. " Package Manager", - Outline = icons.ui.Table .. " Symbols Outline", - noice = icons.ui.List .. " Notifications", - checkhealth = icons.ui.Health .. " Health", - WhichKey = icons.ui.Search .. " WhichKey", - query = icons.ui.Query .. " Query", - dbui = icons.ui.Db .. " Database", - } - local custom_ft = special_filetypes[vim.bo.filetype] - - return table.concat({ - colors.mode, - get_mode(), - modifiedReadOnlyFlags, - colors.inverted, - icons.ui.SlArrowRight, - sideSep, - colors.inactive, - custom_ft or ftype_name, - sideSep - }) + local ftype_name = string.format("%s %s", "", vim.bo.filetype) + local sideSep = "%=" + local modifiedReadOnlyFlags = "%m%r" + + local icons = require "lib.icons" + + local special_filetypes = { + dashboard = icons.ui.Plugin .. " Dashboard", + alpha = icons.ui.Plugin .. " Dashboard", + oil = icons.documents.OpenFolder .. " File Explorer", + lazy = icons.ui.PluginManager .. " Plugin Manager", + lspinfo = icons.ui.Health .. " LSP Status", + TelescopePrompt = icons.ui.Telescope .. " Telescope", + qf = icons.ui.Gear .. " QuickFix", + toggleterm = icons.misc.Robot .. "Terminal", + mason = icons.ui.List .. " Package Manager", + Outline = icons.ui.Table .. " Symbols Outline", + noice = icons.ui.List .. " Notifications", + checkhealth = icons.ui.Health .. " Health", + WhichKey = icons.ui.Search .. " WhichKey", + query = icons.ui.Query .. " Query", + dbui = icons.ui.Db .. " Database", + } + local custom_ft = special_filetypes[vim.bo.filetype] + + return table.concat({ + colors.mode, + get_mode(), + modifiedReadOnlyFlags, + colors.inverted, + icons.ui.SlArrowRight, + sideSep, + colors.inactive, + custom_ft or ftype_name, + sideSep + }) end ---Statusline enabled with all items ---@return string statusline M.on = function() - local sideSep = "%=" - local modifiedReadOnlyFlags = "%m%r" - local space = " " - - local sl = { - -- LeftSide - colors.mode, get_mode(), - colors.inverted, icons.ui.SlArrowRight, - modifiedReadOnlyFlags, space, - colors.git, get_git_status(), - colors.name, get_filename(), - colors.empty, icons.ui.SlArrowRight, - session_name(), - get_python_env(), - - -- Middle - sideSep, - get_lsp_diagnostic(), - space, - - -- Right Side - colors.empty, icons.ui.SlArrowLeft, get_lsp_info(), - colors.ftype, get_filetype().icon or "", - space, - get_filetype().name, - colors.encoding, get_fencoding(), - colors.fformat, get_fformat(), - get_line_onTot(), - colors.inverted, icons.ui.SlArrowLeft - } - - return table.concat(sl) + local sideSep = "%=" + local modifiedReadOnlyFlags = "%m%r" + local space = " " + + local icons = require "lib.icons" + + local sl = { + -- LeftSide + colors.mode, get_mode(), + colors.inverted, icons.ui.SlArrowRight, + modifiedReadOnlyFlags, space, + colors.git, get_git_status(), + colors.name, get_filename(), + colors.symbols, icons.ui.SlArrowRight, + colors.empty, + session_name(), + get_python_env(), + + -- Middle + sideSep, + get_lsp_diagnostic(), + space, + + -- Right Side + colors.symbols, icons.ui.SlArrowLeft, get_lsp_info(), + colors.ftype, get_filetype().icon or "", + space, + get_filetype().name, + colors.encoding, get_fencoding(), + colors.fformatloc, get_fformat(), + get_line_onTot(), + colors.inverted, icons.ui.SlArrowLeft + } + + return table.concat(sl) end ---Set statusline based on filetype of current buffer M.set = function() - if not vim.g.statusline_color then set_color_groups() end - if not to_exclude() then - vim.wo.statusline = M.on() - else - vim.wo.statusline = M.off() - end + if not vim.g.statusline_color then set_color_groups() end + if not to_exclude() then + vim.wo.statusline = M.on() + else + vim.wo.statusline = M.off() + end end M.toggle = function() - if vim.g.statusline ~= nil then - vim.api.nvim_del_autocmd(vim.g.statusline) - vim.wo.statusline = "" - vim.g.statusline = nil - else - vim.api.nvim_create_autocmd({ - "BufNewFile", - "CursorMoved", - "ModeChanged", - "VimResized", - "FileType", - "FileChangedShellPost", - }, { - callback = function(cb) - if vim.g.statusline ~= nil then - vim.api.nvim_eval_statusline( - "%!v:lua.require'config.statusline'.set()", {}) - else - vim.g.statusline = cb.id - end - end - }) - end + if vim.g.statusline ~= nil then + vim.api.nvim_del_autocmd(vim.g.statusline) + vim.wo.statusline = "" + vim.g.statusline = nil + else + vim.api.nvim_create_autocmd({ + "BufNewFile", + "CursorMoved", + "ModeChanged", + "VimResized", + "FileType", + "FileChangedShellPost", + }, { + callback = function(cb) + if vim.g.statusline ~= nil then + vim.api.nvim_eval_statusline( + "%!v:lua.require'config.statusline'.set()", {}) + else + vim.g.statusline = cb.id + end + end + }) + end end vim.api.nvim_create_user_command("ToggleStatusline", function() - M.toggle() + M.toggle() end, { desc = "Toggle StatuLine" }) return M \ No newline at end of file diff --git a/lua/config/winbar.lua b/lua/config/winbar.lua index 053f6c8..681d938 100644 --- a/lua/config/winbar.lua +++ b/lua/config/winbar.lua @@ -6,110 +6,112 @@ ----------------------------------------- local M = { - dir = "~/.config/nvim/lua/plugins/ui/winbar.lua" + dir = "~/.config/nvim/lua/plugins/ui/winbar.lua" } local function is_not_empty(s) - return s ~= nil and s ~= "" + return s ~= nil and s ~= "" end local function to_exclude(filetype) - local special_ft = { - dashboard = true, - alpha = true, - WhichKey = true, - NvimTree = true, - lspinfo = true, - TelescopePrompt = true, - TelescopeResults = true, - qf = true, - toggleterm = true, - lazy = true, - mason = true, - Outline = true, - noice = true, - checkhealth = true, - notify = true, - cmpmenu = true, - vim = true, - oil = true, - help = true, - query = true, - } - - return special_ft[filetype] + local special_ft = { + dashboard = true, + alpha = true, + WhichKey = true, + NvimTree = true, + lspinfo = true, + TelescopePrompt = true, + TelescopeResults = true, + qf = true, + toggleterm = true, + lazy = true, + mason = true, + Outline = true, + noice = true, + checkhealth = true, + notify = true, + cmpmenu = true, + vim = true, + oil = true, + help = true, + query = true, + } + + return special_ft[filetype] end M.filename = function() - local default_file_icon = require "lib.icons".kind.File - local filename = vim.fn.expand "%:t" - - if is_not_empty(filename) then - local file_icon = "" - local extension = vim.fn.expand "%:e" - - file_icon, _ = require("nvim-web-devicons").get_icon_color( - filename, - extension, - { default = not is_not_empty(extension) or false } - ) - - return string.format( - "%%#FileIconColor%s#%s%%* %s", - extension, - file_icon or default_file_icon, - filename - ) - end + local default_file_icon = require "lib.icons".kind.File + local filename = vim.fn.expand "%:t" + + if is_not_empty(filename) then + local file_icon = "" + local extension = vim.fn.expand "%:e" + + file_icon, _ = require("nvim-web-devicons").get_icon_color( + filename, + extension, + { default = not is_not_empty(extension) or false } + ) + + return string.format( + "%%#FileIconColor%s#%s%%* %s", + extension, + file_icon or default_file_icon, + filename + ) + end end M.get = function() - local icons = require "lib.icons" - local has_navic, navic = pcall(require, "nvim-navic") - local location = has_navic and navic.get_location() or nil - - local retval = M.filename() - - return is_not_empty(location) - and string.format( - "%s %%#NavicSeparator# %s %%* %s", - retval, - icons.ui.ChevronRight, - location - ) - or retval + local icons = require "lib.icons" + local has_navic, navic = pcall(require, "nvim-navic") + local location = has_navic and navic.get_location() or nil + + -- WinBar = { fg = "#6c6c6c", bg = "#1c1c1c", italic = true }, + -- WinBarNC = { fg = "#3c3c3c", bg = "#1c1c1c" }, + local retval = M.filename() + + return is_not_empty(location) + and string.format( + "%s %%#NavicSeparator# %s %%* %s", + retval, + icons.ui.ChevronRight, + location + ) + or retval end M.toggle = function() - if vim.g.winbar ~= nil then - vim.api.nvim_del_autocmd(vim.g.winbar) - vim.wo.winbar = "" - vim.g.winbar = nil - else - vim.api.nvim_create_autocmd({ - "CursorMoved", "ModeChanged" - }, { - callback = function(cb) - if vim.g.winbar ~= nil then - if - not vim.api.nvim_win_get_config(0).relative ~= "" - and not to_exclude(vim.bo.filetype) - then - vim.wo.winbar = require("config.winbar").get() - end - else - vim.g.winbar = cb.id - end - -- disable on float windows - end + if vim.g.winbar ~= nil then + vim.api.nvim_del_autocmd(vim.g.winbar) + vim.wo.winbar = "" + vim.g.winbar = nil + else + vim.api.nvim_create_autocmd({ + "CursorMoved", "ModeChanged", "BufEnter" + }, { + callback = function(cb) + if vim.g.winbar ~= nil then + if + not vim.api.nvim_win_get_config(0).relative ~= "" + and not to_exclude(vim.bo.filetype) + then + vim.wo.winbar = require("config.winbar").get() + end + else + vim.api.nvim_set_hl(0, "WinBar", { fg = "#6c6c6c", bg = "#1c1c1c", italic = true }) + vim.api.nvim_set_hl(0, "WinBarNC", { fg = "#3c3c3c", bg = "#1c1c1c" }) + vim.g.winbar = cb.id + end + end }) - end - + end end vim.api.nvim_create_user_command("ToggleWinbar", function() - M.toggle() + M.toggle() end, { desc = "Toggle Winbar" }) return M \ No newline at end of file diff --git a/lua/lib/icons.lua b/lua/lib/icons.lua index 1298c7e..038b4f8 100644 --- a/lua/lib/icons.lua +++ b/lua/lib/icons.lua @@ -134,10 +134,10 @@ return { Query = "󱩾" }, diagnostics = { - Error = "", - Warning = "", - Information = "", - Question = "", + Error = "", + Warning = "", + Information = "", + Question = "", Hint = "󱧢", status_ok = "", status_not_ok = "", @@ -175,4 +175,4 @@ return { emoji = "[]", calc = "[]", }, -} +} \ No newline at end of file diff --git a/lua/plugins/editor/completion.lua b/lua/plugins/editor/completion.lua index ff177d6..5edef97 100644 --- a/lua/plugins/editor/completion.lua +++ b/lua/plugins/editor/completion.lua @@ -108,10 +108,17 @@ local M = { end end), - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + -- c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }), + }), [""] = cmp.mapping(cmp.mapping.abort(), { "i", "c" }), @@ -209,7 +216,7 @@ local M = { } o.window = { - completion = cmp.config.window.bordered(), + completion = cmp.config.window.bordered({ scrollbar = false }), documentation = cmp.config.window.bordered(), } @@ -275,8 +282,11 @@ local M = { }) cmp.setup(o) - - require "knvim.plugins.cmp" + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() + ) end } diff --git a/lua/plugins/editor/fzf.lua b/lua/plugins/editor/fzf.lua new file mode 100644 index 0000000..01b4e87 --- /dev/null +++ b/lua/plugins/editor/fzf.lua @@ -0,0 +1,1038 @@ +--------------------------------------- +-- File : fzf.lua +-- Description : fzf config +-- Author : Kevin +-- Last Modified: 14 Jan 2024, 09:57 +--------------------------------------- + + +local M = { + "ibhagwan/fzf-lua", + cmd = "FzfLua" , + enabled = false, + dependencies = { "nvim-tree/nvim-web-devicons" }, + keys = { + { + "b", + function() + require("fzf-lua").buffers() + end, + desc = "Buffers", + }, + { "f", nil, desc = "Fzf", }, + }, + opts = function(_, o) + local icons = require "lib.icons" + local actions = require "fzf-lua.actions" + -- fzf_bin = 'sk', -- use skim instead of fzf? + -- https://github.com/lotabout/skim + -- can also be set to 'fzf-tmux' + o.winopts = { + -- split = "belowright new",-- open in a split instead? + -- "belowright new" : split below + -- "aboveleft new" : split above + -- "belowright vnew" : split right + -- "aboveleft vnew : split left + -- Only valid when using a float window + -- (i.e. when 'split' is not defined, default) + height = 0.85, -- window height + width = 0.80, -- window width + row = 0.35, -- window row position (0=top, 1=bottom) + col = 0.50, -- window col position (0=left, 1=right) + -- border argument passthrough to nvim_open_win(), also used + -- to manually draw the border characters around the preview + -- window, can be set to 'false' to remove all borders or to + -- 'none', 'single', 'double', 'thicc' (+cc) or 'rounded' (default) + border = "rounded", + -- border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, + -- requires neovim > v0.9.0, passed as is to `nvim_open_win` + -- can be sent individually to any provider to set the win title + -- title = "Title", + -- title_pos = "center", -- 'left', 'center' or 'right' + fullscreen = false, -- start fullscreen? + preview = { + -- default = 'bat', -- override the default previewer? + -- default uses the 'builtin' previewer + border = 'border', -- border|noborder, applies only to + -- native fzf previewers (bat/cat/git/etc) + wrap = 'nowrap', -- wrap|nowrap + hidden = 'hidden', -- hidden|nohidden + vertical = 'up:45%', -- up|down:size + horizontal = 'right:50%', -- right|left:size + layout = 'flex', -- horizontal|vertical|flex + flip_columns = 120, -- #cols to switch to horizontal on flex + -- Only used with the builtin previewer: + title = true, -- preview border title (file/buf)? + title_pos = "center", -- left|center|right, title alignment + scrollbar = false, -- `false` or string:'float|border' + -- float: in-window floating border + -- border: in-border chars (see below) + scrolloff = '-2', -- float scrollbar offset from right + -- applies only when scrollbar = 'float' + scrollchars = {'█', '' }, -- scrollbar chars ({ , } + -- applies only when scrollbar = 'border' + delay = 100, -- delay(ms) displaying the preview + -- prevents lag on fast scrolling + winopts = { -- builtin previewer window options + number = true, + relativenumber = false, + cursorline = true, + cursorlineopt = 'both', + cursorcolumn = false, + signcolumn = 'no', + list = false, + foldenable = false, + foldmethod = 'manual', + }, + }, + on_create = function() + -- called once upon creation of the fzf main window + -- can be used to add custom fzf-lua mappings, e.g: + vim.keymap.set("t", "", "", { silent = true, buffer = true }) + vim.keymap.set("t", "", "", { silent = true, buffer = true }) + -- vim.keymap.set("t", "", "", { silent = true, buffer = true }) + end, + -- called once *after* the fzf interface is closed + -- on_close = function() ... end + } + o.ignore_current_file = true + o.keymap = { + -- These override the default tables completely + -- no need to set to `false` to disable a bind + -- delete or modify is sufficient + builtin = { + -- neovim `:tmap` mappings for the fzf win + ["?"] = "toggle-help", + [""] = "toggle-fullscreen", + -- Only valid with the 'builtin' previewer + [""] = "toggle-preview-wrap", + [""] = "toggle-preview", + -- Rotate preview clockwise/counter-clockwise + [""] = "toggle-preview-ccw", + [""] = "toggle-preview-cw", + [""] = "preview-page-down", + [""] = "preview-page-up", + }, + fzf = { + -- fzf '--bind=' options + ["ctrl-l"] = "accept", + ["ctrl-e"] = "abort", + ["ctrl-u"] = "unix-line-discard", + ["ctrl-f"] = "half-page-down", + ["ctrl-b"] = "half-page-up", + ["alt-a"] = "toggle-all", + -- Only valid with fzf previewers (bat/cat/git/etc) + ["f3"] = "toggle-preview-wrap", + ["ctrl-y"] = "toggle-preview", + ["ctrl-F"] = "preview-page-down", + ["ctrl-B"] = "preview-page-up", + ["shift-tab"] = "toggle+up", + tab = "toggle+down" + }, + } + o.actions = { + -- These override the default tables completely + -- no need to set to `false` to disable an action + -- delete or modify is sufficient + files = { + -- providers that inherit these actions: + -- files, git_files, git_status, grep, lsp + -- oldfiles, quickfix, loclist, tags, btags + -- args + -- default action opens a single selection + -- or sends multiple selection to quickfix + -- replace the default action with the below + -- to open all files whether single or multiple + ["default"] = actions.file_edit_or_qf, + ["ctrl-l"] = actions.file_edit_or_qf, + ["ctrl-s"] = actions.file_split, + ["ctrl-v"] = actions.file_vsplit, + ["ctrl-t"] = actions.file_tabedit, + ["alt-q"] = actions.file_sel_to_qf, + ["alt-l"] = actions.file_sel_to_ll, + }, + buffers = { + -- providers that inherit these actions: + -- buffers, tabs, lines, blines + ["default"] = actions.buf_edit, + ["ctrl-l"] = actions.buf_edit, + ["ctrl-s"] = actions.buf_split, + ["ctrl-v"] = actions.buf_vsplit, + ["ctrl-t"] = actions.buf_tabedit, + ["ctrl-x"] = actions.buf_del, + } + } + o.fzf_opts = { + -- options are sent as `=` + -- set to `false` to remove a flag + -- set to '' for a non-value flag + -- for raw args use `fzf_args` instead + -- ["--ansi"] = "", + ["--info"] = "inline", + -- ["--height"] = "60%", + ["--layout"] = "default", + ["--border"] = "none", + } + -- Only used when fzf_bin = "fzf-tmux", by default opens as a + -- popup 80% width, 80% height (note `-p` requires tmux > 3.2) + -- and removes the sides margin added by `fzf-tmux` (fzf#3162) + -- for more options run `fzf-tmux --help` + -- fzf '--color=' options (optional) + --[[ fzf_colors = { + ["fg"] = { "fg", "CursorLine" }, + ["bg"] = { "bg", "Normal" }, + ["hl"] = { "fg", "Comment" }, + ["fg+"] = { "fg", "Normal" }, + ["bg+"] = { "bg", "CursorLine" }, + ["hl+"] = { "fg", "Statement" }, + ["info"] = { "fg", "PreProc" }, + ["prompt"] = { "fg", "Conditional" }, + ["pointer"] = { "fg", "Exception" }, + ["marker"] = { "fg", "Keyword" }, + ["spinner"] = { "fg", "Label" }, + ["header"] = { "fg", "Comment" }, + ["gutter"] = { "bg", "Normal" }, + }, ]] + o.previewers = { + cat = { + cmd = "cat", + args = "--number", + }, + bat = { + cmd = "bat", + args = "--color=always --style=numbers,changes", + -- uncomment to set a bat theme, `bat --list-themes` + -- theme = 'Coldark-Dark', + }, + head = { + cmd = "head", + args = nil, + }, + git_diff = { + -- if required, use `{file}` for argument positioning + -- e.g. `cmd_modified = "git diff --color HEAD {file} | cut -c -30"` + cmd_deleted = "git diff --color HEAD --", + cmd_modified = "git diff --color HEAD", + cmd_untracked = "git diff --color --no-index /dev/null", + -- git-delta is automatically detected as pager, set `pager=false` + -- to disable, can also be set under 'git.status.preview_pager' + }, + man = { + -- NOTE: remove the `-c` flag when using man-db + -- replace with `man -P cat %s | col -bx` on OSX + cmd = "man -P cat %s | col -bx", + }, + builtin = { + syntax = true, -- preview syntax highlight? + syntax_limit_l = 0, -- syntax limit (lines), 0=nolimit + syntax_limit_b = 1024*1024, -- syntax limit (bytes), 0=nolimit + limit_b = 1024*1024*10, -- preview limit (bytes), 0=nolimit + -- previewer treesitter options: + -- enable specific filetypes with: `{ enable = { "lua" } } + -- exclude specific filetypes with: `{ disable = { "lua" } } + -- disable fully with: `{ enable = false }` + treesitter = { enable = true, disable = {} }, + -- By default, the main window dimensions are calculted as if the + -- preview is visible, when hidden the main window will extend to + -- full size. Set the below to "extend" to prevent the main window + -- from being modified when toggling the preview. + toggle_behavior = "default", + -- Title transform function, by default only displays the tail + -- title_fnamemodify = function(s) vim.fn.fnamemodify(s, ":t") end, + -- preview extensions using a custom shell command: + -- for example, use `viu` for image previews + -- will do nothing if `viu` isn't executable + -- extensions = { + -- BUG: kitty not working due to: https://github.com/kovidgoyal/kitty/issues/413 + -- + -- -- neovim terminal only supports `viu` block output + -- -- by default the filename is added as last argument + -- -- if required, use `{file}` for argument positioning + -- ["png"] = { "kitty +kitten icat" }, + -- ["jpg"] = { "kitty +kitten icat" }, + -- }, + -- if using `ueberzug` in the above extensions map + -- set the default image scaler, possible scalers: + -- false (none), "crop", "distort", "fit_contain", + -- "contain", "forced_cover", "cover" + -- https://github.com/seebye/ueberzug + -- ueberzug_scaler = "cover", + -- Custom filetype autocmds aren't triggered on + -- the preview buffer, define them here instead + -- ext_ft_override = { ["ksql"] = "sql", ... }, + }, + -- Code Action previewers, default is "codeaction" (set via `lsp.code_actions.previewer`) + -- "codeaction_native" uses fzf's native previewer, recommended when combined with git-delta + codeaction = { + -- options for vim.diff(): https://neovim.io/doc/user/lua.html#vim.diff() + diff_opts = { ctxlen = 3 }, + winopts = { + width = 0.4, + height = 0.4 + } + }, + codeaction_native = { + diff_opts = { ctxlen = 3 }, + -- git-delta is automatically detected as pager, set `pager=false` + -- to disable, can also be set under 'lsp.code_actions.preview_pager' + -- recommended styling for delta + --pager = [[delta --width=$COLUMNS --hunk-header-style="omit" --file-style="omit"]], + winopts = { + width = 0.4, + height = 0.4 + } + }, + } + -- PROVIDERS SETUP + -- use `defaults` (table or function) if you wish to set "global-provider" defaults + -- for exmaple, disabling file icons globally and open the quickfix list at the top + -- defaults = { + -- file_icons = false, + -- copen = "topleft copen", + -- }, + o.files = { + -- previewer = "bat", -- uncomment to override previewer + -- (name from 'previewers' table) + -- set to 'false' to disable + prompt = icons.lsp.buffer..' Files❯ ', + multiprocess = true, -- run command in a separate process + git_icons = false, -- show git icons? + file_icons = true, -- show file icons? + color_icons = true, -- colorize file|git icons + -- path_shorten = 1, -- 'true' or number, shorten path? + -- executed command priority is 'cmd' (if exists) + -- otherwise auto-detect prioritizes `fd`:`rg`:`find` + -- default options are controlled by 'fd|rg|find|_opts' + -- NOTE: 'find -printf' requires GNU find + -- cmd = "find . -type f -printf '%P\n'", + find_opts = [[-type f -not -path '*/\.git/*' -printf '%P\n']], + rg_opts = "--color=never --files --hidden --follow -g '!.git'", + fd_opts = "--color=never --type f --hidden --follow --exclude .git", + -- by default, cwd appears in the header only if {opts} contain a cwd + -- parameter to a different folder than the current working directory + -- uncomment if you wish to force display of the cwd as part of the + -- query prompt string (fzf.vim style), header line or both + -- cwd_header = true, + cwd_prompt = true, + cwd_prompt_shorten_len = 32, -- shorten prompt beyond this length + cwd_prompt_shorten_val = 1, -- shortened path parts length + toggle_ignore_flag = "--no-ignore", -- flag toggled in `actions.toggle_ignore` + actions = { + -- inherits from 'actions.files', here we can override + -- or set bind to 'false' to disable a default action + -- ["default"] = actions.file_edit, + -- ["ctrl-l"] = function(selected) + -- vim.print("Pressed < ctrl-l > on" .. selected[1]) + -- actions.file_edit(selected[1]) + -- end, + -- custom actions are available too + -- ["ctrl-y"] = function(selected) print(selected[1]) end, + -- action to toggle `--no-ignore`, requires fd or rg installed + ["ctrl-l"] = function(selected) print(selected[1]) end, + ["ctrl-g"] = { actions.toggle_ignore }, + } + } + o.git = { + files = { + prompt = 'GitFiles❯ ', + cmd = 'git ls-files --exclude-standard', + multiprocess = true, -- run command in a separate process + git_icons = true, -- show git icons? + file_icons = true, -- show file icons? + color_icons = true, -- colorize file|git icons + -- force display the cwd header line regardles of your current working + -- directory can also be used to hide the header when not wanted + -- cwd_header = true + winopts = { height = 0.8, width = 0.6 } + }, + status = { + prompt = 'GitStatus❯ ', + cmd = "git -c color.status=false status -su", + multiprocess = true, -- run command in a separate process + file_icons = true, + git_icons = true, + color_icons = true, + previewer = "git_diff", + -- git-delta is automatically detected as pager, uncomment to disable + -- preview_pager = false, + actions = { + -- actions inherit from 'actions.files' and merge + ["right"] = { fn = actions.git_unstage, reload = true }, + ["left"] = { fn = actions.git_stage, reload = true }, + ["ctrl-x"] = { fn = actions.git_reset, reload = true }, + ["ctrl-s"] = { fn = actions.git_stage_unstage, reload = true }, + }, + winopts = { height = 0.8, width = 0.6 } + -- If you wish to use a single stage|unstage toggle instead + -- using 'ctrl-s' modify the 'actions' table as shown below + -- actions = { + -- ["right"] = false, + -- ["left"] = false, + -- ["ctrl-x"] = { fn = actions.git_reset, reload = true }, + -- ["ctrl-s"] = { fn = actions.git_stage_unstage, reload = true }, + -- }, + }, + commits = { + prompt = 'Commits❯ ', + cmd = "git log --color --pretty=format:'%C(yellow)%h%Creset %Cgreen(%><(12)%cr%><|(12))%Creset %s %C(blue)<%an>%Creset'", + preview = "git show --color {1}", + -- git-delta is automatically detected as pager, uncomment to disable + -- preview_pager = false, + actions = { + ["default"] = actions.git_checkout, + -- remove `exec_silent` or set to `false` to exit after yank + ["ctrl-y"] = { fn = actions.git_yank_commit, exec_silent = true }, + }, + winopts = { height = 0.8, width = 0.6 } + }, + bcommits = { + prompt = 'BCommits❯ ', + -- default preview shows a git diff vs the previous commit + -- if you prefer to see the entire commit you can use: + -- git show --color {1} --rotate-to={file} + -- {1} : commit SHA (fzf field index expression) + -- {file} : filepath placement within the commands + cmd = "git log --color --pretty=format:'%C(yellow)%h%Creset %Cgreen(%><(12)%cr%><|(12))%Creset %s %C(blue)<%an>%Creset' {file}", + preview = "git show --color {1} -- {file}", + -- git-delta is automatically detected as pager, uncomment to disable + -- preview_pager = false, + actions = { + ["default"] = actions.git_buf_edit, + ["ctrl-s"] = actions.git_buf_split, + ["ctrl-v"] = actions.git_buf_vsplit, + ["ctrl-t"] = actions.git_buf_tabedit, + ["ctrl-y"] = { fn = actions.git_yank_commit, exec_silent = true }, + }, + }, + branches = { + prompt = 'Branches❯ ', + cmd = "git branch --all --color", + preview = "git log --graph --pretty=oneline --abbrev-commit --color {1}", + actions = { + ["default"] = actions.git_switch, + }, + winopts = { height = 0.4, width = 0.5 } + }, + tags = { + prompt = "Tags> ", + cmd = "git for-each-ref --color --sort=-taggerdate --format " + .. "'%(color:yellow)%(refname:short)%(color:reset) " + .. "%(color:green)(%(taggerdate:relative))%(color:reset)" + .. " %(subject) %(color:blue)%(taggername)%(color:reset)' refs/tags", + preview = "git log --graph --color --pretty=format:'%C(yellow)%h%Creset " + .. "%Cgreen(%><(12)%cr%><|(12))%Creset %s %C(blue)<%an>%Creset' {1}", + fzf_opts = { ["--no-multi"] = "" }, + actions = { ["default"] = actions.git_checkout }, + }, + stash = { + prompt = 'Stash> ', + cmd = "git --no-pager stash list", + preview = "git --no-pager stash show --patch --color {1}", + actions = { + ["default"] = actions.git_stash_apply, + ["ctrl-x"] = { fn = actions.git_stash_drop, reload = true }, + }, + fzf_opts = { + ["--no-multi"] = '', + ['--delimiter'] = "'[:]'", + }, + }, + icons = { + ["M"] = { icon = "M", color = "yellow" }, + ["D"] = { icon = "D", color = "red" }, + ["A"] = { icon = "A", color = "green" }, + ["R"] = { icon = "R", color = "yellow" }, + ["C"] = { icon = "C", color = "yellow" }, + ["T"] = { icon = "T", color = "magenta" }, + ["?"] = { icon = "?", color = "magenta" }, + -- override git icons? + -- ["M"] = { icon = "★", color = "red" }, + -- ["D"] = { icon = "✗", color = "red" }, + -- ["A"] = { icon = "+", color = "green" }, + }, + } + o.grep = { + prompt = 'Rg❯ ', + input_prompt = 'Grep For❯ ', + multiprocess = true, -- run command in a separate process + git_icons = true, -- show git icons? + file_icons = true, -- show file icons? + color_icons = true, -- colorize file|git icons + -- executed command priority is 'cmd' (if exists) + -- otherwise auto-detect prioritizes `rg` over `grep` + -- default options are controlled by 'rg|grep_opts' + -- cmd = "rg --vimgrep", + grep_opts = "--binary-files=without-match --line-number --recursive --color=auto --perl-regexp -e", + rg_opts = "--column --line-number --no-heading --color=always --smart-case --max-columns=4096 -e", + -- set to 'true' to always parse globs in both 'grep' and 'live_grep' + -- search strings will be split using the 'glob_separator' and translated + -- to '--iglob=' arguments, requires 'rg' + -- can still be used when 'false' by calling 'live_grep_glob' directly + rg_glob = false, -- default to glob parsing? + glob_flag = "--iglob", -- for case sensitive globs use '--glob' glob_separator = "%s%-%-", -- query separator pattern (lua): ' --' + -- advanced usage: for custom argument parsing define + -- 'rg_glob_fn' to return a pair: + -- first returned argument is the new search query + -- second returned argument are addtional rg flags + -- rg_glob_fn = function(query, opts) + -- ... + -- return new_query, flags + -- end, + actions = { + -- actions inherit from 'actions.files' and merge + -- this action toggles between 'grep' and 'live_grep' + ["ctrl-g"] = { actions.grep_lgrep } + }, + no_header = false, -- hide grep|cwd header? + no_header_i = false, -- hide interactive header? + } + o.args = { + prompt = 'Args❯ ', + files_only = true, + -- actions inherit from 'actions.files' and merge + actions = { ["ctrl-x"] = { fn = actions.arg_del, reload = true } }, + } + o.oldfiles = { + prompt = icons.package_manager.working_sym..' OldFiles❯ ', + cwd_only = false, + stat_file = true, -- verify files exist on disk + include_current_session = false, -- include bufs from current session + -- actions = { + -- ["enter"] = "file-edit-or-qf", + -- [""] = "file-edit-or-qf" + -- } + } + o.buffers = { + prompt = icons.ui.List..' Buffers❯ ', + file_icons = true, -- show file icons? + color_icons = true, -- colorize file|git icons + sort_lastused = true, -- sort buffers() by last used + show_unloaded = true, -- show unloaded buffers + cwd_only = false, -- buffers for the cwd only + cwd = nil, -- buffers list for a given dir + actions = { + -- actions inherit from 'actions.buffers' and merge + -- by supplying a table of functions we're telling + -- fzf-lua to not close the fzf window, this way we + -- can resume the buffers picker on the same window + -- eliminating an otherwise unaesthetic win "flash" + ["ctrl-x"] = { fn = actions.buf_del, reload = true }, + -- ["ctrl-l"] = actions.buf_edit_or_qf + }, + winopts = { + height = 0.4, + width = 0.4 + } + } + o.tabs = { + prompt = icons.ui.Table..' Tabs❯ ', + tab_title = "Tab", + tab_marker = "<<", + file_icons = true, -- show file icons? + color_icons = true, -- colorize file|git icons + actions = { + -- actions inherit from 'actions.buffers' and merge + ["default"] = actions.buf_switch, + ["ctrl-l"] = actions.buf_switch, + ["ctrl-x"] = { fn = actions.buf_del, reload = true }, + }, + fzf_opts = { + -- hide tabnr + ['--delimiter'] = "'[\\):]'", + ["--with-nth"] = '2..', + }, + winopts = { + height = 0.4, + width = 0.4 + } + } + o.lines = { + previewer = "builtin", -- set to 'false' to disable + prompt = 'Lines❯ ', + show_unloaded = true, -- show unloaded buffers + show_unlisted = false, -- exclude 'help' buffers + no_term_buffers = true, -- exclude 'term' buffers + fzf_opts = { + -- do not include bufnr in fuzzy matching + -- tiebreak by line no. + ['--delimiter'] = "'[\\]:]'", + ["--nth"] = '2..', + ["--tiebreak"] = 'index', + ["--tabstop"] = "1", + }, + -- actions inherit from 'actions.buffers' and merge + actions = { + ["default"] = actions.buf_edit_or_qf, + ["ctrl-l"] = actions.buf_edit_or_qf, + ["alt-q"] = actions.buf_sel_to_qf, + ["alt-l"] = actions.buf_sel_to_ll + }, + } + o.blines = { + previewer = "builtin", -- set to 'false' to disable + prompt = 'BLines❯ ', + show_unlisted = true, -- include 'help' buffers + no_term_buffers = false, -- include 'term' buffers + -- start = "cursor" -- start display from cursor? + fzf_opts = { + -- hide filename, tiebreak by line no. + ["--delimiter"] = "'[:]'", + ["--with-nth"] = '2..', + ["--tiebreak"] = 'index', + ["--tabstop"] = "1", + }, + -- actions inherit from 'actions.buffers' and merge + actions = { + ["default"] = actions.buf_edit_or_qf, + ["ctrl-l"] = actions.buf_edit_or_qf, + ["alt-q"] = actions.buf_sel_to_qf, + ["alt-l"] = actions.buf_sel_to_ll + }, + } + o.tags = { + prompt = 'Tags❯ ', + ctags_file = nil, -- auto-detect from tags-option + multiprocess = true, + file_icons = true, + git_icons = true, + color_icons = true, + -- 'tags_live_grep' options, `rg` prioritizes over `grep` + rg_opts = "--no-heading --color=always --smart-case", + grep_opts = "--color=auto --perl-regexp", + fzf_opts = { ["--info"] = "default", ["--tiebreak"] = "begin" }, + actions = { + -- actions inherit from 'actions.files' and merge + -- this action toggles between 'grep' and 'live_grep' + ["ctrl-g"] = { actions.grep_lgrep } + }, + no_header = false, -- hide grep|cwd header? + no_header_i = false, -- hide interactive header? + } + o.btags = { + prompt = 'BTags❯ ', + ctags_file = nil, -- auto-detect from tags-option + ctags_autogen = false, -- dynamically generate ctags each call + multiprocess = true, + file_icons = false, + git_icons = false, + rg_opts = "--color=never --no-heading", + grep_opts = "--color=never --perl-regexp", + fzf_opts = { ["--info"] = "default", ["--tiebreak"] = "begin" }, + -- actions inherit from 'actions.files' + } + o.colorschemes = { + prompt = 'Colorschemes❯ ', + live_preview = true, -- apply the colorscheme on preview? + actions = { ["default"] = actions.colorscheme, }, + winopts = { height = 0.55, width = 0.30, }, + -- uncomment to ignore colorschemes names (lua patterns) + -- ignore_patterns = { "^delek$", "^blue$" }, + -- uncomment to execute a callback after interface is closed + -- e.g. a call to reset statusline highlights + -- post_reset_cb = function() ... end, + } + o.keymaps = { + prompt = "Keymaps> ", + winopts = { preview = { layout = "vertical" } }, + fzf_opts = { ["--tiebreak"] = "index", }, + -- by default, we ignore and mappings + -- set `ignore_patterns = false` to disable filtering + ignore_patterns = { "^", "^" }, + actions = { + ["default"] = actions.keymap_apply, + ["ctrl-s"] = actions.keymap_split, + ["ctrl-v"] = actions.keymap_vsplit, + ["ctrl-t"] = actions.keymap_tabedit, + ["ctrl-l"] = actions.keymap_apply, + }, + } + o.quickfix = { + file_icons = true, + git_icons = true, + } + o.quickfix_stack = { + prompt = "Quickfix Stack> ", + marker = ">", -- current list marker + } + o.lsp = { + prompt_postfix = '❯ ', -- will be appended to the LSP label + -- to override use 'prompt' instead + cwd_only = false, -- LSP/diagnostics for cwd only? + async_or_timeout = 5000, -- timeout(ms) or 'true' for async calls + file_icons = true, + git_icons = false, + -- The equivalent of using `includeDeclaration` in lsp buf calls, e.g: + -- :lua vim.lsp.buf.references({includeDeclaration = false}) + includeDeclaration = true, -- include current declaration in LSP context + -- settings for 'lsp_{document|workspace|lsp_live_workspace}_symbols' + symbols = { + async_or_timeout = true, -- symbols are async by default + symbol_style = 1, -- style for document/workspace symbols + -- false: disable, 1: icon+kind + -- 2: icon only, 3: kind only + -- NOTE: icons are extracted from + -- vim.lsp.protocol.CompletionItemKind + -- icons for symbol kind + -- see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#symbolKind + -- see https://github.com/neovim/neovim/blob/829d92eca3d72a701adc6e6aa17ccd9fe2082479/runtime/lua/vim/lsp/protocol.lua#L117 + symbol_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 = "󰗴", + }, + -- colorize using Treesitter '@' highlight groups ("@function", etc). + -- or 'false' to disable highlighting + symbol_hl = function(s) return "@" .. s:lower() end, + -- additional symbol formatting, works with or without style + symbol_fmt = function(s, opts) return "[" .. s .. "]" end, + -- prefix child symbols. set to any string or `false` to disable + child_prefix = true, + fzf_opts = { + ["--tiebreak"] = "begin", + ["--info"] = "default", + }, + }, + code_actions = { + prompt = 'Code Actions> ', + async_or_timeout = 5000, + -- when git-delta is installed use "codeaction_native" for beautiful diffs + -- try it out with `:FzfLua lsp_code_actions previewer=codeaction_native` + -- scroll up to `previewers.codeaction{_native}` for more previewer options + previewer = "codeaction", + winopts = { + width = 0.5, + height = 0.4 + } + }, + finder = { + prompt = icons.ui.Search.."LSP Finder> ", + fzf_opts = { ["--info"] = "default" }, + file_icons = true, + color_icons = true, + git_icons = false, + async = true, -- async by default + silent = true, -- suppress "not found" + separator = "| ", -- separator after provider prefix, `false` to disable + includeDeclaration = true, -- include current declaration in LSP context + -- by default display all LSP locations + -- to customize, duplicate table and delete unwanted providers + providers = { + { "references", prefix = require("fzf-lua").utils.ansi_codes.blue("ref ") }, + { "definitions", prefix = require("fzf-lua").utils.ansi_codes.green("def ") }, + { "declarations", prefix = require("fzf-lua").utils.ansi_codes.magenta("decl") }, + { "typedefs", prefix = require("fzf-lua").utils.ansi_codes.red("tdef") }, + { "implementations", prefix = require("fzf-lua").utils.ansi_codes.green("impl") }, + { "incoming_calls", prefix = require("fzf-lua").utils.ansi_codes.cyan("in ") }, + { "outgoing_calls", prefix = require("fzf-lua").utils.ansi_codes.yellow("out ") }, + }, + } + } + o.diagnostics = { + prompt = 'Diagnostics❯ ', + cwd_only = false, + file_icons = true, + git_icons = false, + diag_icons = true, + diag_source = true, -- display diag source (e.g. [pycodestyle]) + icon_padding = '', -- add padding for wide diagnostics signs + multiline = true, -- concatenate multi-line diags into a single line + -- set to `false` to display the first line only + -- by default icons and highlights are extracted from 'DiagnosticSignXXX' + -- and highlighted by a highlight group of the same name (which is usually + -- set by your colorscheme, for more info see: + -- :help DiagnosticSignHint' + -- :help hl-DiagnosticSignHint' + -- only uncomment below if you wish to override the signs/highlights + -- define only text, texthl or both (':help sign_define()' for more info) + signs = { + ["Error"] = { text = icons.diagnostics.Error, texthl = "DiagnosticError" }, + ["Warn"] = { text = icons.diagnostics.Warning, texthl = "DiagnosticWarn" }, + ["Info"] = { text = icons.diagnostics.Information, texthl = "DiagnosticInfo" }, + ["Hint"] = { text = icons.diagnostics.Hint, texthl = "DiagnosticHint" }, + }, + -- limit to specific severity, use either a string or num: + -- 1 or "hint" + -- 2 or "information" + -- 3 or "warning" + -- 4 or "error" + -- severity_only: keep any matching exact severity + -- severity_limit: keep any equal or more severe (lower) + -- severity_bound: keep any equal or less severe (higher) + } + o.complete_path = { + cmd = nil, -- default: auto detect fd|rg|find + complete = { ["default"] = actions.complete }, + } + o.complete_file = { + cmd = nil, -- default: auto detect rg|fd|find + file_icons = true, + color_icons = true, + git_icons = false, + -- actions inherit from 'actions.files' and merge + actions = { ["default"] = actions.complete }, + -- previewer hidden by default + winopts = { preview = { hidden = "hidden" } }, + } + -- uncomment to use fzf native previewers + -- (instead of using a neovim floating window) + -- manpages = { previewer = "man_native" }, + -- helptags = { previewer = "help_native" }, + -- + -- optional override of file extension icon colors + -- available colors (terminal): + -- clear, bold, black, red, green, yellow + -- blue, magenta, cyan, grey, dark_grey, white + o.file_icon_colors = { + ["sh"] = "green", + } + -- padding can help kitty term users with + -- double-width icon rendering + o.file_icon_padding = '' + -- uncomment if your terminal/font does not support unicode character + -- 'EN SPACE' (U+2002), the below sets it to 'NBSP' (U+00A0) instead + -- nbsp = '\xc2\xa0', + o.hls = { + -- title = "FloatTitle", + -- normal = "FloatNormal", + border = "FloatBorder", + } + end, + config = function(_, o) + -- local icons = require "lib.icons" + local fzf = require "fzf-lua" + fzf.setup(o) + + -- Keymaps + + vim.keymap.set("n", + "fF", + function() + fzf.live_grep() + end, + { desc = "Find Text (LiveGrep)" } + ) + vim.keymap.set("n", + "fH", + function() + local cword = vim.fn.expand "" + fzf.help_tags({ default_text = cword }) + end, + { desc = "Help" } + ) + vim.keymap.set("n", + "fg", + function() + fzf.git_files() + end, + { desc = "Git Files" } + ) + -- vim.keymap.set("n", + -- "fp", + -- function() + -- telescope.extensions.project.project() + -- end, + -- { desc = "Projects" } + -- ) + vim.keymap.set("n", + "fR", + function() + fzf.registers() + end, + { desc = "Registers" } + ) + vim.keymap.set("n", + "fq", + function() + fzf.quickfix() + end, + { desc = "QuickFix" } + ) + vim.keymap.set("n", + "fQ", + function() + fzf.loclist() + end, + { desc = "LocationList" } + ) + vim.keymap.set("n", + "fl", + function() + fzf.resume() + end, + { desc = "Resume last" } + ) + vim.keymap.set("n", + "fc", + function() + fzf.current_buffer_fuzzy_find() + end, + { desc = "Line fuzzy" } + ) + vim.keymap.set("n", + "fC", + function() + fzf.commands() + end, + { desc = "Colorscheme" } + ) + vim.keymap.set("n", + "fe", + function() + fzf.extensions.env.env() + end, + { desc = "Environment" } + ) + vim.keymap.set("n", + "fO", + function() + require("lib.software_licenses").pick_license() + end, + { desc = "Software Licenses" } + ) + -- vim.keymap.set("n", + -- "fE", + -- function() + -- telescope.extensions.emoji.emoji { + -- theme = "cursor", + -- initial_mode = "insert", + -- layout_strategy = "cursor", + -- layout_config = { + -- height = 0.4, + -- width = 0.5, + -- }, + -- } + -- end, + -- { desc = "Emoji" } + -- ) + + -- vim.keymap.set("n", + -- "fb", + -- function() + -- telescope.extensions.file_browser.file_browser { + -- cwd = vim.fn.getcwd(), + -- } + -- end, + -- { desc = "File Browser (CWD)" } + -- ) + vim.keymap.set("n", + "fs", + function() + fzf.grep_string { + theme = "dropdown", + previewer = false, + } + end, + { desc = "Grep < cword >" } + ) + + vim.keymap.set("n", + "ff", + function() + fzf.files() + end, + { desc = "Find Files" } + ) + vim.keymap.set("n", + "fo", + function() + fzf.builtin() + end, + { desc = "Open Fzf" } + ) + vim.keymap.set("n", + "fr", + function() + fzf.oldfiles() + end, + { desc = "Recent Files" } + ) + + -- vim.keymap.set("n", + -- "fU", + -- function() + -- telescope.extensions.file_browser.file_browser { + -- cwd = "~/Informatica/", + -- } + -- end, + -- { desc = "University Folder" } + -- ) + + vim.keymap.set("n", + "gs", + function() + fzf.git_status() + end, + { desc = "Git status" } + ) + vim.keymap.set("n", + "gb", + function() + fzf.git_branches() + end, + { desc = "Checkout branch" } + ) + vim.keymap.set("n", + "gc", + function() + fzf.git_commits() + end, + { desc = "Checkout commit" } + ) + + vim.keymap.set("n", + "lD", + function() + fzf.diagnostics_document() + end, + { desc = "Lsp Diagnostics" } + ) + + vim.keymap.set({ "n", "v", "i" }, "", function() + require("fzf-lua").complete_path() + end, { silent = true, desc = "Fuzzy complete path" }) + + + require("fzf-lua").register_ui_select(function(_, items) + local min_h, max_h = 0.15, 0.70 + local h = (#items + 4) / vim.o.lines + if h < min_h then + h = min_h + elseif h > max_h then + h = max_h + end + return { winopts = { height = h, width = 0.60, row = 0.40 } } + end) + + vim.api.nvim_create_autocmd("VimResized", { + pattern = '*', + callback = function() fzf.redraw() end + }) + end + -- "nvim-telescope/telescope-file-browser.nvim", + -- "nvim-telescope/telescope-project.nvim", +} + +return M \ No newline at end of file diff --git a/lua/plugins/editor/telescope.lua b/lua/plugins/editor/telescope.lua index 1d83cae..d3008d8 100644 --- a/lua/plugins/editor/telescope.lua +++ b/lua/plugins/editor/telescope.lua @@ -7,839 +7,694 @@ local function git_hunks() - require("telescope.pickers") - .new({ - finder = require("telescope.finders").new_oneshot_job( - { "git", "jump", "--stdout", "diff" }, - { - entry_maker = function(line) - local filename, lnum_string = line:match "([^:]+):(%d+).*" - - -- I couldn't find a way to use grep in new_oneshot_job so we have to filter here. - -- return nil if filename is /dev/null because this means the file was deleted. - if filename:match "^/dev/null" then - return nil - end - - return { - value = filename, - display = line, - ordinal = line, - filename = filename, - lnum = tonumber(lnum_string), - } - end, - } - ), - sorter = require("telescope.sorters").get_generic_fuzzy_sorter(), - previewer = require("telescope.config").values.grep_previewer {}, - results_title = "Git hunks", - prompt_title = "Git hunks", - layout_strategy = "flex", - }, {}) - :find() + require("telescope.pickers") + .new({ + finder = require("telescope.finders").new_oneshot_job( + { "git", "jump", "--stdout", "diff" }, + { + entry_maker = function(line) + local filename, lnum_string = line:match "([^:]+):(%d+).*" + + -- I couldn't find a way to use grep in new_oneshot_job so we have to filter here. + -- return nil if filename is /dev/null because this means the file was deleted. + if filename:match "^/dev/null" then + return nil + end + + return { + value = filename, + display = line, + ordinal = line, + filename = filename, + lnum = tonumber(lnum_string), + } + end, + } + ), + sorter = require("telescope.sorters").get_generic_fuzzy_sorter(), + previewer = require("telescope.config").values.grep_previewer {}, + results_title = "Git hunks", + prompt_title = "Git hunks", + layout_strategy = "flex", + }, {}) + :find() end local select_one_or_multi = function(prompt_bufnr, action) - local picker = require('telescope.actions.state').get_current_picker(prompt_bufnr) - local multi = picker:get_multi_selection() - if not vim.tbl_isempty(multi) then - require('telescope.actions').close(prompt_bufnr) - for _, j in pairs(multi) do - if j.path ~= nil then - vim.cmd(string.format("%s %s", action, j.path)) + local picker = require('telescope.actions.state').get_current_picker(prompt_bufnr) + local multi = picker:get_multi_selection() + if not vim.tbl_isempty(multi) then + require('telescope.actions').close(prompt_bufnr) + for _, j in pairs(multi) do + if j.path ~= nil then + vim.cmd(string.format("%s %s", action, j.path)) + end end - end - else - if action == 'edit' then - require('telescope.actions').select_default(prompt_bufnr) - elseif action == 'sp' then - require('telescope.actions').select_horizontal(prompt_bufnr) - elseif action == 'vsp' then - require('telescope.actions').select_vertical(prompt_bufnr) - elseif action == 'tabe' then - require('telescope.actions').select_tab(prompt_bufnr) - end - end + else + if action == 'edit' then + require('telescope.actions').select_default(prompt_bufnr) + elseif action == 'sp' then + require('telescope.actions').select_horizontal(prompt_bufnr) + elseif action == 'vsp' then + require('telescope.actions').select_vertical(prompt_bufnr) + elseif action == 'tabe' then + require('telescope.actions').select_tab(prompt_bufnr) + end + end end +local function filenameFirst(_, path) + local tail = vim.fs.basename(path) + local parent = vim.fs.dirname(path) + if parent == "." then return tail end + return string.format("%s\t\t%s", tail, parent) +end + local M = { - { - "nvim-telescope/telescope.nvim", - cmd = { "Telescope" }, - dependencies = { - "nvim-lua/plenary.nvim", - "benfowler/telescope-luasnip.nvim", - "LinArcX/telescope-env.nvim", - "nvim-telescope/telescope-ui-select.nvim", - }, - keys = { - -- { - -- "e", - -- function() - -- require("telescope").extensions.file_browser.file_browser() - -- end, - -- desc = "File Browser", - -- }, - { - "b", - function() - require("telescope.builtin").buffers() - end, - desc = "Buffers", + { + "nvim-telescope/telescope.nvim", + cmd = { "Telescope" }, + dependencies = { + "nvim-lua/plenary.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make" + }, + "benfowler/telescope-luasnip.nvim", + "LinArcX/telescope-env.nvim", + "nvim-telescope/telescope-ui-select.nvim", + -- "nvim-telescope/telescope-file-browser.nvim", }, - { "f", nil, desc = "Telescope", }, - }, - opts = function(_, o) - local icons = require "lib.icons" - - local actions = require "telescope.actions" - local action_layout = require "telescope.actions.layout" - -- local fb_actions = require("telescope").extensions.file_browser.actions - local action_state = require "telescope.actions.state" - - o.defaults = { - preview = { - hide_on_startup = true, - }, - -- buffer_previewer_maker = new_maker, - initial_mode = "insert", - prompt_prefix = icons.ui.Telescope .. " ", - selection_caret = "> ", - path_display = { "smart" }, - file_ignore_patterns = { "Icon?", ".DS_Store" }, - selection_strategy = "reset", - scroll_strategy = "cycle", - layout_strategy = "horizontal", - layout = { horizontal = { width = 0.5 } }, - winblend = 6, - mappings = { - i = { - [""] = "move_selection_next", - [""] = "move_selection_previous", - - [""] = "close", - [""] = false, - [""] = { "", type = "command" }, - - [""] = "move_selection_next", - [""] = "move_selection_previous", - - [""] = function(pb) select_one_or_multi(pb, 'edit') end, - [""] = function(pb) select_one_or_multi(pb, 'edit') end, - [""] = function(pb) select_one_or_multi(pb, 'sp') end, - [""] = function(pb) select_one_or_multi(pb, 'vsp') end, - [""] = function(pb) select_one_or_multi(pb, 'tabe') end, - - [""] = "preview_scrolling_up", - [""] = "preview_scrolling_down", - - [""] = "results_scrolling_up", - [""] = "results_scrolling_down", - - [""] = actions.toggle_selection + actions.move_selection_worse, - [""] = actions.toggle_selection + actions.move_selection_better, - -- [""] = actions.toggle_selection + actions.move_selection_worse, - -- [""] = actions.toggle_selection + actions.move_selection_better, - [""] = actions.send_to_qflist + actions.open_qflist, - ["„"] = false, - - [""] = action_layout.toggle_preview, - - -- [""] = fb_actions.goto_parent_dir, - - ["?"] = "which_key", - }, - - n = { - [""] = "close", - ["q"] = "close", - [""] = function(pb) select_one_or_multi(pb, 'edit') end, - [""] = function(pb) select_one_or_multi(pb, 'edit') end, - [""] = function(pb) select_one_or_multi(pb, 'sp') end, - [""] = function(pb) select_one_or_multi(pb, 'vsp') end, - [""] = function(pb) select_one_or_multi(pb, 'tabe') end, - [""] = "close", - - -- [""] = "toggle_selection + actions.move_selection_worse"", - -- [""] = "toggle_selection + actions.move_selection_better"", - [""] = actions.send_to_qflist + actions.open_qflist, - ["„"] = false, - - [""] = "move_selection_next", - [""] = "move_selection_previous", - - ["j"] = "move_selection_next", - ["k"] = "move_selection_previous", - ["l"] = "select_default", - ["H"] = "move_to_top", - ["M"] = "move_to_middle", - ["L"] = "move_to_bottom", - ["g"] = false, -- disable map - ["h"] = false, -- disable map - - [""] = "move_selection_next", - [""] = "move_selection_previous", - - [""] = "preview_scrolling_up", - [""] = "preview_scrolling_down", - - [""] = "results_scrolling_up", - [""] = "results_scrolling_down", - - [""] = action_layout.toggle_preview, - - ["cd"] = function(prompt_bufnr) -- cd to dir in normal mode - local selection = action_state.get_selected_entry() - local dir = vim.fn.fnamemodify(selection.path, ":p:h") - actions.close(prompt_bufnr) - -- Depending on what you want put `cd`, `lcd`, `tcd` - vim.cmd(string.format("silent tcd %s", dir)) + keys = { + { + "b", + function() + require("telescope.builtin").buffers() end, - - ["?"] = "which_key", - }, - }, - } - - o.pickers = { - find_files = { - theme = "dropdown", - previewer = false, - sorting_strategy = "descending", - layout_strategy = "center", - layout_config = { - prompt_position = "bottom", - height = 0.4, - }, - cwd = require("lspconfig.util").find_git_ancestor(vim.fn.expand "%:p:h") - or vim.fn.expand "%:p:h", - no_ignore = true, - mappings = { - n = { - ["h"] = function(prompt_bufnr) - local current_picker = - require("telescope.actions.state").get_current_picker( - prompt_bufnr - ) - local opts = { - hidden = true, - default_text = current_picker:_get_prompt(), - } - - require("telescope.actions").close(prompt_bufnr) - require("telescope.builtin").find_files(opts) - end, - ["g"] = function(prompt_bufnr) - local current_picker = - require("telescope.actions.state").get_current_picker( - prompt_bufnr - ) - local opts = { - default_text = current_picker:_get_prompt(), - cwd = vim.fn.expand "%:p:h:h", - } - - require("telescope.actions").close(prompt_bufnr) - require("telescope.builtin").resume(opts) - end, + desc = "Buffers", + }, + { "f", nil, desc = "Telescope", }, + }, + opts = function(_, o) + local icons = require "lib.icons" + + local actions = require "telescope.actions" + local action_layout = require "telescope.actions.layout" + -- local fb_actions = require("telescope").extensions.file_browser.actions + local action_state = require "telescope.actions.state" + + o.defaults = { + preview = { hide_on_startup = true }, + initial_mode = "insert", + prompt_prefix = icons.ui.Telescope .. " ", + selection_caret = "> ", + entry_prefix = " ", + path_display = { "smart" }, + file_ignore_patterns = { "Icon?", ".DS_Store" }, + selection_strategy = "reset", + scroll_strategy = "cycle", + layout_strategy = "horizontal", + layout = { horizontal = { width = 0.5 } }, + winblend = 6, + mappings = { + i = { + [""] = "move_selection_next", + [""] = "move_selection_previous", + + [""] = "close", + [""] = false, + [""] = { "", type = "command" }, + + [""] = "move_selection_next", + [""] = "move_selection_previous", + + [""] = function(pb) select_one_or_multi(pb, 'edit') end, + [""] = function(pb) select_one_or_multi(pb, 'edit') end, + [""] = function(pb) select_one_or_multi(pb, 'sp') end, + [""] = function(pb) select_one_or_multi(pb, 'vsp') end, + [""] = function(pb) select_one_or_multi(pb, 'tabe') end, + + [""] = "preview_scrolling_up", + [""] = "preview_scrolling_down", + + [""] = "results_scrolling_up", + [""] = "results_scrolling_down", + + [""] = actions.toggle_selection + actions.move_selection_worse, + [""] = actions.toggle_selection + actions.move_selection_better, + -- [""] = actions.toggle_selection + actions.move_selection_worse, + -- [""] = actions.toggle_selection + actions.move_selection_better, + [""] = actions.send_to_qflist + actions.open_qflist, + ["„"] = false, + + [""] = action_layout.toggle_preview, + + -- [""] = fb_actions.goto_parent_dir, + + ["?"] = "which_key", + }, + + n = { + [""] = "close", + ["q"] = "close", + [""] = function(pb) select_one_or_multi(pb, 'edit') end, + [""] = function(pb) select_one_or_multi(pb, 'edit') end, + [""] = function(pb) select_one_or_multi(pb, 'sp') end, + [""] = function(pb) select_one_or_multi(pb, 'vsp') end, + [""] = function(pb) select_one_or_multi(pb, 'tabe') end, + [""] = "close", + + -- [""] = "toggle_selection + actions.move_selection_worse"", + -- [""] = "toggle_selection + actions.move_selection_better"", + [""] = actions.send_to_qflist + actions.open_qflist, + ["„"] = false, + + [""] = "move_selection_next", + [""] = "move_selection_previous", + + ["j"] = "move_selection_next", + ["k"] = "move_selection_previous", + ["l"] = "select_default", + ["H"] = "move_to_top", + ["M"] = "move_to_middle", + ["L"] = "move_to_bottom", + ["g"] = false, -- disable map + ["h"] = false, -- disable map + + [""] = "move_selection_next", + [""] = "move_selection_previous", + + [""] = "preview_scrolling_up", + [""] = "preview_scrolling_down", + + [""] = "results_scrolling_up", + [""] = "results_scrolling_down", + + [""] = action_layout.toggle_preview, + + ["cd"] = function(prompt_bufnr) -- cd to dir in normal mode + local selection = action_state.get_selected_entry() + local dir = vim.fn.fnamemodify(selection.path, ":p:h") + actions.close(prompt_bufnr) + -- Depending on what you want put `cd`, `lcd`, `tcd` + vim.cmd(string.format("silent tcd %s", dir)) + end, + + ["?"] = "which_key", + }, }, - i = { - [""] = function(prompt_bufnr) - local current_picker = - require("telescope.actions.state").get_current_picker( - prompt_bufnr - ) - local opts = { - default_text = current_picker:_get_prompt(), - cwd = vim.fn.expand "%:p:h:h", - } - - require("telescope.actions").close(prompt_bufnr) - require("telescope.builtin").find_files(opts) + } + + o.pickers = { + find_files = { + theme = "dropdown", + previewer = false, + sorting_strategy = "descending", + layout_strategy = "center", + layout_config = { + prompt_position = "bottom", + height = 0.4, + }, + cwd = require("lspconfig.util").find_git_ancestor(vim.fn.expand "%:p:h") + or vim.fn.expand "%:p:h", + no_ignore = true, + path_display = filenameFirst, + mappings = { + n = { + ["."] = function(prompt_bufnr) + local current_picker = + require("telescope.actions.state").get_current_picker( + prompt_bufnr + ) + local opts = { + hidden = true, + default_text = current_picker:_get_prompt(), + } + + require("telescope.actions").close(prompt_bufnr) + require("telescope.builtin").find_files(opts) + end, + ["g"] = function(prompt_bufnr) + local current_picker = + require("telescope.actions.state").get_current_picker( + prompt_bufnr + ) + local opts = { + default_text = current_picker:_get_prompt(), + cwd = vim.fn.expand "%:p:h:h", + } + + require("telescope.actions").close(prompt_bufnr) + require("telescope.builtin").resume(opts) + end, + }, + i = { + [""] = function(prompt_bufnr) + local current_picker = + require("telescope.actions.state").get_current_picker( + prompt_bufnr + ) + local opts = { + hidden = true, + default_text = current_picker:_get_prompt(), + } + + require("telescope.actions").close(prompt_bufnr) + require("telescope.builtin").find_files(opts) + end, + [""] = function(prompt_bufnr) + local current_picker = + require("telescope.actions.state").get_current_picker( + prompt_bufnr + ) + local opts = { + default_text = current_picker:_get_prompt(), + cwd = vim.fn.expand "%:p:h:h", + } + + require("telescope.actions").close(prompt_bufnr) + require("telescope.builtin").find_files(opts) + end, + }, + }, + }, + buffers = { + theme = "dropdown", + sort_mru = true, + ignore_current_buffer = true, + previewer = false, + initial_mode = "insert", + sorting_strategy = "descending", + path_display = filenameFirst, + layout_config = { + prompt_position = "bottom", + }, + mappings = { + i = { + [""] = "delete_buffer", + }, + n = { + ["x"] = "delete_buffer", + }, + }, + }, + oldfiles = { + previewer = false, + cwd_only = false, + initial_mode = "insert", + sorting_strategy = "descending", + layout_strategy = "vertical", + tiebreak = function(current, existing, _) + return current.index < existing.index end, + layout_config = { + prompt_position = "bottom", + height = 0.8, + width = 0.6, + }, + }, + live_grep = { + initial_mode = "insert", + sorting_strategy = "descending", + layout_strategy = "bottom_pane", + path_display = filenameFirst, + debounce = 400, + layout_config = { + prompt_position = "bottom", + height = 0.7, + }, + }, + git_files = { + previewer = false, + cwd_only = false, + initial_mode = "insert", + sorting_strategy = "descending", + layout_strategy = "vertical", + path_display = filenameFirst, + layout_config = { + prompt_position = "bottom", + height = 0.8, + width = 0.6, + }, + }, + git_status = { + theme = "dropdown", + previewer = false, + initial_mode = "normal", + sorting_strategy = "descending", + layout_strategy = "vertical", + layout_config = { + prompt_position = "bottom", + vertical = { width = 0.6, height = 0.4 }, + }, + }, + git_branches = { + theme = "dropdown", + previewer = false, + initial_mode = "normal", + sorting_strategy = "descending", + layout_strategy = "vertical", + layout_config = { + prompt_position = "bottom", + width = 0.6, + height = 0.4, + }, }, - }, - }, - buffers = { - theme = "dropdown", - sort_mru = true, - ignore_current_buffer = true, - previewer = false, - initial_mode = "insert", - sorting_strategy = "descending", - layout_config = { - prompt_position = "bottom", - }, - mappings = { - i = { - [""] = "delete_buffer", + commands = { + theme = "dropdown", + previewer = false, + initial_mode = "normal", + sorting_strategy = "descending", + layout_strategy = "vertical", + layout_config = { + prompt_position = "bottom", + width = 0.6, + height = 0.4, + }, }, - n = { - ["d"] = "delete_buffer", + diagnostics = { + bufnr = 0, + previewer = true, + initial_mode = "normal", + sorting_strategy = "descending", + layout_strategy = "vertical", + layout_config = { + prompt_position = "bottom", + vertical = { width = 0.6, height = 0.6 }, + }, }, - }, - }, - oldfiles = { - previewer = false, - cwd_only = false, - initial_mode = "insert", - sorting_strategy = "descending", - layout_strategy = "vertical", - layout_config = { - prompt_position = "bottom", - height = 0.8, - width = 0.6, - }, - }, - live_grep = { - initial_mode = "insert", - sorting_strategy = "descending", - layout_strategy = "bottom_pane", - debounce = 400, - layout_config = { - prompt_position = "bottom", - height = 0.7, - }, - }, - git_files = { - previewer = false, - cwd_only = false, - initial_mode = "insert", - sorting_strategy = "descending", - layout_strategy = "vertical", - layout_config = { - prompt_position = "bottom", - height = 0.8, - width = 0.6, - }, - }, - git_status = { - theme = "dropdown", - previewer = false, - initial_mode = "normal", - sorting_strategy = "descending", - layout_strategy = "vertical", - layout_config = { - prompt_position = "bottom", - vertical = { width = 0.6, height = 0.4 }, - }, - }, - git_branches = { - theme = "dropdown", - previewer = false, - initial_mode = "normal", - sorting_strategy = "descending", - layout_strategy = "vertical", - layout_config = { - prompt_position = "bottom", - width = 0.6, - height = 0.4, - }, - }, - diagnostics = { - bufnr = 0, - previewer = true, - initial_mode = "normal", - sorting_strategy = "descending", - layout_strategy = "vertical", - layout_config = { - prompt_position = "bottom", - vertical = { width = 0.6, height = 0.6 }, - }, - }, - lsp_references = { - previewer = true, - initial_mode = "normal", - layout_strategy = "vertical", - sorting_strategy = "descending", - layout_config = { - vertical = { width = 0.7, height = 0.6 }, - }, - }, - lsp_definitions = { - previewer = true, - initial_mode = "normal", - layout_strategy = "vertical", - sorting_strategy = "descending", - layout_config = { - vertical = { width = 0.7, height = 0.6 }, - }, - }, - lsp_type_definitions = { - previewer = true, - initial_mode = "normal", - layout_strategy = "vertical", - sorting_strategy = "descending", - layout_config = { - vertical = { width = 0.7, height = 0.6 }, - }, - }, - lsp_declarations = { - previewer = true, - initial_mode = "normal", - layout_strategy = "vertical", - sorting_strategy = "descending", - layout_config = { - vertical = { width = 0.7, height = 0.6 }, - }, - }, - lsp_implementations = { - previewer = true, - initial_mode = "normal", - layout_strategy = "vertical", - sorting_strategy = "descending", - layout_config = { - vertical = { width = 0.7, height = 0.6 }, - }, - }, - lsp_document_symbols = { - previewer = true, - initial_mode = "insert", - layout_strategy = "vertical", - sorting_strategy = "descending", - layout_config = { - vertical = { width = 0.7, height = 0.6 }, - }, - }, - lsp_dynamic_workspace_symbols = { - previewer = true, - initial_mode = "insert", - layout_strategy = "vertical", - sorting_strategy = "descending", - layout_config = { - vertical = { width = 0.7, height = 0.6 }, - }, - }, - registers = { - theme = "dropdown", - initial_mode = "normal", - layout_strategy = "center", - layout_config = { - prompt_position = "bottom", - vertical = { width = 0.7, height = 0.5 }, - }, - }, - keymaps = { - theme = "dropdown", - previewer = false, - initial_mode = "insert", - layout_strategy = "center", - layout_config = { - prompt_position = "bottom", - vertical = { width = 0.8, height = 0.6 }, - }, - }, - } - - o.extensions = { - -- file_browser = { - -- previewer = false, - -- cwd = "%:p:h", - -- initial_mode = "insert", - -- select_buffer = true, - -- hijack_netrw = true, - -- layout_strategy = "bottom_pane", - -- sorting_strategy = "ascending", - -- respect_gitignore = false, - -- hidden = false, - -- git_status = true, - -- color_devicons = true, - -- use_less = true, - -- layout_config = { - -- prompt_position = "bottom", - -- height = 0.5, - -- }, - -- -- on_input_filter_cb = function(prompt) - -- -- if prompt:sub(-1, -1) == os_sep then - -- -- local prompt_bufnr = vim.api.nvim_get_current_buf() - -- -- if vim.bo[prompt_bufnr].filetype == "TelescopePrompt" then - -- -- local current_picker = action_state.get_current_picker(prompt_bufnr) - -- -- if current_picker.finder.files then - -- -- fb_actions.toggle_browser(prompt_bufnr, { reset_prompt = true }) - -- -- current_picker:set_prompt(prompt:sub(1, -2)) - -- -- end - -- -- end - -- -- end - -- -- end, - -- mappings = { - -- i = { - -- [""] = fb_actions.goto_home_dir, - -- [""] = fb_actions.goto_cwd, - -- [""] = fb_actions.goto_parent_dir, - -- [""] = fb_actions.toggle_hidden, - -- [""] = fb_actions.change_cwd, - -- [""] = fb_actions.toggle_all, - -- [""] = "move_selection_next", - -- [""] = "move_selection_previous", - -- [""] = fb_actions.create, - -- [""] = fb_actions.rename, - -- [""] = fb_actions.move, - -- [""] = fb_actions.remove, - -- ["æ"] = fb_actions.copy, - -- -- Trash files instead of deleting them - -- ["∂"] = function(prompt_bufnr) - -- local fb_utils = - -- require "telescope._extensions.file_browser.utils" - -- -- Get the finder - -- local current_picker = - -- action_state.get_current_picker(prompt_bufnr) - -- local finder = current_picker.finder - -- -- Get the selections - -- local selections = - -- fb_utils.get_selected_files(prompt_bufnr, false) - -- if vim.tbl_isempty(selections) then - -- fb_utils.notify("actions.trash", { - -- msg = "No selection to be trashed!", - -- level = "WARN", - -- quiet = finder.quiet, - -- }) - -- return - -- end - - -- -- Trash the selected files - -- local trashed = {} - -- for _, selection in ipairs(selections) do - -- local filename = - -- selection.filename:sub(#selection:parent().filename + 2) - - -- vim.fn.jobstart( - -- "mv " - -- .. vim.fn.fnameescape(selection.filename) - -- .. " ~/.Trash", - -- { - -- detach = true, - -- on_exit = function() - -- -- vim.notify(" " .. filename .. " moved to Bin!", "Warn") - -- table.insert(trashed, filename) - -- end, - -- } - -- ) - -- end - -- -- Notify about operations - -- local message = "" - -- if not vim.tbl_isempty(trashed) then - -- message = message .. "Trashed: " .. table.concat(trashed, ", ") - -- end - -- fb_utils.notify( - -- "actions.trash", - -- { msg = message, level = "INFO", quiet = finder.quiet } - -- ) - -- -- Reset multi selection - -- current_picker:refresh( - -- current_picker.finder, - -- { reset_prompt = true } - -- ) - -- end, - -- }, - -- n = { - -- b = fb_actions.goto_home_dir, - -- g = fb_actions.goto_cwd, - -- h = fb_actions.goto_parent_dir, - -- x = fb_actions.change_cwd, - -- ["."] = fb_actions.toggle_hidden, - -- a = fb_actions.toggle_all, - -- j = "move_selection_next", - -- k = "move_selection_previous", - -- c = fb_actions.create, - -- r = fb_actions.rename, - -- m = fb_actions.move, - -- d = fb_actions.remove, - -- -- Trash files instead of deleting them - -- D = function(prompt_bufnr) - -- local fb_utils = - -- require "telescope._extensions.file_browser.utils" - -- -- Get the finder - -- local current_picker = - -- action_state.get_current_picker(prompt_bufnr) - -- local finder = current_picker.finder - -- -- Get the selections - -- local selections = - -- fb_utils.get_selected_files(prompt_bufnr, false) - -- if vim.tbl_isempty(selections) then - -- fb_utils.notify("actions.trash", { - -- msg = "No selection to be trashed!", - -- level = "WARN", - -- quiet = finder.quiet, - -- }) - -- return - -- end - - -- -- Trash the selected files - -- local trashed = {} - -- for _, selection in ipairs(selections) do - -- local filename = - -- selection.filename:sub(#selection:parent().filename + 2) - -- -- `trash-put` is from the `trash-cli` package - -- vim.fn.jobstart( - -- "mv " .. vim.fn.fnameescape(selection) .. " ~/.Trash", - -- { - -- detach = true, - -- on_exit = function() - -- -- vim.notify(" " .. filename .. " moved to Bin!", "Warn") - -- table.insert(trashed, filename) - -- end, - -- } - -- ) - -- end - -- -- Notify about operations - -- local message = "" - -- if not vim.tbl_isempty(trashed) then - -- message = message .. "Trashed: " .. table.concat(trashed, ", ") - -- end - -- fb_utils.notify( - -- "actions.trash", - -- { msg = message, level = "INFO", quiet = finder.quiet } - -- ) - -- -- Reset multi selection - -- current_picker:refresh( - -- current_picker.finder, - -- { reset_prompt = true } - -- ) - -- end, - -- }, - -- }, - -- }, - ["ui-select"] = { - theme = "dropdown", - layout_strategy = "center", - sorting_strategy = "descending", - layout_config = { - prompt_position = "bottom", - width = 0.5, - height = 0.5, - }, - }, - -- project = { - -- theme = "dropdown", - -- hidden_files = true, -- default: false - -- base_dirs = { - -- "~/Documents/Developer", - -- "~/dev", - -- "~/uni/", - -- "~/Informatica/Anno2/Semestre1/Programmazione II", - -- "~/Informatica/Anno3/Semestre1/Ingegneria del Software/Laboratorio", - -- }, - -- }, - -- emoji = { - -- theme = "cursor", - -- initial_mode = "insert", - -- layout_strategy = "cursor", - -- layout_config = { - -- height = 0.4, - -- width = 0.5, - -- }, - -- }, - } - end, - config = function(_, o) - local telescope = require "telescope" - telescope.setup(o) - - require("knvim.plugins.telescope") - - local tele_builtin = require "telescope.builtin" - - -- telescope.load_extension "file_browser" - telescope.load_extension "ui-select" - - -- Keymaps - - vim.keymap.set("n", - "fF", - function() - tele_builtin.live_grep() - end, - { desc = "Find Text (LiveGrep)" } - ) - vim.keymap.set("n", - "fH", - function() - local cword = vim.fn.expand "" - tele_builtin.help_tags({ default_text = cword }) - end, - { desc = "Help" } - ) - vim.keymap.set("n", - "fg", - function() - tele_builtin.git_files() - end, - { desc = "Git Files" } - ) - -- vim.keymap.set("n", - -- "fp", - -- function() - -- telescope.extensions.project.project() - -- end, - -- { desc = "Projects" } - -- ) - vim.keymap.set("n", - "fR", - function() - tele_builtin.registers() - end, - { desc = "Registers" } - ) - vim.keymap.set("n", - "fq", - function() - tele_builtin.quickfix() - end, - { desc = "QuickFix" } - ) - vim.keymap.set("n", - "fQ", - function() - tele_builtin.loclist() - end, - { desc = "LocationList" } - ) - vim.keymap.set("n", - "fl", - function() - tele_builtin.resume() - end, - { desc = "Resume last" } - ) - vim.keymap.set("n", - "fc", - function() - tele_builtin.current_buffer_fuzzy_find() - end, - { desc = "Line fuzzy" } - ) - vim.keymap.set("n", - "fC", - function() - tele_builtin.colorscheme() - end, - { desc = "Colorscheme" } - ) - vim.keymap.set("n", - "fe", - function() - telescope.extensions.env.env() - end, - { desc = "Environment" } - ) - vim.keymap.set("n", - "fO", - function() - require("lib.software_licenses").pick_license() - end, - { desc = "Software Licenses" } - ) - -- vim.keymap.set("n", - -- "fE", - -- function() - -- telescope.extensions.emoji.emoji { - -- theme = "cursor", - -- initial_mode = "insert", - -- layout_strategy = "cursor", - -- layout_config = { - -- height = 0.4, - -- width = 0.5, - -- }, - -- } - -- end, - -- { desc = "Emoji" } - -- ) - - -- vim.keymap.set("n", - -- "fb", - -- function() - -- telescope.extensions.file_browser.file_browser { - -- cwd = vim.fn.getcwd(), - -- } - -- end, - -- { desc = "File Browser (CWD)" } - -- ) - vim.keymap.set("n", - "fs", - function() - tele_builtin.grep_string { - theme = "dropdown", - previewer = false, - } - end, - { desc = "Grep < cword >" } - ) - - vim.keymap.set("n", - "ff", - function() - require("telescope.builtin").find_files() - end, - { desc = "Find Files" } - ) - vim.keymap.set("n", - "fo", - function() - require("telescope.builtin").builtin() - end, - { desc = "Open Telescope" } - ) - vim.keymap.set("n", - "fr", - function() - require("telescope.builtin").oldfiles() - end, - { desc = "Recent File" } - ) - - -- vim.keymap.set("n", - -- "fU", - -- function() - -- telescope.extensions.file_browser.file_browser { - -- cwd = "~/Informatica/", - -- } - -- end, - -- { desc = "University Folder" } - -- ) - - vim.keymap.set("n", - "gs", - function() - tele_builtin.git_status {} - end, - { desc = "Git status" } - ) - vim.keymap.set("n", - "gb", - function() - tele_builtin.git_branches {} - end, - { desc = "Checkout branch" } - ) - vim.keymap.set("n", - "gc", - function() - tele_builtin.git_commits {} - end, - { desc = "Checkout commit" } - ) - vim.keymap.set("n", - "gh", - function() - git_hunks() - end, - { desc = "Git Hunks" } - ) - - vim.keymap.set("n", - "lD", - function() - tele_builtin.diagnostics { bufnr = 0 } - end, - { desc = "Lsp Diagnostics" } - ) - end - }, - -- "nvim-telescope/telescope-file-browser.nvim", - -- "nvim-telescope/telescope-project.nvim", + lsp_references = { + previewer = true, + initial_mode = "normal", + layout_strategy = "vertical", + sorting_strategy = "descending", + layout_config = { + vertical = { width = 0.7, height = 0.6 }, + }, + }, + lsp_definitions = { + previewer = true, + initial_mode = "normal", + layout_strategy = "vertical", + sorting_strategy = "descending", + layout_config = { + vertical = { width = 0.7, height = 0.6 }, + }, + }, + lsp_type_definitions = { + previewer = true, + initial_mode = "normal", + layout_strategy = "vertical", + sorting_strategy = "descending", + layout_config = { + vertical = { width = 0.7, height = 0.6 }, + }, + }, + lsp_declarations = { + previewer = true, + initial_mode = "normal", + layout_strategy = "vertical", + sorting_strategy = "descending", + layout_config = { + vertical = { width = 0.7, height = 0.6 }, + }, + }, + lsp_implementations = { + previewer = true, + initial_mode = "normal", + layout_strategy = "vertical", + sorting_strategy = "descending", + layout_config = { + vertical = { width = 0.7, height = 0.6 }, + }, + }, + lsp_document_symbols = { + previewer = true, + initial_mode = "insert", + layout_strategy = "vertical", + sorting_strategy = "descending", + layout_config = { + vertical = { width = 0.7, height = 0.6 }, + }, + }, + lsp_dynamic_workspace_symbols = { + previewer = true, + initial_mode = "insert", + layout_strategy = "vertical", + sorting_strategy = "descending", + layout_config = { + vertical = { width = 0.7, height = 0.6 }, + }, + }, + registers = { + theme = "dropdown", + initial_mode = "normal", + layout_strategy = "center", + layout_config = { + prompt_position = "bottom", + vertical = { width = 0.7, height = 0.5 }, + }, + }, + keymaps = { + theme = "dropdown", + previewer = false, + initial_mode = "insert", + layout_strategy = "center", + layout_config = { + prompt_position = "bottom", + vertical = { width = 0.8, height = 0.6 }, + }, + }, + } + + o.extensions = { + ["ui-select"] = { + theme = "dropdown", + layout_strategy = "center", + sorting_strategy = "descending", + layout_config = { + prompt_position = "bottom", + width = 0.5, + height = 0.5, + }, + }, + } + end, + config = function(_, o) + local telescope = require "telescope" + telescope.setup(o) + + local tele_builtin = require "telescope.builtin" + + telescope.load_extension "fzf" + telescope.load_extension "ui-select" + -- telescope.load_extension "file_browser" + + vim.api.nvim_create_autocmd("FileType", { + pattern = "TelescopeResults", + callback = function(ctx) + vim.api.nvim_buf_call(ctx.buf, function() + vim.fn.matchadd("TelescopeParent", "\t\t.*$") + vim.api.nvim_set_hl(0, "TelescopeParent", { link = "Comment" }) + end) + end, + }) + + -- Keymaps + + vim.keymap.set("n", + "fF", + function() + tele_builtin.live_grep() + end, + { desc = "Find Text (LiveGrep)" } + ) + vim.keymap.set("n", + "fH", + function() + local cword = vim.fn.expand "" + tele_builtin.help_tags({ default_text = cword }) + end, + { desc = "Help" } + ) + vim.keymap.set("n", + "fg", + function() + tele_builtin.git_files() + end, + { desc = "Git Files" } + ) + -- vim.keymap.set("n", + -- "fp", + -- function() + -- telescope.extensions.project.project() + -- end, + -- { desc = "Projects" } + -- ) + vim.keymap.set("n", + "fR", + function() + tele_builtin.registers() + end, + { desc = "Registers" } + ) + vim.keymap.set("n", + "fq", + function() + tele_builtin.quickfix() + end, + { desc = "QuickFix" } + ) + vim.keymap.set("n", + "fQ", + function() + tele_builtin.loclist() + end, + { desc = "LocationList" } + ) + vim.keymap.set("n", + "fl", + function() + tele_builtin.resume() + end, + { desc = "Resume last" } + ) + vim.keymap.set("n", + "fc", + function() + tele_builtin.current_buffer_fuzzy_find() + end, + { desc = "Line fuzzy" } + ) + vim.keymap.set("n", + "fC", + function() + tele_builtin.commands() + end, + { desc = "Colorscheme" } + ) + vim.keymap.set("n", + "fe", + function() + telescope.extensions.env.env() + end, + { desc = "Environment" } + ) + vim.keymap.set("n", + "fO", + function() + require("lib.software_licenses").pick_license() + end, + { desc = "Software Licenses" } + ) + -- vim.keymap.set("n", + -- "fE", + -- function() + -- telescope.extensions.emoji.emoji { + -- theme = "cursor", + -- initial_mode = "insert", + -- layout_strategy = "cursor", + -- layout_config = { + -- height = 0.4, + -- width = 0.5, + -- }, + -- } + -- end, + -- { desc = "Emoji" } + -- ) + + -- vim.keymap.set("n", + -- "fb", + -- function() + -- telescope.extensions.file_browser.file_browser { + -- cwd = vim.fn.getcwd(), + -- } + -- end, + -- { desc = "File Browser (CWD)" } + -- ) + vim.keymap.set("n", + "fs", + function() + tele_builtin.grep_string { + theme = "dropdown", + previewer = false, + } + end, + { desc = "Grep < cword >" } + ) + + vim.keymap.set("n", + "ff", + function() + require("telescope.builtin").find_files() + end, + { desc = "Find Files" } + ) + vim.keymap.set("n", + "fo", + function() + require("telescope.builtin").builtin() + end, + { desc = "Open Telescope" } + ) + vim.keymap.set("n", + "fr", + function() + require("telescope.builtin").oldfiles() + end, + { desc = "Recent File" } + ) + + -- vim.keymap.set("n", + -- "fU", + -- function() + -- telescope.extensions.file_browser.file_browser { + -- cwd = "~/Informatica/", + -- } + -- end, + -- { desc = "University Folder" } + -- ) + + vim.keymap.set("n", + "gs", + function() + tele_builtin.git_status() + end, + { desc = "Git status" } + ) + vim.keymap.set("n", + "gb", + function() + tele_builtin.git_branches() + end, + { desc = "Checkout branch" } + ) + vim.keymap.set("n", + "gc", + function() + tele_builtin.git_commits() + end, + { desc = "Checkout commit" } + ) + vim.keymap.set("n", + "gh", + function() + git_hunks() + end, + { desc = "Git Hunks" } + ) + + vim.keymap.set("n", + "lD", + function() + tele_builtin.diagnostics { bufnr = 0 } + end, + { desc = "Lsp Diagnostics" } + ) + end + }, } return M \ No newline at end of file diff --git a/lua/plugins/editor/treesitter.lua b/lua/plugins/editor/treesitter.lua index e41df69..b69b52e 100644 --- a/lua/plugins/editor/treesitter.lua +++ b/lua/plugins/editor/treesitter.lua @@ -66,9 +66,12 @@ local M = { o.highlight = { enable = true, -- false will disable the whole extension additional_vim_regex_highlighting = { "markdown" }, - disable = function(_, bufnr) - return vim.api.nvim_buf_line_count(bufnr) > 10000 or - #vim.api.nvim_buf_get_lines(bufnr, 0, 1, false)[1] > 1000 + disable = function(_, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + + return ok and (stats and stats.size > max_filesize) or + #vim.api.nvim_buf_get_lines(buf, 0, 1, false)[1] > 1000 end } o.autopairs = { @@ -152,7 +155,12 @@ local M = { } }) - require "knvim.plugins.treesitter" + vim.api.nvim_create_user_command("Inspect", function() + vim.show_pos() + end, { desc = "Inspect" }) + vim.api.nvim_create_user_command("InspectTree", function() + vim.treesitter.inspect_tree() + end, { desc = "InspectTree" }) end }, } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index d877b68..4c69111 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -10,16 +10,13 @@ local M = { "nvim-tree/nvim-web-devicons", { - "kevinm6/knvim-theme.nvim", + "kevinm6/knvim.nvim", + lazy = false, dev = true, priority = 1000, config = function() - local has_theme, knvim = pcall(require, "knvim") - if not has_theme then - vim.notify(string.format("Error loading theme < knvim >:\n%s", knvim), vim.log.levels.INFO) - end - require("knvim").setup() - end, + vim.cmd.colorscheme('knvim') + end }, { @@ -47,34 +44,46 @@ local M = { { "3rd/image.nvim", - ft = { "markdown", "vimwiki", "image_nvim" }, + ft = { "markdown", "vimwiki", "image_nvim", "png", "jpeg", "jpg", "image_nvim" }, init = function() - package.path = package.path .. ";" .. vim.fn.expand "$HOME" .. "/.luarocks/share/lua/5.1/?/init.lua" - package.path = package.path .. ";" .. vim.fn.expand "$HOME" .. "/.luarocks/share/lua/5.1/?.lua" + package.path = package.path..";"..vim.env.HOME.."/.luarocks/share/lua/5.1/?/init.lua" + package.path = package.path..";"..vim.env.HOME.."/.luarocks/share/lua/5.1/?.lua" end, - config = function() - require "image".setup({ - backend = "kitty", - integrations = { - markdown = { - enabled = true, - sizing_strategy = "auto", - download_remote_images = true, - clear_in_insert_mode = true, - only_render_image_at_cursor = true, - filetypes = { "markdown", "vimwiki", "quarto" } - } - }, - hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp" } - }) + opts = function(_, o) + o.backend = "kitty" + o.window_overlap_clear_enabled = true -- toggles images when windows are overlapped + o.editor_only_render_when_focused = true -- auto show/hide images when the editor gains/looses focus + o.window_overlap_clear_ft_ignore = {} + o.integrations = { + markdown = { + enabled = true, + sizing_strategy = "auto", + download_remote_images = true, + clear_in_insert_mode = true, + only_render_image_at_cursor = true, + filetypes = { "markdown", "vimwiki", "quarto" } + } + } + o.hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp" } -- render image files as images when opened end }, -- Jupyter Notebook { "GCBallesteros/jupytext.nvim", - config = true, - event = { "BufReadPre *.ipynb", "BufNewFile *.ipynb" }, + lazy = false, + -- config = true, + event = { "VeryLazy", "BufReadPre *.ipynb", "BufNewFile *.ipynb" }, + config = function(_, o) + o.custom_language_formatting = { + python = { + extension = "qmd", + style = "quarto", + force_ft = true + } + } + require "jupytext".setup(o) + end -- "goerz/jupytext.vim", -- lazy = false, -- ft = { "jupyter_notebook" }, @@ -89,7 +98,7 @@ local M = { "benlubas/molten-nvim", -- event = { "BufWriteFile ".. vim.fn.expand (vim.b.jupyter_file) }, event = { "BufReadPre *.ipynb", "BufNewFile *.ipynb" }, - ft = { "quarto", "jupyter_notebook" }, + ft = { "qmd", "jupyter_notebook" }, version = "^1.0.0", build = ":UpdateRemotePlugins", dependencies = { "3rd/image.nvim" }, @@ -127,7 +136,7 @@ local M = { }, { "quarto-dev/quarto-nvim", - ft = { "quarto", "qmd" }, + ft = { "qmd" }, dependencies = { { "jmbuhr/otter.nvim", @@ -239,6 +248,7 @@ local M = { { 'vidocqh/data-viewer.nvim', ft = { "sqlite", "tsv", "csv" }, + cmd = { "DataViewerFocusTable", "DataViewer" }, dependencies = { "nvim-lua/plenary.nvim" }, config = function(_, o) require "data-viewer".setup(o) @@ -246,11 +256,9 @@ local M = { vim.api.nvim_set_hl(0, "DataViewerColumn0", { fg = "#4fc1ff", bold = true }) vim.api.nvim_set_hl(0, "DataViewerColumn1", { fg = "#6c7986" }) vim.api.nvim_set_hl(0, "DataViewerColumn2", { fg = "#626262" }) - vim.api.nvim_set_hl(0, "DataViewerFocuTable", { fg = "#00ff87", bold = true }) + vim.api.nvim_set_hl(0, "DataViewerFocusTable", { fg = "#00ff87", bold = true }) end - } - - + }, } diff --git a/lua/plugins/lsp/handlers.lua b/lua/plugins/lsp/handlers.lua index 44211af..7803bd4 100644 --- a/lua/plugins/lsp/handlers.lua +++ b/lua/plugins/lsp/handlers.lua @@ -12,9 +12,9 @@ M.setup = function() local signs = { { name = "DiagnosticSignError", text = icons.diagnostics.Error }, - { name = "DiagnosticSignWarn", text = icons.diagnostics.Warning }, - { name = "DiagnosticSignHint", text = icons.diagnostics.Hint }, - { name = "DiagnosticSignInfo", text = icons.diagnostics.Information }, + { name = "DiagnosticSignWarn", text = icons.diagnostics.Warning }, + { name = "DiagnosticSignHint", text = icons.diagnostics.Hint }, + { name = "DiagnosticSignInfo", text = icons.diagnostics.Information }, } for _, sign in ipairs(signs) do @@ -22,9 +22,17 @@ M.setup = function() end -- Vim LSP Diagnostic - vim.diagnostic.config { - virtual_text = true, - signs = { active = signs }, + local default_diagnostic_config = { + signs = { + active = true, + text = { + [vim.diagnostic.severity.ERROR] = icons.diagnostics.Error, + [vim.diagnostic.severity.WARN] = icons.diagnostics.Warning, + [vim.diagnostic.severity.INFO] = icons.diagnostics.Information, + [vim.diagnostic.severity.HINT] = icons.diagnostics.Hint, + }, + }, + virtual_text = false, update_in_insert = false, underline = true, severity_sort = true, @@ -37,6 +45,7 @@ M.setup = function() prefix = icons.lsp.nvim_lsp .. " ", }, } + vim.diagnostic.config(default_diagnostic_config) vim.diagnostic.open_float = (function(orig) return function(bufnr, opts) @@ -86,20 +95,8 @@ M.setup = function() dynamicRegistration = true }) - -- Jump directly to the first available definition every time. - -- vim.lsp.handlers["textDocument/definition"] = function(_, result) - -- if not result or vim.tbl_isempty(result) then - -- vim.notify("[LSP] Could not find definition", "Info") - -- return - -- elseif vim.tbl_islist(result) then - -- vim.lsp.util.jump_to_location(result[1], "utf-8") - -- else - -- vim.lsp.util.jump_to_location(result, "utf-8") - -- end - -- end - - - vim.lsp.handlers["workspace/workspaceFolders"] = vim.lsp.with(vim.lsp.handlers.workspaceFolders, { + vim.lsp.handlers["workspace/workspaceFolders"] = vim.lsp.with( + vim.lsp.handlers.workspaceFolders, { library = { [vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, @@ -107,15 +104,8 @@ M.setup = function() }) vim.lsp.handlers["textDocument/publishDiagnostics"] = - vim.lsp.with(vim.lsp.handlers["textDocument/publishDiagnostics"], { - signs = { - severity_limit = "Error", - }, - underline = { - severity_limit = "Warning", - }, - virtual_text = true, - }) + vim.lsp.with(vim.lsp.handlers["textDocument/publishDiagnostics"], + default_diagnostic_config) vim.lsp.handlers["textDocument/references"] = vim.lsp.with( vim.lsp.handlers["textDocument/references"], { @@ -123,46 +113,47 @@ M.setup = function() loclist = true, } ) - end M.implementation = function() local params = vim.lsp.util.make_position_params() - vim.lsp.buf_request(0, "textDocument/implementation", params, function(err, result, ctx, config) - local bufnr = ctx.bufnr - local ft = vim.api.nvim_buf_get_option(bufnr, "filetype") + vim.lsp.buf_request(0, "textDocument/implementation", params, + function(err, result, ctx, config) + local bufnr = ctx.bufnr + local ft = vim.api.nvim_buf_get_option(bufnr, "filetype") - -- do not shiow mocks for impls in golang - if ft == "go" then - local new_result = vim.tbl_filter(function(v) - return not string.find(v.uri, "mock_") - end, result) + -- do not shiow mocks for impls in golang + if ft == "go" then + local new_result = vim.tbl_filter(function(v) + return not string.find(v.uri, "mock_") + end, result) - if #new_result > 0 then - result = new_result + if #new_result > 0 then + result = new_result + end end - end - vim.lsp.handlers["textDocument/implementation"](err, result, ctx, config) - vim.cmd [[normal! zz]] - end) + vim.lsp.handlers["textDocument/implementation"](err, result, ctx, config) + vim.cmd [[normal! zz]] + end) end -M.code_action_listener = function() +local function code_action_listener() local context = { diagnostics = vim.lsp.diagnostic.get_line_diagnostics() } local params = vim.lsp.util.make_range_params() params.context = context vim.lsp.buf_request(0, 'textDocument/codeAction', params, function(err) - if err ~= nil then vim.notify(string.format("Code Action Listener: %s", err) , vim.log.levels.ERROR) end + if err ~= nil then vim.notify(string.format("Code Action Listener: %s", err), + vim.log.levels.ERROR) end end) end vim.api.nvim_create_autocmd({ "InsertLeave" }, { pattern = "*", callback = function() - M.code_action_listener() + code_action_listener() end, }) -return M +return M \ No newline at end of file diff --git a/lua/plugins/lsp/init.lua b/lua/plugins/lsp/init.lua index b3fd0f4..53616e2 100644 --- a/lua/plugins/lsp/init.lua +++ b/lua/plugins/lsp/init.lua @@ -2,7 +2,7 @@ -- File : init.lua -- Description : config all module to be imported -- Author : Kevin --- Last Modified: 03 Dec 2023, 10:48 +-- Last Modified: 06 Jan 2024, 09:11 ------------------------------------- ---Auto Stop LSP client if no more buffers attached. @@ -12,7 +12,7 @@ local set_auto_stop_lsp = function(client, bufnr) if (vim.fn.has "nvim-0.10" ~= 1) then return end vim.api.nvim_create_autocmd("BufDelete", { - group = vim.api.nvim_create_augroup("_lsp_timeout", {clear = false}), + group = vim.api.nvim_create_augroup("_lsp_timeout", { clear = false }), buffer = bufnr, callback = function(ev) local clients = vim.lsp.get_clients({ name = client.name, bufnr = bufnr })[1] or @@ -29,7 +29,7 @@ local set_auto_stop_lsp = function(client, bufnr) vim.notify("No more clients attached. Stopped.", vim.log.levels.INFO, { - title = "LSP: "..clients.name, + title = "LSP: " .. clients.name, } ) end, 6000) @@ -47,14 +47,17 @@ local set_buf_keymaps = function(client, _) client.server_capabilities.documentHighlightProvider = false end - local has_telescope, tele_builtin = pcall(require, "telescope.builtin") + -- local has_telescope, fzf.= pcall(require, "telescope.builtin") + local has_fzf, fzf = pcall(require, "fzf-lua") + + local map = vim.keymap.set -- local opts = { noremap = true, silent = true } - vim.keymap.set("n", "gl", function() + map("n", "gl", function() vim.diagnostic.open_float() - end, { buffer = true, desc = "Open float" }) + end, { desc = "Open float", buffer = true }) - vim.keymap.set("n", "K", function() + map("n", "K", function() local winid = require("ufo").peekFoldedLinesUnderCursor() if not winid then vim.lsp.buf.hover() @@ -62,123 +65,123 @@ local set_buf_keymaps = function(client, _) end, { desc = "Hover | PeekFold", buffer = true }) if client.server_capabilities.declarationProvider then - vim.keymap.set("n", "gD", function() - if has_telescope then - tele_builtin.lsp_definitions() + map("n", "gD", function() + if has_fzf then + fzf.lsp_declarations() else vim.lsp.buf.declaration() end - end, { buffer = true, desc = "LSP Declaration" }) + end, { desc = "LSP Declaration", buffer = true }) end if client.server_capabilities.definitionProvider then - vim.keymap.set("n", "gd", function() - if has_telescope then - tele_builtin.lsp_definitions() + map("n", "gd", function() + if has_fzf then + fzf.lsp_definitions() else vim.lsp.buf.definition() end - end, { buffer = true, desc = "LSP Definition" }) + end, { desc = "LSP Definition", buffer = true }) - vim.keymap.set("n", "ld", function() - if has_telescope then - tele_builtin.lsp_definitions() + map("n", "ld", function() + if has_fzf then + fzf.lsp_definitions() else vim.lsp.buf.definition() end - end, { buffer = true, desc = "LSP Definition" }) + end, { desc = "LSP Definition", buffer = true }) end if client.server_capabilities.implementationProvider then - vim.keymap.set("n", "gI", function() - if has_telescope then - tele_builtin.lsp_incoming_calls {} + map("n", "gI", function() + if has_fzf then + fzf.lsp_incoming_calls() else vim.lsp.buf.implementation() end - end, { buffer = true, desc = "LSP IncCalls" }) + end, { desc = "LSP Incoming-calls", buffer = true }) end if client.supports_method "callHierarchy/outgoingCalls" then - vim.keymap.set("n", "gC", function() - if has_telescope then - tele_builtin.lsp_outgoing_calls {} + map("n", "gC", function() + if has_fzf then + fzf.lsp_outgoing_calls() else vim.lsp.buf.outgoing_calls() end - end, { buffer = true, desc = "LSP OutCalls" }) + end, { desc = "LSP Outgoing-calls", buffer = true }) end if client.server_capabilities.referencesProvider then - vim.keymap.set("n", "gr", function() - if has_telescope then - tele_builtin.lsp_references {} + map("n", "gr", function() + if has_fzf then + fzf.lsp_references() else vim.lsp.buf.references() end end, { buffer = true, desc = "LSP References" }) - vim.keymap.set("n", "lr", function() - if has_telescope then - tele_builtin.lsp_references {} + map("n", "lr", function() + if has_fzf then + fzf.lsp_references() else vim.lsp.buf.references() end end, { buffer = true, desc = "LSP References" }) end - vim.keymap.set("n", "gs", function() - if has_telescope then - tele_builtin.lsp_document_symbols() + map("n", "gs", function() + if has_fzf then + fzf.lsp_document_symbols() else vim.lsp.buf.document_symbol() end end, { buffer = true, desc = "LSP Symbols" }) - vim.keymap.set("n", "ls", function() - if has_telescope then - tele_builtin.lsp_document_symbols() + map("n", "ls", function() + if has_fzf then + fzf.lsp_document_symbols() else vim.lsp.buf.document_symbol() end end, { buffer = true, desc = "LSP Symbols" }) - vim.keymap.set("n", "lt", function() - if has_telescope then - tele_builtin.lsp_type_definitions() + map("n", "lt", function() + if has_fzf then + fzf.lsp_typedefs() else vim.lsp.buf.type_definition() end end, { buffer = true, desc = "LSP TypeDef" }) - vim.keymap.set("n", "lS", function() - if has_telescope then - tele_builtin.lsp_dynamic_workspace_symbols {} + map("n", "lS", function() + if has_fzf then + fzf.lsp_workspace_symbols() else vim.lsp.buf.workspace_symbol() end - end, { desc = "Workspace Symbols" }) + end, { desc = "Workspace Symbols", buffer = true }) - vim.keymap.set("n", "ll", function() + map("n", "ll", function() vim.lsp.codelens.run() - end, { buffer = true, desc = "CodeLens Action" }) - vim.keymap.set("n", "la", function() + end, { desc = "CodeLens Action", buffer = true }) + map("n", "la", function() vim.lsp.buf.code_action() - end, { buffer = true, desc = "Code Action" }) - vim.keymap.set("n", "lI", function() + end, { desc = "Code Action", buffer = true }) + map("n", "lI", function() vim.cmd.LspInfo {} - end, { buffer = true, desc = "Lsp Info" }) - vim.keymap.set("n", "lL", function() + end, { desc = "Lsp Info", buffer = true }) + map("n", "lL", function() vim.cmd.LspLog {} - end, { buffer = true, desc = "Lsp Log" }) - vim.keymap.set("n", "r", function() + end, { desc = "Lsp Log", buffer = true }) + map("n", "r", function() vim.lsp.buf.rename() - end, { buffer = true, desc = "Rename" }) - vim.keymap.set("n", "lq", function() + end, { desc = "Rename", buffer = true }) + map("n", "lq", function() vim.diagnostic.setloclist() - end, { buffer = true, desc = "Lsp QFDiagnostics" }) + end, { desc = "Lsp QFDiagnostics", buffer = true }) -- Diagnostics - vim.keymap.set("n", "dj", function() + map("n", "dj", function() vim.diagnostic.goto_next { buffer = true } - end, { desc = "Next Diagnostic" }) - vim.keymap.set("n", "dk", function() + end, { desc = "Next Diagnostic", buffer = true }) + map("n", "dk", function() vim.diagnostic.goto_prev { buffer = true } - end, { desc = "Prev Diagnostic" }) + end, { desc = "Prev Diagnostic", buffer = true }) end @@ -187,15 +190,20 @@ end --- @param client any client passed to attach config --- @param bufnr any|integer buffer id passed to attach config local set_buf_funcs_for_capabilities = function(client, bufnr) + local map = vim.keymap.set + + if client.supports_method "textDocument/inlayHint" then + vim.lsp.inlay_hint.enable(bufnr, true) + end -- TODO: remove check for nvim_v0.10 after update if vim.lsp.inlay_hint then - vim.api.nvim_create_user_command("InlayHints", function () + vim.api.nvim_create_user_command("InlayHints", function() if vim.lsp.inlay_hint.is_enabled(bufnr) then vim.lsp.inlay_hint.enable(bufnr, false) else vim.lsp.inlay_hint.enable(bufnr, true) end - end, { desc = "Toggle Inlay hints"}) + end, { desc = "Toggle Inlay hints" }) end -- lsp-document_highlight @@ -234,18 +242,18 @@ local set_buf_funcs_for_capabilities = function(client, bufnr) lib_format.lsp_format(bufnr) end, { force = true }) - vim.keymap.set("n", "lf", function() + map("n", "lf", function() lib_format.lsp_format(bufnr) - end, { desc = "Format" }) - vim.keymap.set("n", "lF", function() + end, { desc = "Format", buffer = true }) + map("n", "lF", function() vim.cmd.LspToggleAutoFormat() - end, { desc = "Toggle AutoFormat" }) + end, { desc = "Toggle AutoFormat", buffer = true }) end if client.server_capabilities.documentRangeFormattingProvider then - vim.keymap.set("v", "lf", function() + map("v", "lf", function() require("lib.utils").range_format() - end, { desc = "Range format" }) + end, { desc = "Range format", buffer = true }) end vim.api.nvim_create_user_command("LspCapabilities", function() @@ -270,7 +278,6 @@ local custom_attach = function(client, bufnr) set_buf_keymaps(client, bufnr) set_buf_funcs_for_capabilities(client, bufnr) -- set_auto_stop_lsp(client, bufnr) - require "knvim.plugins.lsp" end local M = { @@ -294,6 +301,15 @@ local M = { ext_capabilities = cmp_nvim_lsp.default_capabilities() end + ext_capabilities.textDocument.completion.completionItem.snippetSupport = true + -- ext_capabilities.textDocument.completion.completionItem.resolveSupport = { + -- properties = { + -- "documentation", + -- "detail", + -- "additionalTextEdits" + -- } + -- } + local default_lsp_config = { on_init = custom_init, on_attach = custom_attach, @@ -308,7 +324,8 @@ local M = { function(server_name) if server_name ~= "jdtls" then lspconfig[server_name].setup(default_lsp_config) -- default handler (optional) - else return + else + return end end, @@ -346,7 +363,15 @@ local M = { }, checkThirdParty = false, }, - hint = { enable = true }, + hint = { + enable = true, + arrayIndex = "Auto", + await = true, + paramName = "Disable", + paramType = false, + semicolon = "SameLine", + setType = false + }, telemetry = { enable = false } }, }, @@ -405,9 +430,10 @@ local M = { }, }, root_dir = function(fname) - return lsputil.root_pattern(".git", "setup.py", "setup.cfg", "pyproject.toml", "requirements.txt")( - fname - ) or lsputil.path.dirname(fname) + return lsputil.root_pattern(".git", "setup.py", "setup.cfg", + "pyproject.toml", "requirements.txt")( + fname + ) or lsputil.path.dirname(fname) end, }) ) @@ -509,23 +535,25 @@ local M = { end, })) end, - ["erlangls"] = function() - lspconfig.erlangls.setup(vim.tbl_deep_extend("force", default_lsp_config, { - docs = { - description = [[ - https://github.com/erlang-ls/erlang_ls - ]], - }, - root_dir = lsputil.root_pattern("rebar.config", "erlang.mk", ".git") - or vim.loop.cwd(), - })) - end, + -- ["erlangls"] = function() + -- lspconfig.erlangls.setup(vim.tbl_deep_extend("force", default_lsp_config, { + -- docs = { + -- description = [[ + -- https://github.com/erlang-ls/erlang_ls + -- ]], + -- }, + -- root_dir = lsputil.root_pattern("rebar.config", "erlang.mk", ".git") + -- or vim.loop.cwd(), + -- })) + -- end, } -- sourcekit is still not available on mason-lspconfig lspconfig.sourcekit.setup(vim.tbl_deep_extend("force", default_lsp_config, { cmd = { - vim.fn.glob("/Applications/Xcode*.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp", true, true)[1] + vim.fn.glob( + "/Applications/Xcode*.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp", + true, true)[1] }, filetypes = { "swift" }, root_dir = function(filename, _) @@ -713,8 +741,6 @@ local M = { null_ls.builtins.hover.dictionary, null_ls.builtins.hover.printenv, } - - require "knvim.plugins.null_ls" end, }, diff --git a/lua/plugins/ui/dashboard.lua b/lua/plugins/ui/dashboard.lua index f7e8faf..44acf84 100644 --- a/lua/plugins/ui/dashboard.lua +++ b/lua/plugins/ui/dashboard.lua @@ -1,198 +1,144 @@ ----------------------------------- -- File: dashboard.lua --- Description: greeter config for Neovim (nvim-dashboard) +-- Description: greeter config for Neovim (using Alpha actually) -- Author: Kevin -- Last Modified: 03 Dec 2023, 10:48 ----------------------------------- ---Get date in nice style ---@return string date formatted -local function date() +local function get_date() return tostring(os.date " %d/%m/%Y  %H:%M") end ---Get Neovim version ---@return string nvim_version full neovim version -local function nvim_version() +local function get_nvim_version() local icons = require "lib.icons" local v = vim.version() - local v_info = string.format("%s v%s.%s.%s", icons.ui.Version, v.major, v.minor, v - .patch) + local v_info = string.format("%s v%s.%s.%s", icons.ui.Version, v.major, v.minor, v.patch) return v_info end +---Get centered string with prefixed spaces +---@param string_to_center string string passed to be centered +---@param cols_tot number | nil total number of coloumns to be used for center the string +---@return string centered_string string +local function center_string(string_to_center, cols_tot) + local center_cols = math.floor((cols_tot or vim.o.columns) / 2) + local center_str_len = math.floor(#string_to_center/2) + + local spaces = string.rep(" ", center_cols - center_str_len) + return string.format("%s%s", spaces, string_to_center) +end + +---Create footer for Alpha dashboard +---@return string footer_str +local function footer() + local plugins = require("lazy").stats().count + local loaded = require("lazy").stats().loaded + local icons = require "lib.icons" + + local plugins_count = string.format("%s %d Plugins | %d loaded", icons.ui.Plugin, plugins, loaded) + + -- local my_url = "github.com/kevinm6/nvim" + -- local myself = string.format(" %s %s ", icons.misc.GitHub, my_url) + + -- local footer_str = string.format("%s\n%s", + -- center_string(plugins_count, 30), + -- center_string(myself, 30) + -- ) + + return center_string(plugins_count, #plugins_count) +end + + local M = { - 'nvimdev/dashboard-nvim', - enabled = false, - event = 'VimEnter', + "goolord/alpha-nvim", + event = "VimEnter", keys = { - { "a", function() vim.cmd.Dashboard() end, desc = "Dashboard" } + { "a", function() vim.cmd.Alpha() end, desc = "Dashboard" } }, - config = function(_, o) + config = function() + local alpha = require "alpha" + local db = require "alpha.themes.dashboard" local icons = require "lib.icons" - local logo = [[ - ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗ - ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║ - ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║ - ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║ - ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║ - ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ - ]] - - logo = string.rep("\n", 4) .. logo .. "\n\n" - local header = function() - local str = string.format("%s\n%s\n%s", date(), logo, nvim_version()) - return vim.split(str, "\n") - end - - local footer = function() - local plugins = require("lazy").stats().count - local loaded = require("lazy").stats().loaded - - local plugins_count = string.format("%s %d Plugins | %d loaded", - icons.ui.Plugin, plugins, loaded) - return plugins_count - end - - o = { - theme = "doom", - hide = { - -- this is taken care of by lualine - -- enabling this messes up the actual laststatus setting after loading a file - statusline = false, - }, - config = { - header = header(), - week_heade = { - enable = true, - }, - disable_move = true, - -- date(), - -- nvim_version() - - center = { - { - action = "lua require 'lib.utils'.new_file()", - desc = "New File", - icon = icons.ui.NewFile, - key = "n" - }, - { - action = "lua require 'lib.utils'.new_tmp_file()()", - desc = "New temp file", - icon = icons.ui.NewFile, - key = "t" - }, - { - action = [[lua require "lib.notes".open_note()()]], - desc = "Notes", - icon = icons.ui.Note, - key = "o" - }, - { - action = "lua require 'telescope.builtin'.find_files()", - desc = "Find file", - icon = icons.documents.Files, - key = "f" - }, - { - action = "lua require 'telescope.builtin'.oldfiles()", - desc = "Recent files", - icon = icons.ui.History, - key = "r" - }, - { - action = "lua require 'lib.utils'.projects()", - desc = "Find project", - icon = icons.git.Repo, - key = "R" - }, - { - action = [[lua require "lib.utils".dev_folder()]], - desc = "Developer", - icon = icons.ui.Dev, - key = "d" - }, - { - action = "Lazy", - desc = "Plugin Manager", - icon = icons.ui.PluginManager, - key = "L" - }, - { - action = - [[lua require "oil".open_float(vim.fn.expand "$NVIMDOTDIR/lua/plugins")]], - desc = "Plugins config", - icon = icons.ui.Plugin, - key = "P" - }, - { - action = "Mason", - desc = "Package Manager", - icon = icons.ui.List, - key = "m" - }, - { - action = "Git", - desc = "Git", - icon = icons.ui.Git, - key = "g" - }, - { - action = "lua require 'lib.sessions'.restore_session()", - desc = "Sessions", - icon = icons.ui.History, - key = "S" - }, - { - action = [[lua require "oil".open_float(vim.fn.expand "$DOTFILES")]], - desc = "Dotfiles", - icon = icons.ui.Lock, - key = "D" - }, - { - action = "checkhealth", - desc = "Health", - icon = icons.ui.Health, - key = "H" - }, - -- { - -- action = "close", - -- desc = "Close", - -- icon = icons.documents.Files, - -- key = "c" - -- }, - { - action = "qa", - desc = "Quit", - icon = "", - icon_hl = "String", - key = "q" - }, - }, - footer = footer() - }, + local newline = [[ + ]] + + local date = get_date() + local nvim_version = get_nvim_version() + + db.section.header.val = { + center_string(date, 58), + newline, + [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], + [[ ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║]], + [[ ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║]], + [[ ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║]], + [[ ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║]], + [[ ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝]], + newline, + center_string(nvim_version, 55), + newline } - for _, button in ipairs(o.config.center) do - button.desc = " " .. button.desc .. string.rep(" ", 43 - #button.desc) - button.key_format = " %s" - end - - -- close Lazy and re-open when the dashboard is ready - -- if vim.o.filetype == "lazy" then - -- vim.cmd.close() - -- vim.api.nvim_create_autocmd("User", { - -- pattern = "DashboardLoaded", - -- callback = function() - -- require("lazy").show() - -- end, - -- }) - -- end - - require "knvim.plugins.dashboard" + local db_btn = db.button + db.section.buttons.val = { + db_btn("n", icons.ui.NewFile .. " New file", "lua require 'lib.utils'.new_file()"), + db_btn( + "t", + icons.ui.NewFile .. " New temp file", + "lua require 'lib.utils'.new_tmp_file()" + ), + db_btn("o", icons.ui.Note .. " Notes", [[lua require "lib.notes".open_note()]]), + + db_btn( + "f", + icons.documents.Files .. " Find file", + "lua require 'telescope.builtin'.find_files()" + ), + db_btn("r", icons.ui.History .. " Recent files", "lua require 'telescope.builtin'.oldfiles()"), + db_btn( + "R", + icons.git.Repo .. " Find project", + "lua require 'lib.utils'.projects()" + ), + db_btn("d", icons.ui.Dev .. " Developer", [[lua require "lib.utils".dev_folder()]]), + db_btn("L", icons.ui.PluginManager .. " Plugin Manager", "Lazy"), + db_btn( + "P", + icons.ui.Plugin .. " Plugins config", + [[lua require "oil".open_float(vim.fn.expand "$NVIMDOTDIR/lua/plugins")]] + ), + db_btn("m", icons.ui.List .. " Package Manager", "Mason"), + db_btn("g", icons.ui.Git .. " Git", "Git "), + db_btn( + "S", + icons.ui.History .. " Sessions", + "lua require 'lib.sessions'.restore_session()" + ), + db_btn( + "D", + icons.ui.Lock .. " Dotfiles", + [[lua require "oil".open_float(vim.fn.expand "$DOTFILES")]] + ), + db_btn("H", icons.ui.Health .. " Health", "checkhealth"), + db_btn("c", icons.documents.Files .. " Close", "Alpha"), + db_btn("q", icons.diagnostics.Error .. " Quit", "qa"), + } + + db.section.footer.val = footer + + db.section.header.opts.hl = "Type" + db.section.buttons.opts.hl = "Keyword" + db.section.footer.opts.hl = "Comment" + + db.config.opts.noautocmd = true + + alpha.setup(db.opts) end } diff --git a/lua/plugins/ui/greeter.lua b/lua/plugins/ui/greeter.lua deleted file mode 100644 index a2ccb7d..0000000 --- a/lua/plugins/ui/greeter.lua +++ /dev/null @@ -1,145 +0,0 @@ ------------------------------------ --- File: greeter.lua --- Description: greeter config for Neovim (using Alpha actually) --- Author: Kevin --- Last Modified: 03 Dec 2023, 10:48 ------------------------------------ - ----Get date in nice style ----@return string date formatted -local function date() - return tostring(os.date " %d/%m/%Y  %H:%M") -end - ----Get Neovim version ----@return string nvim_version full neovim version -local function nvim_version() - local icons = require "lib.icons" - local v = vim.version() - local v_info = string.format("%s v%s.%s.%s", icons.ui.Version, v.major, v.minor, v.patch) - return v_info -end - - ----Get centered string with prefixed spaces ----@param string_to_center string string passed to be centered ----@param cols_tot number total number of coloumns to be used for center the string ----@return string centered_string string -local function center_string(string_to_center, cols_tot) - local center_cols = math.floor((cols_tot or vim.o.columns) / 2) - local center_str_len = math.floor(#string_to_center/2) - - local spaces = string.rep(" ", center_cols - center_str_len) - return string.format("%s%s", spaces, string_to_center) -end - ----Create footer for Alpha dashboard ----@return string footer_str -local function footer() - local plugins = require("lazy").stats().count - local loaded = require("lazy").stats().loaded - local icons = require "lib.icons" - - local plugins_count = string.format("%s %d Plugins | %d loaded", icons.ui.Plugin, plugins, loaded) - - local my_url = "github.com/kevinm6/nvim" - local myself = string.format(" %s %s ", icons.misc.GitHub, my_url) - - local footer_str = string.format("%s\n%s", - center_string(plugins_count, 30), - center_string(myself, 30) - ) - - return footer_str -end - - -local M = { - "goolord/alpha-nvim", - event = "VimEnter", - keys = { - { "a", function() vim.cmd.Alpha {} end, desc = "Alpha Dashboard" } - }, - config = function() - local alpha = require "alpha" - local dashboard = require "alpha.themes.dashboard" - local icons = require "lib.icons" - - local newline = [[ - ]] - - dashboard.section.header.val = { - center_string(date(), 58), - newline, - [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], - [[ ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║]], - [[ ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║]], - [[ ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║]], - [[ ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║]], - [[ ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝]], - newline, - center_string(nvim_version(), 55) - } - - dashboard.section.buttons.val = { - dashboard.button("n", icons.ui.NewFile .. " New file", "lua require 'lib.utils'.new_file()"), - dashboard.button( - "t", - icons.ui.NewFile .. " New temp file", - "lua require 'lib.utils'.new_tmp_file()" - ), - dashboard.button("o", icons.ui.Note .. " Notes", [[lua require "lib.notes".open_note()]]), - - dashboard.button( - "f", - icons.documents.Files .. " Find file", - "lua require 'telescope.builtin'.find_files()" - ), - dashboard.button("r", icons.ui.History .. " Recent files", "lua require 'telescope.builtin'.oldfiles()"), - dashboard.button( - "R", - icons.git.Repo .. " Find project", - "lua require 'lib.utils'.projects()" - ), - dashboard.button("d", icons.ui.Dev .. " Developer", [[lua require "lib.utils".dev_folder()]]), - dashboard.button("L", icons.ui.PluginManager .. " Plugin Manager", "Lazy"), - dashboard.button( - "P", - icons.ui.Plugin .. " Plugins config", - [[lua require "oil".open_float(vim.fn.expand "$NVIMDOTDIR/lua/plugins")]] - ), - dashboard.button("m", icons.ui.List .. " Package Manager", "Mason"), - dashboard.button("g", icons.ui.Git .. " Git", "Git "), - dashboard.button( - "S", - icons.ui.History .. " Sessions", - "lua require 'lib.sessions'.restore_session()" - ), - dashboard.button( - "D", - icons.ui.Lock .. " Dotfiles", - [[lua require "oil".open_float(vim.fn.expand "$DOTFILES")]] - ), - dashboard.button("H", icons.ui.Health .. " Health", "checkhealth"), - dashboard.button("c", icons.documents.Files .. " Close", "Alpha"), - dashboard.button("q", icons.diagnostics.Error .. " Quit", "qa"), - } - - - dashboard.section.footer.val = footer - - dashboard.section.header.opts.hl = "Type" - dashboard.section.buttons.opts.hl = "Keyword" - dashboard.section.footer.opts.hl = "AlphaFooter" - - -- vim.api.nvim_set_hl(0, "AlphaHeader", { fg = "#016a60" }) - -- vim.api.nvim_set_hl(0, "AlphaButtons", { link = "Keyword" }) - -- vim.api.nvim_set_hl(0, "AlphaFooter", { link = "Comment" }) - - dashboard.config.opts.noautocmd = true - - alpha.setup(dashboard.opts) - end -} - -return M \ No newline at end of file diff --git a/lua/plugins/ui/navic.lua b/lua/plugins/ui/navic.lua index 41db2d9..f64ac38 100644 --- a/lua/plugins/ui/navic.lua +++ b/lua/plugins/ui/navic.lua @@ -54,7 +54,6 @@ local M = { end, config = function(_, o) require("nvim-navic").setup(o) - require "knvim.plugins.navic" end } diff --git a/lua/plugins/ui/noice.lua b/lua/plugins/ui/noice.lua index b080898..dd33c3a 100644 --- a/lua/plugins/ui/noice.lua +++ b/lua/plugins/ui/noice.lua @@ -15,7 +15,7 @@ local M = { { "rcarriga/nvim-notify", event = "BufRead", - opts = function(_, o) + config = function(_, o) -- Animation style (see below for details) o.stages = "fade" @@ -45,16 +45,16 @@ local M = { return math.floor(vim.o.columns * 0.75) end + local icons = require "lib.icons" -- Icons for the different levels o.icons = { - ERROR = require "lib.icons".diagnostics.Error, - WARN = require "lib.icons".diagnostics.Warning, - INFO = require "lib.icons".diagnostics.Information, - DEBUG = require "lib.icons".ui.Bug, - TRACE = require "lib.icons".ui.Pencil, + ERROR = icons.diagnostics.Error, + WARN = icons.diagnostics.Warning, + INFO = icons.diagnostics.Information, + DEBUG = icons.ui.Bug, + TRACE = icons.ui.Pencil, } - end, - config = function(_, o) + local notify = require "notify" notify.setup(o) vim.notify = notify @@ -287,8 +287,6 @@ local M = { config = function(_, o) require "noice".setup(o) - require "knvim.plugins.noice" - vim.keymap.set({ "n", "s" }, "", function() if not require("noice.lsp").scroll(4) then return "" @@ -341,6 +339,7 @@ local M = { end, { desc = "Noice Telescope" } ) + end } diff --git a/lua/plugins/ui/whichkey.lua b/lua/plugins/ui/whichkey.lua index eb5fb97..a1f0284 100644 --- a/lua/plugins/ui/whichkey.lua +++ b/lua/plugins/ui/whichkey.lua @@ -39,10 +39,6 @@ local M = { } o.show_help = false end, - config = function(_, o) - require("which-key").setup(o) - require "knvim.plugins.whichkey" - end } return M \ No newline at end of file diff --git a/lua/plugins/utils/coding_helper.lua b/lua/plugins/utils/coding_helper.lua index a1a4d05..2aeaf3a 100644 --- a/lua/plugins/utils/coding_helper.lua +++ b/lua/plugins/utils/coding_helper.lua @@ -6,193 +6,135 @@ ------------------------------------- local M = { - { - "windwp/nvim-autopairs", - event = "InsertEnter", - opts = function(_, o) - o.check_ts = true - o.ts_config = { - lua = { "string", "source" }, - javascript = { "string", "template_string" }, - java = true, - } - o.break_undo = true - o.map_c_w = true - o.map_c_h = true - o.disable_filetype = { "TelescopePrompt", "Alpha", "vim", "text" } - o.fast_wrap = { - map = "", - pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), - highlight = "PmenuSel", - highlight_grey = "LineNr", - } - end, - config = function(_, opts) - local npairs = require "nvim-autopairs" - local cond = require "nvim-autopairs.conds" - local Rule = require "nvim-autopairs.rule" + { + "windwp/nvim-autopairs", + event = "InsertEnter", + opts = function(_, o) + o.check_ts = true + o.ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = true, + } + o.break_undo = true + o.map_c_w = true + o.map_c_h = true + o.disable_filetype = { "TelescopePrompt", "Alpha", "vim", "text" } + o.fast_wrap = { + map = "", + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + highlight = "PmenuSel", + highlight_grey = "LineNr", + } + end, + config = function(_, opts) + local npairs = require "nvim-autopairs" + local cond = require "nvim-autopairs.conds" + local Rule = require "nvim-autopairs.rule" - npairs.setup(opts) + npairs.setup(opts) - npairs.add_rules { - ---@diagnostic disable-next-line: redefined-local - Rule("<", ">"):with_pair(cond.before_regex "%a+"):with_move(function(opts) - return opts.char == ">" - end), - } - end - }, - { - "numToStr/Comment.nvim", - event = { "BufReadPre", "BufNewFile" }, - keys = { - { "gc", mode = { "n", "v" } }, - { "gb", mode = { "n", "v" } }, - { - "/", - function() - require("Comment.api").toggle.linewise.current(vim.fn.visualmode()) - end, - desc = "Comment selection", - mode = "v", - }, - }, - opts = function(_, o) - o.ignore = "^$" - - o.pre_hook = function(ctx) - require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook() - local javascript_filetypes = { - typescriptreact = true, - javascriptreact = true, - javascript = true, - typescript = true, - } + npairs.add_rules { + ---@diagnostic disable-next-line: redefined-local + Rule("<", ">"):with_pair(cond.before_regex "%a+"):with_move(function(opts) + return opts.char == ">" + end), + } + end + }, + { + "numToStr/Comment.nvim", + event = { "BufReadPre", "BufNewFile" }, + -- keys = { + -- { "gc", mode = { "n", "v" } }, + -- { "gb", mode = { "n", "v" } }, + -- }, + opts = function(_, o) + o.ignore = "^$" - if javascript_filetypes[vim.bo.filetype] then - local U = require "Comment.utils" + o.pre_hook = function(ctx) + require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook() + local javascript_filetypes = { + typescriptreact = true, + javascriptreact = true, + javascript = true, + typescript = true, + } - -- Determine whether to use linewise or blockwise commentstring - local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" + if javascript_filetypes[vim.bo.filetype] then + local U = require "Comment.utils" - -- Determine the location where to calculate commentstring from - local location = nil - if ctx.ctype == U.ctype.blockwise then - location = require("ts_context_commentstring.utils").get_cursor_location() - elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then - location = require("ts_context_commentstring.utils") - .get_visual_start_location() - end + -- Determine whether to use linewise or blockwise commentstring + local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" - return require("ts_context_commentstring.internal").calculate_commentstring { - key = type, - location = location, - } - end - end - end - }, - { - "ur4ltz/surround.nvim", - event = "BufRead", - opts = function(_, o) - o.load_keymaps = true - o.pairs = { - nestable = { { "(", ")" }, { "[", "]" }, { "{", "}" }, { "<", ">" } }, - linear = { { "'", "'" }, { "`", "`" }, { '"', '"' }, { "*", "*" } }, - } - end, - config = function(_, o) - local surround = require("surround") - surround.setup(o) + -- Determine the location where to calculate commentstring from + local location = nil + if ctx.ctype == U.ctype.blockwise then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require("ts_context_commentstring.utils") + .get_visual_start_location() + end - -- Normal & Visual Keymaps - vim.keymap.set({ "v", "n" }, - "s.", - function() - surround.repeat_last() - end, - { desc = "Repeat" } - ) - vim.keymap.set({ "v", "n" }, - "sa", - function() - surround.surround_add(true) - end, - { desc = "Add" } - ) - vim.keymap.set({ "v", "n" }, - "sd", - function() - surround.surround_delete() - end, - { desc = "Delete" } - ) - vim.keymap.set({ "v", "n" }, - "sr", - function() - surround.surround_replace() - end, - { desc = "Replace", } - ) - vim.keymap.set({ "v", "n" }, - "sq", - function() - surround.toggle_quotes() - end, - { desc = "Quotes" } - ) - vim.keymap.set({ "v", "n" }, - "sb", - function() - surround.toggle_brackets() - end, - { desc = "Brackets" }) + return require("ts_context_commentstring.internal").calculate_commentstring { + key = type, + location = location, + } + end end - }, - { - "folke/todo-comments.nvim", - cmd = { "TodoTelescope", "TodoLocList", "TodoQuickFix" }, - event = "BufRead", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = function(_, o) - local icons = require "lib.icons" + end + }, + { + 'echasnovski/mini.surround', + version = '*', -- stable version + event = { "BufRead", "BufNewFile" }, + config = function(_, o) + require('mini.surround').setup(o) + end + }, + { + "folke/todo-comments.nvim", + cmd = { "TodoTelescope", "TodoLocList", "TodoQuickFix" }, + event = "BufRead", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = function(_, o) + local icons = require "lib.icons" - local error_red = "#F44747" - local warning_orange = "#ff8800" - local info_yellow = "#FFCC66" - local hint_blue = "#4FC1FF" - local perf_purple = "#7C3AED" - o.keywords = { - FIX = { - icon = icons.ui.Bug, -- icon used for the sign, and in search results - color = error_red, -- can be a hex color, or a named color (see below) - alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords - -- signs = false, -- configure signs for some keywords individually - }, - TODO = { icon = icons.ui.Check, color = hint_blue, alt = { "TIP" } }, - HACK = { icon = icons.ui.Fire, color = warning_orange }, - WARN = { icon = icons.diagnostics.Warning, color = warning_orange, alt = { "WARNING", "XXX" } }, - PERF = { icon = icons.ui.Dashboard, color = perf_purple, alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, - NOTE = { icon = icons.ui.Note, color = info_yellow, alt = { "INFO" } }, - } - end, - config = function(_, o) - local todo_comments = require "todo-comments" - todo_comments.setup(o) + local error_red = "#F44747" + local warning_orange = "#ff8800" + local info_yellow = "#FFCC66" + local hint_blue = "#4FC1FF" + local perf_purple = "#7C3AED" + o.keywords = { + FIX = { + icon = icons.ui.Bug, -- icon used for the sign, and in search results + color = error_red, -- can be a hex color, or a named color (see below) + alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords + -- signs = false, -- configure signs for some keywords individually + }, + TODO = { icon = icons.ui.Check, color = hint_blue, alt = { "TIP" } }, + HACK = { icon = icons.ui.Fire, color = warning_orange }, + WARN = { icon = icons.diagnostics.Warning, color = warning_orange, alt = { "WARNING", "XXX" } }, + PERF = { icon = icons.ui.Dashboard, color = perf_purple, alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, + NOTE = { icon = icons.ui.Note, color = info_yellow, alt = { "INFO" } }, + } + end, + config = function(_, o) + local todo_comments = require "todo-comments" + todo_comments.setup(o) - vim.keymap.set("n", "]t", function() todo_comments.jump_next() end, - { desc = "Next todo comment" }) - vim.keymap.set("n", "[t", function() todo_comments.jump_prev() end, - { desc = "Prev todo comment" }) - vim.keymap.set("n", "ftt", function() vim.cmd.TodoTelescope() end, - { desc = "ToDo Telescope" }) - vim.keymap.set("n", "ftq", function() vim.cmd.TodoQuickFix() end, - { desc = "ToDo QuickFix" }) - vim.keymap.set("n", "ftl", function() vim.cmd.TodoLocList() end, - { desc = "ToDo LocList" }) - end - } + vim.keymap.set("n", "]t", function() todo_comments.jump_next() end, + { desc = "Next todo comment" }) + vim.keymap.set("n", "[t", function() todo_comments.jump_prev() end, + { desc = "Prev todo comment" }) + vim.keymap.set("n", "ftt", function() vim.cmd.TodoTelescope() end, + { desc = "ToDo Telescope" }) + vim.keymap.set("n", "ftq", function() vim.cmd.TodoQuickFix() end, + { desc = "ToDo QuickFix" }) + vim.keymap.set("n", "ftl", function() vim.cmd.TodoLocList() end, + { desc = "ToDo LocList" }) + end + } } return M \ No newline at end of file diff --git a/lua/plugins/utils/gitsigns.lua b/lua/plugins/utils/gitsigns.lua index 8aa2868..e52bb62 100644 --- a/lua/plugins/utils/gitsigns.lua +++ b/lua/plugins/utils/gitsigns.lua @@ -52,8 +52,6 @@ local M = { vim.keymap.set("n", "gL", function() require "gitsigns".toggle_linehl() end, { desc = "Toggle Linehl" }) vim.keymap.set("n", "gW", function() require "gitsigns".toggle_word_diff() end, { desc = "Toggle Word diff" }) vim.keymap.set("n", "gN", function() require "gitsigns".toggle_numhl() end, { desc = "Toggle Numhl" }) - - require "knvim.plugins.gitsigns" end } return M \ No newline at end of file diff --git a/lua/plugins/utils/ufo.lua b/lua/plugins/utils/ufo.lua index 12a4c0e..ddd37fe 100644 --- a/lua/plugins/utils/ufo.lua +++ b/lua/plugins/utils/ufo.lua @@ -53,7 +53,6 @@ local M = { vim.keymap.set("n", "zR", function() ufo.openAllFolds() end, { desc = "Open All Folds" }) vim.keymap.set("n", "zm", function() ufo.closeFoldsWith() end, { desc = "Folds more" }) vim.keymap.set("n", "zM", function() ufo.closeAllFolds() end, { desc = "Close All Folds" }) - require "knvim.plugins.ufo" end }