From c7c24cd03bb55db975909083c03e13d4de95ee94 Mon Sep 17 00:00:00 2001 From: davidpkj Date: Wed, 15 Mar 2023 14:13:27 +0100 Subject: Changed up nvim --- neovim/.config/nvim/lua/keybinds.lua | 67 +++++++++++++++++++++----- neovim/.config/nvim/lua/plugins.lua | 8 ++- neovim/.config/nvim/lua/plugins/telescope.lua | 27 +---------- neovim/.config/nvim/lua/plugins/treesitter.lua | 2 +- neovim/.config/nvim/lua/settings.lua | 1 + 5 files changed, 66 insertions(+), 39 deletions(-) diff --git a/neovim/.config/nvim/lua/keybinds.lua b/neovim/.config/nvim/lua/keybinds.lua index d113573..1a56ccc 100644 --- a/neovim/.config/nvim/lua/keybinds.lua +++ b/neovim/.config/nvim/lua/keybinds.lua @@ -5,23 +5,36 @@ end -- Fix * (Keep the cursor position, don't move to next match) map("n", "*", "*N") --- Fix n and N. Keeping cursor in center -map("n", "n", "nzz") -map("n", "N", "Nzz") - -- Move line up and down in NORMAL and VISUAL modes map("n", "", "move .+1") map("n", "", "move .-2") map("x", "", ":move '>+1gv=gv") map("x", "", ":move '<-2gv=gv") +-- Keep cursor position +map("n", "J", "mzJ`z") + +-- Keep cursur in center +map("n", "", "zz") +map("n", "", "zz") +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") + +-- Remove to void (and paste) +map("n", "d", "\"_d") +map("v", "d", "\"_d") +map("x", "p", "\"_dP") + +-- Format +map("n", "i", function() vim.lsp.buf.format() end) +-- Edit word +map("n", "s", [[:%s/\<\>//gI]]) +-- Make executable +map("n", "x", "!chmod +x %") + -- map("n", "", ":Files") map("n", "", ":!compile %") --- Mimic shell movements --- map("i", "", "A") --- map("i", "", "I") - -- Move to the next/previous buffer -- map("n", "[", "bp") -- map("n", "]", "bn") @@ -29,12 +42,42 @@ map("n", "", ":!compile %") -- Move to last buffer -- map("n", """", "b#") --- Plugin -map("n", "", "TodoTelescope") +-- Telescope binds +local Telescope = setmetatable({}, { + __index = function(_, k) + if vim.bo.filetype == "NvimTree" then + vim.cmd.wincmd("l") + end + return require("telescope.builtin")[k] + end, +}) + +-- Help +map("n", "fh", Telescope.help_tags) +-- Files with match +map("n", "ff", Telescope.live_grep) +-- Project files +map("n", "fp", Telescope.find_files) +-- Changed git files +map("n", "fc", Telescope.git_status) +-- Git files +map("n", "fg", function() + local ok = pcall(Telescope.git_files, { show_untracked = true }) + if not ok then + Telescope.find_files() + end +end) + +-- Highlighted comments +map("n", "ft", "TodoTelescope") -- Hacky update thing --- TODO: Fix timing -map("n", "u", "PackerSyncPackerCompileTSUpdateMason") +--[[ map("n", "u", function() + local ok = pcall(vim.cmd.PackerSync) + if ok then ok = pcall(vim.cmd.PackerCompile) end + if ok then ok = pcall(vim.cmd.TSUpdate) end + if ok then pcall(vim.cmd.Mason) end +end) ]] exp = {} exp.map = map diff --git a/neovim/.config/nvim/lua/plugins.lua b/neovim/.config/nvim/lua/plugins.lua index d5de0b0..bcd87cc 100644 --- a/neovim/.config/nvim/lua/plugins.lua +++ b/neovim/.config/nvim/lua/plugins.lua @@ -9,7 +9,7 @@ return require("packer").startup(function(use) use("wbthomason/packer.nvim") use("nvim-lua/plenary.nvim") - use 'h-hg/fcitx.nvim' + use("h-hg/fcitx.nvim") -- Color theme use({ @@ -119,6 +119,12 @@ return require("packer").startup(function(use) }, }) + use({ + "akinsho/flutter-tools.nvim", + requires = "nvim-lua/plenary.nvim", + config = function() require("flutter-tools").setup({}) end, + }) + -- Completion framework use({ { diff --git a/neovim/.config/nvim/lua/plugins/telescope.lua b/neovim/.config/nvim/lua/plugins/telescope.lua index 6d3be34..2b34bb2 100644 --- a/neovim/.config/nvim/lua/plugins/telescope.lua +++ b/neovim/.config/nvim/lua/plugins/telescope.lua @@ -1,9 +1,8 @@ local actions = require("telescope.actions") -local finders = require("telescope.builtin") require("telescope").setup({ defaults = { - prompt_prefix = "> ", + prompt_prefix = "ยป ", initial_mode = "insert", sorting_strategy = "ascending", layout_config = { @@ -17,6 +16,7 @@ require("telescope").setup({ [""] = actions.toggle_selection + actions.move_selection_next, [""] = actions.send_selected_to_qflist, [""] = actions.send_to_qflist, + [""] = actions.which_key, }, }, }, @@ -29,26 +29,3 @@ require("telescope").setup({ }, }, }) - -local Telescope = setmetatable({}, { - __index = function(_, k) - if vim.bo.filetype == "NvimTree" then - vim.cmd.wincmd("l") - end - return finders[k] - end, -}) - -vim.keymap.set("n", "", function() - local ok = pcall(Telescope.git_files, { show_untracked = true }) - if not ok then - Telescope.find_files() - end -end) - --- Get :help at the speed of light -vim.keymap.set("n", "H", Telescope.help_tags) --- Search for string -vim.keymap.set("n", "s", Telescope.live_grep) --- Fuzzy find changed files in git -vim.keymap.set("n", "c", Telescope.git_status) diff --git a/neovim/.config/nvim/lua/plugins/treesitter.lua b/neovim/.config/nvim/lua/plugins/treesitter.lua index f05cca9..8c9f60c 100644 --- a/neovim/.config/nvim/lua/plugins/treesitter.lua +++ b/neovim/.config/nvim/lua/plugins/treesitter.lua @@ -118,7 +118,7 @@ require("nvim-treesitter.configs").setup({ -- nvim-treesitter/nvim-treesitter-refactor refactor = { highlight_definitions = { enable = true }, - -- highlight_current_scope = { enable = false }, + -- highlight_current_scope = { enable = true }, }, context_commentstring = { enable = true, diff --git a/neovim/.config/nvim/lua/settings.lua b/neovim/.config/nvim/lua/settings.lua index e65dbff..e4c7543 100644 --- a/neovim/.config/nvim/lua/settings.lua +++ b/neovim/.config/nvim/lua/settings.lua @@ -11,6 +11,7 @@ o.relativenumber = true o.numberwidth = 4 o.signcolumn = "yes:1" +-- o.colorcolumn = "80" o.shortmess = o.shortmess .. "c" o.completeopt = "menuone,noselect,noinsert" -- cgit v1.2.3