aboutsummaryrefslogtreecommitdiff
path: root/config/nvim/lua
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2024-02-25 22:49:55 +0100
committerKarel Kočí <cynerd@email.cz>2024-02-25 23:30:57 +0100
commit1970054228b3a9a3a8fc99af723ee13c147e7747 (patch)
tree2f151b709a06980ecb3c3b96930a6d518a1e15ed /config/nvim/lua
parentfe804beeb41d149cc3e3c714061484e651ba48db (diff)
downloadmyconfigs-1970054228b3a9a3a8fc99af723ee13c147e7747.tar.gz
myconfigs-1970054228b3a9a3a8fc99af723ee13c147e7747.tar.bz2
myconfigs-1970054228b3a9a3a8fc99af723ee13c147e7747.zip
Migrate from vim to nvim
Diffstat (limited to 'config/nvim/lua')
-rw-r--r--config/nvim/lua/mytelescope.lua205
-rw-r--r--config/nvim/lua/plugins.lua97
2 files changed, 302 insertions, 0 deletions
diff --git a/config/nvim/lua/mytelescope.lua b/config/nvim/lua/mytelescope.lua
new file mode 100644
index 0000000..c4fe3a7
--- /dev/null
+++ b/config/nvim/lua/mytelescope.lua
@@ -0,0 +1,205 @@
+local layout = require("nui.layout")
+local popup = require("nui.popup")
+
+local actions = require("telescope.actions")
+
+local tslayout = require("telescope.pickers.layout")
+
+return require("telescope").setup({
+ defaults = {
+ mappings = {
+ i = {
+ ["<esc>"] = actions.close,
+ ["<c-j>"] = actions.move_selection_next,
+ ["<c-k>"] = actions.move_selection_previous,
+ ["<c-u>"] = false,
+ },
+ },
+
+ create_layout = function(picker)
+ local border = {
+ results = {
+ top_left = "┌",
+ top = "─",
+ top_right = "┬",
+ right = "│",
+ bottom_right = "",
+ bottom = "",
+ bottom_left = "",
+ left = "│",
+ },
+ results_patch = {
+ minimal = {
+ top_left = "┌",
+ top_right = "┐",
+ },
+ horizontal = {
+ top_left = "┌",
+ top_right = "┬",
+ },
+ vertical = {
+ top_left = "├",
+ top_right = "┤",
+ },
+ },
+ prompt = {
+ top_left = "├",
+ top = "─",
+ top_right = "┤",
+ right = "│",
+ bottom_right = "┘",
+ bottom = "─",
+ bottom_left = "└",
+ left = "│",
+ },
+ prompt_patch = {
+ minimal = {
+ bottom_right = "┘",
+ },
+ horizontal = {
+ bottom_right = "┴",
+ },
+ vertical = {
+ bottom_right = "┘",
+ },
+ },
+ preview = {
+ top_left = "┌",
+ top = "─",
+ top_right = "┐",
+ right = "│",
+ bottom_right = "┘",
+ bottom = "─",
+ bottom_left = "└",
+ left = "│",
+ },
+ preview_patch = {
+ minimal = {},
+ horizontal = {
+ bottom = "─",
+ bottom_left = "",
+ bottom_right = "┘",
+ left = "",
+ top_left = "",
+ },
+ vertical = {
+ bottom = "",
+ bottom_left = "",
+ bottom_right = "",
+ left = "│",
+ top_left = "┌",
+ },
+ },
+ }
+
+ local results = popup({
+ focusable = false,
+ border = {
+ style = border.results,
+ text = {
+ top = picker.results_title,
+ top_align = "center",
+ },
+ },
+ win_options = {
+ winhighlight = "Normal:Normal",
+ },
+ })
+
+ local prompt = popup({
+ enter = true,
+ border = {
+ style = border.prompt,
+ text = {
+ top = picker.prompt_title,
+ top_align = "center",
+ },
+ },
+ win_options = {
+ winhighlight = "Normal:Normal",
+ },
+ })
+
+ local preview = popup({
+ focusable = false,
+ border = {
+ style = border.preview,
+ text = {
+ top = picker.preview_title,
+ top_align = "center",
+ },
+ },
+ })
+
+ local box_by_kind = {
+ vertical = layout.Box({
+ layout.Box(preview, { grow = 1 }),
+ layout.Box(results, { grow = 1 }),
+ layout.Box(prompt, { size = 3 }),
+ }, { dir = "col" }),
+ horizontal = layout.Box({
+ layout.Box({
+ layout.Box(results, { grow = 1 }),
+ layout.Box(prompt, { size = 3 }),
+ }, { dir = "col", size = "50%" }),
+ layout.Box(preview, { size = "50%" }),
+ }, { dir = "row" }),
+ minimal = layout.Box({
+ layout.Box(results, { grow = 1 }),
+ layout.Box(prompt, { size = 3 }),
+ }, { dir = "col" }),
+ }
+
+ local function get_box()
+ local height, width = vim.o.lines, vim.o.columns
+ local box_kind = "horizontal"
+ if width < 100 then
+ box_kind = "vertical"
+ if height < 40 then
+ box_kind = "minimal"
+ end
+ elseif width < 120 then
+ box_kind = "minimal"
+ end
+ return box_by_kind[box_kind], box_kind
+ end
+
+ local function prepare_layout_parts(layout, box_type)
+ layout.results = tslayout.Window(results)
+ results.border:set_style(border.results_patch[box_type])
+
+ layout.prompt = tslayout.Window(prompt)
+ prompt.border:set_style(border.prompt_patch[box_type])
+
+ if box_type == "minimal" then
+ layout.preview = nil
+ else
+ layout.preview = tslayout.Window(preview)
+ preview.border:set_style(border.preview_patch[box_type])
+ end
+ end
+
+ local box, box_kind = get_box()
+ local layout = layout({
+ relative = "editor",
+ position = "50%",
+ size = {
+ height = "60%",
+ width = "90%",
+ },
+ }, box)
+
+ layout.picker = picker
+ prepare_layout_parts(layout, box_kind)
+
+ local layout_update = layout.update
+ function layout:update()
+ local box, box_kind = get_box()
+ prepare_layout_parts(layout, box_kind)
+ layout_update(self, box)
+ end
+
+ return tslayout(layout)
+ end,
+ },
+})
diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua
new file mode 100644
index 0000000..b60f913
--- /dev/null
+++ b/config/nvim/lua/plugins.lua
@@ -0,0 +1,97 @@
+local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
+if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
+ vim.fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
+ vim.cmd([[packadd packer.nvim]])
+end
+
+require("packer").startup(function(use)
+ use("wbthomason/packer.nvim")
+ -- Visual
+ use("shaunsingh/nord.nvim")
+ use("MunifTanjim/nui.nvim")
+ use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" })
+ use("lukas-reineke/indent-blankline.nvim")
+ use("itchyny/lightline.vim")
+ -- Files navigation
+ use("nvim-lua/plenary.nvim")
+ use("nvim-telescope/telescope.nvim")
+ -- Git
+ use("tpope/vim-fugitive")
+ use("airblade/vim-gitgutter")
+ use({
+ "harrisoncramer/gitlab.nvim",
+ requires = {
+ "MunifTanjim/nui.nvim",
+ "nvim-lua/plenary.nvim",
+ "sindrets/diffview.nvim",
+ "stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
+ "nvim-tree/nvim-web-devicons", -- Recommended but not required. Icons in discussion tree.
+ },
+ run = function()
+ require("gitlab.server").build(true)
+ end,
+ })
+ -- Programming
+ use("neovim/nvim-lspconfig")
+ use("p00f/clangd_extensions.nvim")
+ use("w0rp/ale")
+ use("maximbaz/lightline-ale")
+ use("SirVer/ultisnips")
+ use("honza/vim-snippets")
+ use("craigemery/vim-autotag")
+ use("scrooloose/nerdcommenter")
+ -- Movement, format and others
+ use("tpope/vim-surround")
+ use("tpope/vim-repeat")
+ use("dhruvasagar/vim-table-mode")
+
+-- Indent blanklike character specificaiton
+local highlight = { "CursorColumn", "Whitespace" }
+require("ibl").setup({
+ indent = { highlight = highlight, char = "" },
+ whitespace = {
+ highlight = highlight,
+ remove_blankline_trail = false,
+ },
+ scope = { enabled = false },
+})
+-- Treesitter
+require("nvim-treesitter.configs").setup({
+ ensure_installed = {
+ "c",
+ "lua",
+ "kconfig",
+ "make",
+ "markdown",
+ "meson",
+ "ninja",
+ "ini",
+ "gitcommit",
+ "git_rebase",
+ "git_config",
+ "nix",
+ "python",
+ "toml",
+ "vim",
+ "vimdoc",
+ "yaml",
+ },
+ highlight = {
+ enable = true,
+ additional_vim_regex_highlighting = false,
+ },
+})
+
+-- LSP
+local lspconfig = require("lspconfig")
+lspconfig.clangd.setup({})
+lspconfig.rnix.setup({})
+lspconfig.pylsp.setup({})
+lspconfig.bashls.setup({})
+
+-- Telescope
+require('mytelescope')
+
+-- Gitlab
+require("diffview").setup()
+require("gitlab").setup()