1
Fork 0

feat: telescope file browser

This commit is contained in:
Matei Adriel 2022-02-22 22:52:01 +02:00
parent 577a19cf27
commit 1e499dccba
10 changed files with 169 additions and 72 deletions

View file

@ -1,20 +1,22 @@
local M = {} local M = {}
function M.setup() function M.setup()
-- Other unconfigured plugins
require('nvim-autopairs').setup()
require("startup").setup({theme = "dashboard"})
require('lualine').setup({theme = "github"})
-- Plugins with their own configs:
require("my.plugins.cmp").setup() require("my.plugins.cmp").setup()
require("my.plugins.lspconfig").setup() require("my.plugins.lspconfig").setup()
require("my.plugins.null-ls").setup()
-- require("my.plugins.fzf-lua").setup() -- require("my.plugins.fzf-lua").setup()
require("my.plugins.telescope").setup()
require("my.plugins.treesitter").setup() require("my.plugins.treesitter").setup()
require("my.plugins.comment").setup() require("my.plugins.comment").setup()
-- require("my.plugins.nerdtree").setup() -- require("my.plugins.nerdtree").setup()
require("my.plugins.nvim-tree").setup() require("my.plugins.nvim-tree").setup()
require("my.plugins.vimtex").setup() require("my.plugins.vimtex").setup()
require("my.plugins.telescope").setup()
-- Other unconfigured plugins
require('nvim-autopairs').setup()
require("startup").setup({theme = "dashboard"})
require('lualine').setup({theme = "github"})
end end
return M return M

View file

@ -0,0 +1,7 @@
local M = {}
function M.setup()
-- Setup goes here
end
return M

View file

@ -3,34 +3,59 @@ local mapSilent = require("my.keymaps").mapSilent
local M = {} local M = {}
local bindings = { local bindings = {
-- Open files with control + P builtin = {
find_files = "<c-P>", -- Open files with control + P
find_files = "<c-P>",
-- Search through files with control + F -- Search through files with control + F
live_grep = "<c-F>", live_grep = "<c-F>",
-- See diagnostics with space + d -- See diagnostics with space + d
lsp_document_diagnostics = "<space>d", lsp_document_diagnostics = "<space>d",
lsp_workspace_diagnostics = "<space>wd", lsp_workspace_diagnostics = "<space>wd",
-- Open a list with all the pickers -- Open a list with all the pickers
builtin = "<space>t", builtin = "<space>t",
-- List function, var names etc -- List function, var names etc
treesitter = "<space>s", treesitter = "<space>s",
-- Git stuff -- Git stuff
git_commits = "<space>gj", git_commits = "<space>gj",
git_branches = "<space>gk" git_branches = "<space>gk"
},
["extensions.file_browser.file_browser"] = "<space>p"
} }
function M.setup() local function setupKeybinds(obj, path)
for action, keybind in pairs(bindings) do if path == nil then path = "" end
-- Maps the keybind to the action for name, keybinds in pairs(obj) do
mapSilent('n', keybind, "<cmd>lua require('telescope.builtin')." .. action .. "()<CR>") if (type(keybinds) == "table") then
-- This means we found a table of keybinds, so we go deeper
setupKeybinds(keybinds, path .. "." .. name)
else
-- Maps the keybind to the action
mapSilent('n', keybinds, "<cmd>lua require('telescope" .. path .. "')." .. name .. "()<CR>")
end
end end
end
require("telescope").setup {defaults = {mappings = {i = {["<C-h>"] = "which_key"}}}} function M.setup()
setupKeybinds(bindings)
local settings = {
defaults = {mappings = {i = {["<C-h>"] = "which_key"}}},
extensions = {
file_browser = {
mappings = {
-- Comment so this does not get collapsed
}
}
}
}
require("telescope").setup(settings)
require("telescope").load_extension "file_browser"
end end
return M return M

View file

@ -133,11 +133,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1645244400, "lastModified": 1645479152,
"narHash": "sha256-o7KCd6ySFZ9/LbS62aTeuFmBWtP7Tt3Q3RcNjYgTgZU=", "narHash": "sha256-8au2xAPSi3yGQBaVrYUpMY30lY9tMuNn7UMAHL7NJtw=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "0232fe1b75e6d7864fd82b5c72f6646f87838fc3", "rev": "69536af27e86a9fc875d71cb9566ccccf47b5b60",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -156,11 +156,11 @@
}, },
"locked": { "locked": {
"dir": "contrib", "dir": "contrib",
"lastModified": 1645311555, "lastModified": 1645480882,
"narHash": "sha256-Va2UQFMSBYDuUbYOVKEPQj1PV1RxBHbhv0WTJTHqDvE=", "narHash": "sha256-EHXbr96JiprqxiVQy1NnrCmYB0+HK1EAdWdXQiZ03Cw=",
"owner": "neovim", "owner": "neovim",
"repo": "neovim", "repo": "neovim",
"rev": "8b3799e2c33282bf417ddee15ae71b5aba613c16", "rev": "30c9c8815b531e0130ebeb9358bc6d3947a6128a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -179,11 +179,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1645344796, "lastModified": 1645517666,
"narHash": "sha256-sUaJA5Q6glKRfB2WOcMFi1wOcUQthXRGVego9eetGTk=", "narHash": "sha256-DeQmb7GXKScYKPVXASBlgaARdXO4B9u6um32UPnFIZo=",
"owner": "nix-community", "owner": "nix-community",
"repo": "neovim-nightly-overlay", "repo": "neovim-nightly-overlay",
"rev": "957f8d1c54d81031ea2422b97e2bd9518661f78c", "rev": "f6ce5a9aec32a336cf7045b380a50a42583acd3a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -194,11 +194,11 @@
}, },
"nixos-unstable": { "nixos-unstable": {
"locked": { "locked": {
"lastModified": 1644613700, "lastModified": 1645433236,
"narHash": "sha256-wLRPJclMH8vsHuFtyI78aF09lw5mbi3lMB6uiK5S2wE=", "narHash": "sha256-4va4MvJ076XyPp5h8sm5eMQvCrJ6yZAbBmyw95dGyw4=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "23d785aa6f853e6cf3430119811c334025bbef55", "rev": "7f9b6e2babf232412682c09e57ed666d8f84ac2d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -210,11 +210,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1645355333, "lastModified": 1645488570,
"narHash": "sha256-T6x1HPxTZCS2oXlbeh7YSqivkuDdP3Rfxq7zW7el3UM=", "narHash": "sha256-29Fvczhd20K3ol0wbQrFlsUiYUDoGnpOR2XJTdrRnZA=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "cc244a8ef1a6b116e5254d838fdf28a37c370b48", "rev": "491ad20776074706da6befe0cb8334f2df23fc00",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -226,11 +226,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1645013224, "lastModified": 1645493675,
"narHash": "sha256-b7OEC8vwzJv3rsz9pwnTX2LQDkeOWz2DbKypkVvNHXc=", "narHash": "sha256-9xundbZQbhFodsQRh6QMN1GeSXfo3y/5NL0CZcJULz0=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b66b39216b1fef2d8c33cc7a5c72d8da80b79970", "rev": "74b10859829153d5c5d50f7c77b86763759e8654",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -267,10 +267,27 @@
"nixos-unstable": "nixos-unstable", "nixos-unstable": "nixos-unstable",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"telescope-file-browser-nvim": "telescope-file-browser-nvim",
"vim-extra-plugins": "vim-extra-plugins", "vim-extra-plugins": "vim-extra-plugins",
"z": "z" "z": "z"
} }
}, },
"telescope-file-browser-nvim": {
"flake": false,
"locked": {
"lastModified": 1645182018,
"narHash": "sha256-MFKjdmO0KnZWodUeaXrJExM+j6kplDl9HzHwNfJabOc=",
"owner": "nvim-telescope",
"repo": "telescope-file-browser.nvim",
"rev": "d06fe1d4ade68ba17739025e55e941f9e977d37c",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope-file-browser.nvim",
"type": "github"
}
},
"vim-extra-plugins": { "vim-extra-plugins": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_2",
@ -278,11 +295,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1645107880, "lastModified": 1645366942,
"narHash": "sha256-KuZkokcjhK1PRvIiU2aWszozx3fPOJ3shR7rlUaVraQ=", "narHash": "sha256-2jIT/nz+gelrLI6TcPlT5Awm0Hr/HsozMvOn6lMzp1o=",
"owner": "m15a", "owner": "m15a",
"repo": "nixpkgs-vim-extra-plugins", "repo": "nixpkgs-vim-extra-plugins",
"rev": "4dfa3d3ec4a1b74958e7e62c0ebff918fb084a39", "rev": "6a77da622616f01e9b4a4504fa4ce86acc42ac4b",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -9,25 +9,41 @@
home-manager.url = "github:nix-community/home-manager"; home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs";
easy-dhall-nix.url = "github:justinwoo/easy-dhall-nix";
easy-dhall-nix.flake = false;
easy-purescript-nix.url = "github:justinwoo/easy-purescript-nix";
easy-purescript-nix.flake = false;
z.url = "github:jethrokuan/z";
z.flake = false;
agnoster.url = "github:oh-my-fish/theme-agnoster";
agnoster.flake = false;
githubNvimTheme.url = "github:projekt0n/github-nvim-theme";
githubNvimTheme.flake = false;
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
neovim-nightly-overlay.inputs.nixpkgs.follows = "nixpkgs"; neovim-nightly-overlay.inputs.nixpkgs.follows = "nixpkgs";
vim-extra-plugins.url = "github:m15a/nixpkgs-vim-extra-plugins"; vim-extra-plugins.url = "github:m15a/nixpkgs-vim-extra-plugins";
# Git repo fetching
telescope-file-browser-nvim = {
url = "github:nvim-telescope/telescope-file-browser.nvim";
flake = false;
};
easy-dhall-nix = {
url = "github:justinwoo/easy-dhall-nix";
flake = false;
};
easy-purescript-nix = {
url = "github:justinwoo/easy-purescript-nix";
flake = false;
};
z = {
url = "github:jethrokuan/z";
flake = false;
};
agnoster = {
url = "github:oh-my-fish/theme-agnoster";
flake = false;
};
githubNvimTheme = {
url = "github:projekt0n/github-nvim-theme";
flake = false;
};
}; };
outputs = inputs@{ self, nixpkgs, home-manager, ... }: outputs = inputs@{ self, nixpkgs, home-manager, ... }:
@ -44,8 +60,8 @@
provideInputs provideInputs
]; ];
}; };
in { in
{
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
inherit system; inherit system;

View file

@ -37,7 +37,7 @@ in
]; ];
plugins = with pkgs.vimPlugins; plugins = with pkgs.vimPlugins;
with pkgs.vimExtraPlugins; [ with pkgs.vimExtraPlugins; with pkgs.myVimPlugins; [
config-nvim # my neovim config config-nvim # my neovim config
github-nvim-theme # github theme for neovim github-nvim-theme # github theme for neovim
nvim-lspconfig # configures lsps for me nvim-lspconfig # configures lsps for me
@ -53,7 +53,8 @@ in
lualine-nvim # customizable status line lualine-nvim # customizable status line
nvim-tree-lua # file tree nvim-tree-lua # file tree
vimtex # latex plugin vimtex # latex plugin
null-ls-nvim # generic language server
telescope-file-browser-nvim # file creation/deletion using telescope
# Cmp related stuff. See https://github.com/hrsh7th/nvim-cmp # Cmp related stuff. See https://github.com/hrsh7th/nvim-cmp
cmp-nvim-lsp cmp-nvim-lsp

View file

@ -1,5 +1,5 @@
{ {
ls = "exa -l"; ls = "exa -la";
sl = "sl -e"; sl = "sl -e";
# WIfi stuff # WIfi stuff

View file

@ -2,7 +2,14 @@
with import ../../../secrets.nix; with import ../../../secrets.nix;
let let
variables = { variables = {
# Configure github cli
GITHUB_USERNAME = "Mateiadrielrafael"; GITHUB_USERNAME = "Mateiadrielrafael";
inherit GITHUB_TOKEN; inherit GITHUB_TOKEN;
# Sets neovim as default editor
EDITOR = "nvim";
}; };
in { home-manager.users.adrielus = { home.sessionVariables = variables; }; } in
{
home-manager.users.adrielus = { home.sessionVariables = variables; };
}

View file

@ -1,7 +1,24 @@
{ system }: { system }:
{ home-manager, nixpkgs, nixpkgs-unstable, nixos-unstable, easy-purescript-nix { home-manager
, easy-dhall-nix, z, agnoster, githubNvimTheme, vim-extra-plugins, ... }: , nixpkgs
(self: super: { , nixpkgs-unstable
, nixos-unstable
, easy-purescript-nix
, easy-dhall-nix
, z
, agnoster
, githubNvimTheme
, vim-extra-plugins
, telescope-file-browser-nvim
, ...
}: self: super:
# installs a vim plugin from git with a given tag / branch
let plugin = name: src: self.vimUtils.buildVimPluginFrom2Nix {
inherit name;
inherit src;
};
in
{
unstable = import nixpkgs-unstable { unstable = import nixpkgs-unstable {
inherit system; inherit system;
config.allowUnfree = true; config.allowUnfree = true;
@ -22,4 +39,10 @@
}; };
githubNvimTheme = githubNvimTheme; githubNvimTheme = githubNvimTheme;
})
# Vim plugins
myVimPlugins = {
telescope-file-browser-nvim =
plugin "file_browser" telescope-file-browser-nvim;
};
}

View file

@ -1 +0,0 @@
const a = 3