From 79aee22045e7a9800a98a0ec2be8e3e363f61d32 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sun, 20 Oct 2024 20:18:59 +0200 Subject: [PATCH] More testing --- config/nvim/init.lua | 200 +++++++++++++++++++++++-------------------- 1 file changed, 109 insertions(+), 91 deletions(-) diff --git a/config/nvim/init.lua b/config/nvim/init.lua index f3d77ba..5f908e3 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -208,74 +208,99 @@ require('lazy').setup({ }, -- File explorer ------------------------------------------- + -- { + -- 's1n7ax/nvim-window-picker', + -- version = '2.*', + -- config = function() + -- require 'window-picker'.setup({ + -- filter_rules = { + -- include_current_win = false, + -- autoselect_one = true, + -- -- filter using buffer options + -- bo = { + -- -- if the file type is one of following, the window will be ignored + -- filetype = { 'neo-tree', "neo-tree-popup", "notify" }, + -- -- if the buffer type is one of following, the window will be ignored + -- buftype = { 'terminal', "quickfix" }, + -- }, + -- }, + -- highlights = { + -- statusline = { + -- unfocused = { + -- fg = '#d7af5f', + -- bg = '#262626', + -- bold = true, + -- }, + -- focused = { + -- fg = '#d7af5f', + -- bg = '#262626', + -- bold = true, + -- }, + -- }, + -- }, + -- }) + -- end, + -- }, { - 'nvim-telescope/telescope.nvim', - dependencies = { 'nvim-lua/plenary.nvim' }, - opts = function() - local actions = require "telescope.actions" - return { - defaults = { - path_display = { "truncate" }, - mappings = { - i = { - [""] = actions.cycle_history_next, - [""] = actions.cycle_history_prev, - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = actions.select_default, - [""] = actions.close, - }, - n = { - ["q"] = actions.close, - [""] = actions.close, - }, - }, - }, - } - end, - }, - - { - "nvim-telescope/telescope-file-browser.nvim", - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/plenary.nvim", - }, - }, - - { - 's1n7ax/nvim-window-picker', - version = '2.*', + "ibhagwan/fzf-lua", + -- optional for icon support + dependencies = { "nvim-tree/nvim-web-devicons" }, config = function() - require 'window-picker'.setup({ - filter_rules = { - include_current_win = false, - autoselect_one = true, - -- filter using buffer options - bo = { - -- if the file type is one of following, the window will be ignored - filetype = { 'neo-tree', "neo-tree-popup", "notify" }, - -- if the buffer type is one of following, the window will be ignored - buftype = { 'terminal', "quickfix" }, - }, - }, - highlights = { - statusline = { - unfocused = { - fg = '#d7af5f', - bg = '#262626', - bold = true, - }, - focused = { - fg = '#d7af5f', - bg = '#262626', - bold = true, - }, - }, - }, - }) - end, + -- calling `setup` is optional for customization + require("fzf-lua").setup({}) + end }, + -- { + -- 'nvim-telescope/telescope.nvim', + -- dependencies = { 'nvim-lua/plenary.nvim' }, + -- opts = function() + -- local actions = require "telescope.actions" + -- return { + -- defaults = { + -- previewer = false, + -- path_display = { "truncate" }, + -- mappings = { + -- i = { + -- [""] = actions.cycle_history_next, + -- [""] = actions.cycle_history_prev, + -- [""] = actions.move_selection_next, + -- [""] = actions.move_selection_previous, + -- [""] = actions.select_default, + -- [""] = actions.close, + -- [""] = function(prompt_bufnr) + -- -- Use nvim-window-picker to choose the window by dynamically attaching a function + -- local action_set = require('telescope.actions.set') + -- local action_state = require('telescope.actions.state') + -- + -- local picker = action_state.get_current_picker(prompt_bufnr) + -- picker.get_selection_window = function(picker, entry) + -- local picked_window_id = require('window-picker').pick_window() or + -- vim.api.nvim_get_current_win() + -- -- Unbind after using so next instance of the picker acts normally + -- picker.get_selection_window = nil + -- return picked_window_id + -- end + -- + -- return action_set.edit(prompt_bufnr, 'edit') + -- end, + -- }, + -- n = { + -- ["q"] = actions.close, + -- [""] = actions.close, + -- }, + -- }, + -- }, + -- } + -- end, + -- }, + + -- { + -- "nvim-telescope/telescope-file-browser.nvim", + -- dependencies = { + -- "nvim-telescope/telescope.nvim", + -- "nvim-lua/plenary.nvim", + -- }, + -- }, { "nvim-neo-tree/neo-tree.nvim", @@ -294,13 +319,6 @@ require('lazy').setup({ open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, -- when opening files, do not use windows containing these filetypes or buftypes sort_case_insensitive = false, -- used when sorting files and directories in the tree sort_function = nil, -- use a custom function for sorting files and directories in the tree - -- sort_function = function (a,b) - -- if a.type == b.type then - -- return a.path > b.path - -- else - -- return a.type > b.type - -- end - -- end , -- this sorts files and directories descendantly default_component_configs = { container = { enable_character_fade = true @@ -402,7 +420,7 @@ require('lazy').setup({ require("neo-tree.ui.renderer").focus_node(state, node:get_child_ids()[1]) end else -- if not a directory just open it - state.commands.open_with_window_picker(state) + state.commands.open(state) end end, copy_selector = function(state) @@ -443,7 +461,7 @@ require('lazy').setup({ }, window = { position = "float", - width = 30, + width = 40, mappings = { [""] = false, -- disable space until we figure out which-key disabling h = "parent_or_close", @@ -683,13 +701,13 @@ local on_attach = function(_, bufnr) nmap('gd', vim.lsp.buf.definition, 'Goto Definition') nmap('gD', vim.lsp.buf.declaration, 'Goto Declaration') nmap('gI', vim.lsp.buf.implementation, 'Goto Implementation') - nmap('gr', require('telescope.builtin').lsp_references, 'Goto References') + -- nmap('gr', require('telescope.builtin').lsp_references, 'Goto References') nmap('D', vim.lsp.buf.type_definition, 'Type Definition') nmap('K', vim.lsp.buf.hover, 'Hover Documentation') nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') -- nmap('', vim.lsp.buf.format(), 'Format current buffer') - nmap('ds', require('telescope.builtin').lsp_document_symbols, 'Document Symbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Workspace Symbols') + -- nmap('ds', require('telescope.builtin').lsp_document_symbols, 'Document Symbols') + -- nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Workspace Symbols') -- Create a command `:Format` local to the LSP buffer vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) @@ -816,7 +834,7 @@ require 'lspconfig'.lua_ls.setup { } -- Setup neovim lua configuration -require("telescope").load_extension "file_browser" +-- require("telescope").load_extension "file_browser" -- [[ Configure nvim-cmp ]] local cmp = require 'cmp' @@ -1001,18 +1019,17 @@ vim.keymap.set('n', 'j', require('smart-splits').swap_buf_down, vim.keymap.set('n', 'k', require('smart-splits').swap_buf_up, { desc = 'Swap buffer up' }) vim.keymap.set('n', 'l', require('smart-splits').swap_buf_right, { desc = 'Swap buffer right' }) -- telescope -vim.keymap.set('n', 'fo', require('telescope.builtin').oldfiles, { desc = 'Find recently opened files' }) -vim.keymap.set('n', 'ff', - ":lua require('telescope.builtin').find_files()", - { desc = 'Find files', silent = true }) -vim.keymap.set('n', 'fh', - ":lua require('telescope.builtin').find_files({ hidden = true})", - { desc = 'Find files', silent = true }) -vim.keymap.set('n', 'fb', ":Telescope file_browser", { desc = 'File browser', silent = true }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = 'Search help' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = 'Search current word' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = 'Search by grep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = 'Search diagnostics' }) +-- vim.keymap.set('n', 'fo', require('telescope.builtin').oldfiles, { desc = 'Find recently opened files' }) +-- vim.keymap.set('n', 'ff', +-- ":lua require('telescope.builtin').find_files()", +-- { desc = 'Find files', silent = true }) +-- vim.keymap.set('n', 'fh', +-- ":lua require('telescope.builtin').find_files({ hidden = true})", +-- { desc = 'Find files', silent = true }) +-- vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = 'Search help' }) +-- vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = 'Search current word' }) +-- vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = 'Search by grep' }) +-- vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = 'Search diagnostics' }) --Other vim.keymap.set('n', '', ":tabNext", { desc = 'Next tab', silent = true }) vim.keymap.set('n', '', ":Format", { desc = 'Format code', silent = true }) @@ -1025,4 +1042,5 @@ vim.keymap.set('n', 'n', ":tabnew", { desc = 'Format code', silent = vim.keymap.set('n', 'c', ":tabclose", { desc = 'Format code', silent = true }) vim.keymap.set('n', 'e', ":Neotree filesystem reveal float toggle", { desc = 'File explorer', silent = true }) vim.keymap.set('n', 's', ":HopWord", { desc = 'hop', silent = true }) -vim.keymap.set('n', 't', ":TroubleToggle", { desc = 'Trouble view', silent = true }) +vim.keymap.set('n', 't', ":Trouble diagnostics toggle", { desc = 'Diagnostic view', silent = true }) +vim.keymap.set('n', 'f', ":FzfLua files", { desc = 'Find file', silent = true })