aboutsummaryrefslogtreecommitdiff
path: root/neovim
diff options
context:
space:
mode:
authordavidpkj <davidpenkow1@gmail.com>2023-03-15 14:13:27 +0100
committerdavidpkj <davidpenkow1@gmail.com>2023-03-15 14:13:27 +0100
commitc7c24cd03bb55db975909083c03e13d4de95ee94 (patch)
tree259412b1dbedb5b3fec73a7a01d0018353d39854 /neovim
parent1cb4dc6380e1cc7f77f4db0ba8d5b699213afe90 (diff)
Changed up nvim
Diffstat (limited to 'neovim')
-rw-r--r--neovim/.config/nvim/lua/keybinds.lua67
-rw-r--r--neovim/.config/nvim/lua/plugins.lua8
-rw-r--r--neovim/.config/nvim/lua/plugins/telescope.lua27
-rw-r--r--neovim/.config/nvim/lua/plugins/treesitter.lua2
-rw-r--r--neovim/.config/nvim/lua/settings.lua1
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", "<A-j>", "<cmd>move .+1<cr>")
map("n", "<A-k>", "<cmd>move .-2<cr>")
map("x", "<A-j>", ":move '>+1<cr>gv=gv")
map("x", "<A-k>", ":move '<-2<cr>gv=gv")
+-- Keep cursor position
+map("n", "J", "mzJ`z")
+
+-- Keep cursur in center
+map("n", "<C-d>", "<C-d>zz")
+map("n", "<C-u>", "<C-u>zz")
+map("n", "n", "nzzzv")
+map("n", "N", "Nzzzv")
+
+-- Remove to void (and paste)
+map("n", "<leader>d", "\"_d")
+map("v", "<leader>d", "\"_d")
+map("x", "<leader>p", "\"_dP")
+
+-- Format
+map("n", "<leader>i", function() vim.lsp.buf.format() end)
+-- Edit word
+map("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
+-- Make executable
+map("n", "<leader>x", "<cmd>!chmod +x %<CR>")
+
-- map("n", "<C-space>", ":Files<CR>")
map("n", "<C-c>", ":!compile %<cr><cr>")
--- Mimic shell movements
--- map("i", "<C-E>", "<ESC>A")
--- map("i", "<C-A>", "<ESC>I")
-
-- Move to the next/previous buffer
-- map("n", "<leader>[", "<CMD>bp<CR>")
-- map("n", "<leader>]", "<CMD>bn<CR>")
@@ -29,12 +42,42 @@ map("n", "<C-c>", ":!compile %<cr><cr>")
-- Move to last buffer
-- map("n", """", "<CMD>b#<CR>")
--- Plugin
-map("n", "<C-f>", "<cmd>TodoTelescope<cr>")
+-- 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", "<leader>fh", Telescope.help_tags)
+-- Files with match
+map("n", "<leader>ff", Telescope.live_grep)
+-- Project files
+map("n", "<leader>fp", Telescope.find_files)
+-- Changed git files
+map("n", "<leader>fc", Telescope.git_status)
+-- Git files
+map("n", "<leader>fg", function()
+ local ok = pcall(Telescope.git_files, { show_untracked = true })
+ if not ok then
+ Telescope.find_files()
+ end
+end)
+
+-- Highlighted comments
+map("n", "<leader>ft", "<cmd>TodoTelescope<cr>")
-- Hacky update thing
--- TODO: Fix timing
-map("n", "<leader>u", "<cmd>PackerSync<cr><cmd>PackerCompile<cr><cmd>TSUpdate<cr><cmd>Mason<cr>")
+--[[ map("n", "<leader>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({
["<TAB>"] = actions.toggle_selection + actions.move_selection_next,
["<C-s>"] = actions.send_selected_to_qflist,
["<C-q>"] = actions.send_to_qflist,
+ ["<C-h>"] = 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", "<C-space>", 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", "<leader>H", Telescope.help_tags)
--- Search for string
-vim.keymap.set("n", "<leaders>s", Telescope.live_grep)
--- Fuzzy find changed files in git
-vim.keymap.set("n", "<leader>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"