diff options
author | admin <contact@optics-design.com> | 2025-05-11 00:43:32 +0200 |
---|---|---|
committer | admin <contact@optics-design.com> | 2025-05-11 00:43:32 +0200 |
commit | 102f9a5608cbb7b5553cd0d1862b6bd8e40c8075 (patch) | |
tree | f6ae6dbbf3c9b60e34bb0e24dca20008c704f721 /nvim/lua/configs.lua | |
parent | 681468ea7f56624ca869e7ba859f4457a8412cc3 (diff) |
refractored neovim config
Diffstat (limited to 'nvim/lua/configs.lua')
-rw-r--r-- | nvim/lua/configs.lua | 285 |
1 files changed, 285 insertions, 0 deletions
diff --git a/nvim/lua/configs.lua b/nvim/lua/configs.lua new file mode 100644 index 0000000..92d26f7 --- /dev/null +++ b/nvim/lua/configs.lua @@ -0,0 +1,285 @@ +-- Plugin configurations
+-- All plugin-specific settings are configured here
+
+--------------------------------
+-- TELESCOPE
+--------------------------------
+local function setup_telescope()
+ local actions = require("telescope.actions")
+
+ -- Function to open selected file in external program
+ local function open_in_external_program(prompt_bufnr)
+ local entry = require('telescope.actions.state').get_selected_entry()
+ local file_path = entry.path or entry.filename
+ if file_path then
+ os.execute(string.format('start "" "%s"', file_path))
+ else
+ print("No file selected")
+ end
+ actions.close(prompt_bufnr)
+ end
+
+ require('telescope').setup({
+ defaults = {
+ layout_config = {
+ vertical = { width = 0.5 }
+ },
+ mappings = {
+ n = {
+ ["q"] = actions.close,
+ ["o"] = open_in_external_program,
+ },
+ i = {
+ ["<C-c>"] = actions.close,
+ ["<C-n>"] = actions.cycle_history_next,
+ ["<C-p>"] = actions.cycle_history_prev,
+ ["<C-j>"] = actions.move_selection_next,
+ ["<C-k>"] = actions.move_selection_previous,
+ ["<C-o>"] = open_in_external_program,
+ }
+ },
+ },
+ pickers = {
+ live_grep = {
+ file_ignore_patterns = { 'node_modules', '.git', '.venv' },
+ additional_args = function(_)
+ return { "--hidden" }
+ end
+ },
+ find_files = {
+ file_ignore_patterns = { 'node_modules', '.git', '.venv' },
+ hidden = true
+ }
+ }
+ })
+end
+
+--------------------------------
+-- HARPOON
+--------------------------------
+local function setup_harpoon()
+ local harpoon = require("harpoon")
+
+ -- Initialize harpoon
+ harpoon:setup({
+ settings = {
+ save_on_toggle = true,
+ sync_on_ui_close = true,
+ }
+ })
+end
+
+--------------------------------
+-- OIL
+--------------------------------
+local function setup_oil()
+ require("oil").setup({
+ -- Default file explorer settings
+ default_file_explorer = true,
+
+ -- Columns to display
+ columns = { "icon" },
+
+ -- Buffer options
+ buf_options = {
+ buflisted = false,
+ bufhidden = "hide",
+ },
+
+ -- Window options
+ win_options = {
+ wrap = false,
+ signcolumn = "no",
+ cursorcolumn = false,
+ foldcolumn = "0",
+ spell = false,
+ list = false,
+ conceallevel = 3,
+ concealcursor = "nvic",
+ },
+
+ -- File operations
+ delete_to_trash = true,
+ skip_confirm_for_simple_edits = false,
+ prompt_save_on_select_new_entry = true,
+ cleanup_delay_ms = 2000,
+
+ -- UI behavior
+ constrain_cursor = "editable",
+ watch_for_changes = false,
+
+ -- Custom keymaps
+ keymaps = {
+ ["g?"] = "actions.show_help",
+ ["<CR>"] = "actions.select",
+ ["<C-S>"] = { "actions.select", opts = { vertical = true } },
+ ["<C-H>"] = { "actions.select", opts = { horizontal = true } },
+ ["<C-p>"] = "actions.preview",
+ ["<C-c>"] = "actions.close",
+ ["<C-l>"] = "actions.refresh",
+ ["-"] = "actions.parent",
+ ["_"] = "actions.open_cwd",
+ ["`"] = "actions.cd",
+ ["~"] = { "actions.cd", opts = { scope = "tab" } },
+ ["gs"] = "actions.change_sort",
+ ["<C-o>"] = "actions.open_external",
+ ["g."] = "actions.toggle_hidden",
+ ["g\\"] = "actions.toggle_trash",
+ ['yp'] = {
+ desc = 'Copy filepath to system clipboard',
+ callback = function ()
+ require('oil.actions').copy_entry_path.callback()
+ vim.fn.setreg("+", vim.fn.getreg(vim.v.register))
+ end,
+ },
+ },
+
+ -- Disable default keymaps
+ use_default_keymaps = false,
+
+ -- View options
+ view_options = {
+ show_hidden = false,
+ natural_order = true,
+ case_insensitive = false,
+ sort = {
+ { "type", "asc" },
+ { "name", "asc" },
+ },
+ },
+
+ -- Preview window settings
+ preview = {
+ max_width = 0.9,
+ min_width = { 40, 0.4 },
+ max_height = 0.9,
+ min_height = { 5, 0.1 },
+ border = "rounded",
+ win_options = { winblend = 0 },
+ },
+
+ -- Floating window settings
+ float = {
+ padding = 2,
+ max_width = 0,
+ max_height = 0,
+ border = "rounded",
+ win_options = { winblend = 0 },
+ },
+ })
+end
+
+--------------------------------
+-- TOGGLETERM
+--------------------------------
+local function setup_toggleterm()
+ require("toggleterm").setup({
+ -- Shell to use in the terminal
+ shell = "pwsh.exe -NoLogo",
+
+ -- Display options
+ direction = "float",
+ float_opts = {
+ border = "rounded",
+ },
+
+ -- Window appearance
+ winbar = {
+ enabled = false
+ },
+
+ -- Behavior
+ start_in_insert = true,
+ close_on_exit = true,
+
+ -- Integration with tmux
+ persist_size = true,
+ persist_mode = true,
+ })
+end
+
+--------------------------------
+-- TREESITTER
+--------------------------------
+local function setup_treesitter()
+ require('nvim-treesitter.configs').setup({
+ ensure_installed = { "c", "lua", "vim", "vimdoc", "cpp", "python" },
+ sync_install = false,
+ auto_install = false,
+ highlight = { enable = true },
+ indent = { enable = true },
+ })
+end
+
+--------------------------------
+-- COMMENTS
+--------------------------------
+local function setup_comments()
+ require('Comment').setup({
+ padding = true,
+ sticky = true,
+ ignore = nil,
+ toggler = {
+ line = '<leader>/',
+ block = 'gbc',
+ },
+ opleader = {
+ line = '<leader>/',
+ block = 'gb',
+ }
+ })
+end
+
+--------------------------------
+-- LSP Configuration
+--------------------------------
+local function setup_lsp()
+ -- Configure Mason LSP installer/manager
+ require('mason').setup({
+ ensure_installed = {
+ 'lua_ls', -- Lua
+ 'clangd', -- C/C++
+ 'pyright', -- Python
+ 'marksman', -- Markdown
+ },
+ handlers = {
+ -- Lua LSP settings
+ lua_ls = function()
+ require('lspconfig').lua_ls.setup({})
+ end,
+
+ -- C/C++ LSP settings (clangd)
+ clangd = function()
+ require('lspconfig').clangd.setup({})
+ end,
+
+ -- Markdown LSP settings
+ marksman = function()
+ require('lspconfig').marksman.setup({})
+ end,
+ }
+ })
+ require("mason-lspconfig").setup {}
+
+ -- Configure diagnostics appearance
+ vim.diagnostic.config({
+ virtual_lines=true,
+ signs = true,
+ underline = true,
+ update_in_insert = false,
+ severity_sort = true,
+ })
+end
+
+--------------------------------
+-- INITIALIZE ALL CONFIGS
+--------------------------------
+
+-- Set up all plugin configurations
+setup_telescope()
+setup_harpoon()
+setup_oil()
+setup_toggleterm()
+setup_treesitter()
+setup_comments()
+setup_lsp()
|