Neovim Config
Table of Contents
プログラミングする時の一番大事な道具はエディタ。僕は neovim を使っていて、その設定をまとめた。
色々あったけど結局、kickstart.nvim を使ってる。設定そのものというより、lua の使い方を知って、 lua 経由からどうやって neovim を使うかを知った方が生産的。
色もデフォルトにしてる。
Past settings
パソコン通信。それはそうと、neovim が emacs 化している。
vim の中でターミナルを使うし、
メールもできるよ。
完全に自己満足の世界…
reset all config
rm -rf ~/.config/nvim rm -rf ~/.local/share/nvim mkdir -p ~/.config/nvim/lua/plugins
init.lua
ディレクトリはこんな感じ。
.config/ ├─ nvim/ │ ├─ init.lua │ │ ├─ lua/ │ │ │ ├─ init_lazy.lua │ │ │ ├─ options.lua │ │ │ ├─ plugins/ │ │ │ │ ├─ init.lua │ │ │ │ ├─ {plugin}.lua // whatever you need
これは、 ~/.config/nvim/init.lua
で、みての通り、他の設定をまとめているだけ。neovim は、lua 言語(でも)設定する。
require('init_lazy') require('options') require('keymaps')
initlazy.lua
lazy.nvim
is the new plugin manager
-- setup lazy local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release lazypath, }) end vim.opt.rtp:prepend(lazypath) vim.g.mapleader = " " -- Make sure to set `mapleader` before lazy so your mappings are correct require("lazy").setup("plugins")
UI and appearance
alpha.lua
return{ "goolord/alpha-nvim", dependencies ={ "nvim-tree/nvim-web-devicons", }, config = function() local dashboard = require("alpha.themes.dashboard") dashboard.section.header.val={ "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡟⠉⠻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⣷⡀⠀⠀⠿⠿⠿⠿⠿⠿⢿⣿⠷⠀⠀⠀⠀⠀⠀⢰⡿⠀⢰⣶⣶⣶⣶⣶⣶⣶⡆⠀", "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣧⣀⣴⠃⠀⠀⠀⠀⣶⣆⠀⠀⠀⠀⠀⠀⠀⠀⣿⡆⠀⠀⠀⠀⠀⢠⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⠀⠀⠀⠀⠀⠀⢼⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣦⠀⠀⠀⠛⢿⣦⣾⠛⠀⠀⠀⠀⠀⠀⠀⠀⣿⠁⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀", "⠀⠀⠀⠀⣼⣶⠀⠀⠀⠰⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣆⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠉⠉⠉⠉⢹⣿⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⡶⠀⠀⠀⠀⠀⠀⣾⡄⠀⠀⠀⠀⠀⠀⠀⠀⣶⣶⣶⣶⣶⣿⣶⣶⣶⡆⠀⠀⠀⠀⣼⣿⠀⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉", "⠀⠀⠀⢀⣿⠃⠀⠀⠀⠀⠹⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⠀⠀⠀⠀⠀⠀⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⣿⠀⠀⠀⣿⡇⠀⠀⠀⣰⣿⣿⠀⠀⠸⠿⠿⠿⠿⠿⠿⠿⠇⠀", "⠀⠀⠀⣿⡟⠀⠀⠀⠀⠀⠀⠙⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⡿⠀⠀⠀⠀⠀⠛⠛⣿⡇⠀⣿⡟⠛⠛⣿⠛⠛⠛⣿⡇⠀⠀⢰⡿⢸⣿⠀⠀⢠⣤⣤⣤⣤⣤⣤⣤⡄⠀", "⠀⠀⣾⡿⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⣿⣷⣶⣶⣿⣶⣶⣶⣿⡇⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", "⢀⣾⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣶⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⣿⡇⠀⠀⣿⠀⠀⠀⣿⡇⠀⠀⠀⠀⢸⣿⠀⠀⣿⠛⠛⠛⠛⠛⠛⢻⣿⠀", "⠀⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⠿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠛⠛⠛⠛⠛⠛⠛⠛⠛⢻⣿⠀⠀⠀⠀⠀⠀⢰⣶⣿⡿⠟⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣷⡀⠿⠇⠀⠀⠿⠀⠸⣿⣿⠃⠀⠀⠀⠀⢸⣿⠀⠀⣿⠀⠀⠀⠀⠀⠀⢸⣿⠀", "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⡿⠁⠈⠛⢿⣷⣶⣶⣶⣶⣶⣶⣶⣶⡇⠀⠀⠀⢸⣿⠀⠀⣿⠿⠿⠿⠿⠿⠿⢿⣿⠀", "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠀⠀⠉⠀⠀⠀⠀⠀⠀⠈⠉⠀", "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", } dashboard.section.buttons.val = { dashboard.button( "SPC .", " > File Browser", ":cd $HOME/code | Telescope file_browser<CR>"), dashboard.button( "SPC f f", " > Find file", ":cd $HOME/code | Telescope git_files<CR>"), dashboard.button( "SPC a", " > Terminal", "<cmd>lua require('FTerm').toggle()<CR>"), dashboard.button( "SPC v", " > Git", '<cmd>lua require("FTerm").scratch({cmd="lazygit"})<CR>'), dashboard.button( "SPC m", " > Mail", '<cmd>lua require("FTerm").scratch({cmd="neomutt"})<CR>'), dashboard.button( "SPC l", " > Lazy (Package Manager)", "<cmd>Lazy<CR>"), dashboard.button( "SPC h", " > Help", "<cmd>Telescope help_tags<cr>"), dashboard.button( "q", " > Quit NVIM", ":qa<CR>"), } require('alpha').setup(dashboard.opts) end }
rose-pine.lua
theme, pure taste
return{ 'rose-pine/neovim', name = 'rose-pine', config = function() vim.cmd('colorscheme rose-pine') end }
which-key.lua
I forget which key is which
return{ "folke/which-key.nvim", config = function() vim.o.timeout = true vim.o.timeoutlen = 300 require("which-key").setup({ }) local wk = require("which-key") wk.register({ l = {"<cmd>Lazy<cr>", "Lazy"}, y = {'\'"+y', "Copy to Clipboard"}, s = {'w', "Save"}, }, { prefix = "<leader>" }) end }
treesitter.lua
better syntax highlighting
return{ "nvim-treesitter/nvim-treesitter", build = function() require("nvim-treesitter.install").update({ with_sync = true }) end, config = function() require("nvim-treesitter.configs").setup { ensure_installed = {"c", "python", "lua", "rust", "vim", "vimdoc", "toml", "bash", "bibtex", "css", "diff", "gitignore", "html", "jq", "json", "latex", "lua", "markdown", "swift", "typescript", "javascript", "tsx", "elixir"}, sync_install = false, auto_install = false, highlight = { enable = true, additional_vim_regex_highlighting = false, } } end }
treesitter-context.lua
when in functions or loops, the first line of the block(the signature) ’sticks’ to the top of the buffer.
return { "nvim-treesitter/nvim-treesitter-context", config = function() require('treesitter-context').setup({}) end }
lualine.lua
bottom status line
return { "nvim-lualine/lualine.nvim", dependencies = { {"nvim-tree/nvim-web-devicons"} }, config = function() require("lualine").setup() end }
bufferline.lua
top bar tab-like file list
// #+beginsrc lua
return { "akinsho/bufferline.nvim", dependencies = { {"nvim-tree/nvim-web-devicons"} }, config = function() require("bufferline").setup() end }
trouble.lua
consolidate errors and fixes
// #+beginsrc lua
return{ "folke/trouble.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, config = function() require("trouble").setup { } local wk = require('which-key') wk.register({ x = { name = "Trouble", x = {"<cmd>TroubleToggle<cr>", "Toggle Trouble"}, w = {"<cmd>TroubleToggle workspace_diagnostics<cr>", "Trouble Workspace"}, d = {"<cmd>TroubleToggle document_diagnostics<cr>", "Trouble Document"}, q = {"<cmd>TroubleToggle quickfix<cr>", "Trouble Quickfix"}, }, }, {prefix = "<leader>"}) end }
LSP
lsp-zero
the bigboy. We may not need lsp-zero.nvim
return{ 'VonHeikemen/lsp-zero.nvim', branch = 'v2.x', dependencies = { -- LSP Support {'neovim/nvim-lspconfig'}, { 'williamboman/mason.nvim', build = function() pcall(vim.cmd, 'MasonUpdate') end, }, {'williamboman/mason-lspconfig.nvim'}, -- Autocompletion {'hrsh7th/nvim-cmp'}, {'hrsh7th/cmp-buffer'}, {'hrsh7th/cmp-path'}, {'hrsh7th/cmp-nvim-lsp'}, {'hrsh7th/cmp-nvim-lua'}, {'L3MON4D3/LuaSnip', dependencies={"rafamadriz/friendly-snippets"} }, {"lvimuser/lsp-inlayhints.nvim"} -- {"simrat39/rust-tools.nvim"} }, config = function() local lsp = require('lsp-zero').preset({}) lsp.on_attach(function(client, bufnr) lsp.default_keymaps({buffer = bufnr}) end) local hints = require('lsp-inlayhints') local lspconfig = require('lspconfig') lspconfig.lua_ls.setup({ on_attach = function(client, bufnr) hints.on_attach(client, bufnr) end, settings = { Lua = { hint = { enable = true, } } } }) lspconfig.rust_analyzer.setup({ on_attach = function(client, bufnr) hints.on_attach(client, bufnr) end, settings = { ["rust-analyzer"] = { inlayHints = { enable = false, } } } }) lspconfig.tsserver.setup({ on_attach = function(client, bufnr) hints.on_attach(client, bufnr) end, settings = { typescript = { inlayHints = { includeInlayParameterNameHints = "all", includeInlayParameterNameHintsWhenArgumentMatchesName = false, includeInlayFunctionParameterTypeHints = true, includeInlayVariableTypeHints = true, includeInlayVariableTypeHintsWhenTypeMatchesName = false, includeInlayPropertyDeclarationTypeHints = true, includeInlayFunctionLikeReturnTypeHints = true, includeInlayEnumMemberValueHints = true, } } } }) lsp.setup() local cmp = require('cmp') local cmp_action = require('lsp-zero').cmp_action() local select_ops = { behavior = cmp.SelectBehavior.Select } require('luasnip.loaders.from_vscode').lazy_load() local has_words_before = function() if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end local line, col = unpack(vim.api.nvim_win_get_cursor(0)) return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match("^%s*$") == nil end cmp.setup({ sources = { {name = 'copilot', keyword_length = 2}, {name = 'path'}, {name = 'nvim_lsp'}, {name = 'buffer', keyword_length = 3}, {name = 'luasnip', keyword_length = 2} }, mapping = { ['<CR>'] = cmp.mapping.confirm({select=true}), ['<C-l'] = cmp_action.luasnip_jump_forward(), ['<C-h>'] = cmp_action.luasnip_jump_backward(), ['<C-e>'] = cmp.mapping.abort(), ['<C-j>'] = cmp.mapping.select_next_item(select_ops), ['<C-k>'] = cmp.mapping.select_prev_item(select_ops), ['<Down>'] = cmp.mapping.scroll_docs(4), ['<Up>'] = cmp.mapping.scroll_docs(-4), }, sorting = { priority_weight = 2, comparators = { require("copilot_cmp.comparators").prioritize, -- Below is the default comparitor list and order for nvim-cmp cmp.config.compare.offset, -- cmp.config.compare.scopes, --this is commented in nvim-cmp too cmp.config.compare.exact, cmp.config.compare.score, cmp.config.compare.recently_used, cmp.config.compare.locality, cmp.config.compare.kind, cmp.config.compare.sort_text, cmp.config.compare.length, cmp.config.compare.order, }, } }) end }
lua
better ui for lsp?
return { "glepnir/lspsaga.nvim", event = "LspAttach", dependencies = { {"nvim-tree/nvim-web-devicons"}, {"nvim-treesitter/nvim-treesitter"}, {"VonHeikemen/lsp-zero.nvim"}, -- zero needs to be there }, config = function() require("lspsaga").setup({ finder = { keys = { toggle_or_open = '<cr>', } }, outline = { keys = { toggle_or_open = '<cr>', } } }) local wk = require('which-key') wk.register({ F = {"<cmd>lua vim.lsp.buf.format()<cr>", "Format Buffer"}, g = { name = "+LSP", g = {"<cmd>Lspsaga finder def+imp+ref <cr>", "lsp finder"}, r = {"<cmd>Lspsaga rename<cr>", "Rename"}, a = {"<cmd>Lspsaga code_action<cr>", "Code action"}, p = {"<cmd>Lspsaga peek_definition<cr>", "Peek definition"}, d = {"<cmd>Lspsaga goto_definition<cr>", "Goto definition"}, o = {"<cmd>Lspsaga outline<cr>", "File Outline"}, n = {"<cmd>lua vim.diagnostic.goto_next()<cr>", "Goto next diagnostic"} } }, {prefix="<leader>"}) end, }
inlay-hints.lua
the default may be too much, most configurations go inside lsp.lua
return { "lvimuser/lsp-inlayhints.nvim", config = function() require('lsp-inlayhints').setup({ only_current_line = true }) vim.cmd('hi! LspInlayHint guifg=#403d52 guibg=#1f1d2e') end }
(archive) using formatter.nvim
this doesn’t work well with lazy
?
Formatting, I see examples using null-ls
but I don’t know if I need it.
return{ 'mhartington/formatter.nvim', config = function() require('formatter').setup({ filetype = { rust = { rustfmt= function() return { exe = "rustfmt", args = {"--edition 2021"}, stdin = true } end }, javascript = {require('formatter.filetypes.javascript').prettier}, typescript = {require('formatter.filetypes.typescript').prettier}, javascriptreact = {require('formatter.filetypes.javascriptreact').prettier}, typescriptreact = {require('formatter.filetypes.typescriptreact').prettier} } }) local wk = require('which-key') wk.register({ F = {"<cmd>Format<cr>", "Format"} },{prefix="<leader>"}) end }
copilot.lua
https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/extras/coding/copilot.lua
:Copilot auth
が必要
return { 'zbirenbaum/copilot.lua', cmd = "Copilot", event = "InsertEnter", config = function() require("copilot").setup({ suggestion = {enabled = false}, panel = { enabled = false }, }) end, }
puts the copilot suggestions in the autocomplete list
return { 'zbirenbaum/copilot-cmp', config = function() require("copilot_cmp").setup() end, }
Utility
tmux
I use tmux when using my compter through ssh-ing from my ipad.
return { 'aserowy/tmux.nvim', config= function() require('tmux').setup() end }
buffers (bufdelete.lua)
return{ "famiu/bufdelete.nvim", dependencies = { "nvim-telescope/telescope.nvim", }, config = function () local wk = require("which-key"); wk.register({ ["<leader>"] = {"<C-^><cr>", "alternate file"}, b = { name = "+Buffers", b = {"<cmd>Telescope buffers<cr>", "Buffers"}, d = {"<cmd>Bdelete<cr>", "Delete"}, l = {"<cmd>bnext<cr>", "next"}, h = {"<cmd>bprevious<cr>", "back"}, } }, {prefix="<leader>"}) end }
leap.lua
s
invokes leap, hit the subsequent letters you are looking, (if ’function’ hit sfu
) the fourth letter is the label if there is multiple possibilities.
return{ 'ggandor/leap.nvim', config = function() require('leap').add_default_mappings() end }
telescope.lua
fuzzy finder
return { 'nvim-telescope/telescope.nvim', tag = '0.1.4', dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope-fzy-native.nvim', }, config = function() require('telescope').load_extension('fzy_native') local wk = require('which-key') wk.register({ f = {"<cmd>Telescope find_files<cr>", "Find Files"}, r = {"<cmd>Telescope live_grep<cr>", "ripgrep"}, h = {"<cmd>Telescope help_tags<cr>", "Help"}, }, { prefix = "<leader>" }) end }
telescope-file-browser.lua
telescope findfiles + create and delete
return { "nvim-telescope/telescope-file-browser.nvim", dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }, config = function () require("telescope").load_extension "file_browser" require("which-key").register({ ["."] = {"<cmd>Telescope file_browser<cr>", "File Browser"} }, {prefix="<leader>"}) end }
undotree.lua
let’s see if I use this
return{ 'mbbill/undotree', config = function() local wk = require('which-key') wk.register({ u = {"<cmd>UndotreeToggle<cr>","Undo Tree"} }, {prefix="<leader>"}) end }
himalaya.lua
あんまり安定していない。
return{ 'https://git.sr.ht/~soywod/himalaya-vim', config = function() vim.g.himalaya_folder_picker = 'telescope' require('which-key').register({ n = {'<cmd>Himalaya<cr>', 'Himalaya email client'} }, {prefix='<leader>'}) end }
なので、却下。
autopair.lua
return { "windwp/nvim-autopairs", config = function() require("nvim-autopairs").setup { check_ts = true, } end }
typst
return { 'kaarmu/typst.vim', ft = 'typst', lazy = false, }
Terminal
FTerm
toggle term
seems to be the other (more) popular one.
return{ 'numToStr/FTerm.nvim', opts = {--[[ things you want to change go here]]}, config = function() function is_terminal_open() for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do if vim.bo[bufnr].buftype == 'terminal' then return true end end return false end -- UserCommands vim.api.nvim_create_user_command('OpenLazyGit', function() require('FTerm').scratch({cmd="lazygit", config={auto_close=true}}) end, {bang = true}) vim.api.nvim_create_user_command('ToggleOneShotTerminal', function() local fterm = require('FTerm'); if is_terminal_open() then fterm.exit() else fterm.open() end end, {bang = true}) require('FTerm').setup{} local wk = require('which-key') wk.register({ t = {'<cmd>lua require("FTerm").toggle()<cr>', "Open Terminal"}, a = {'<cmd>ToggleOneShotTerminal<cr>', "Toggle Terminal"}, v = {'<cmd>OpenLazyGit<cr>', "Version Control (git)"}, i = {'<cmd>lua require("FTerm").scratch({cmd="git rebase -i"})<cr>', "Rebase Interactive"} }, {prefix="<leader>"}) end }
unception.lua
avoids nesting neovim instances when you try to use vim inside the teminal-mode inside vim.
similar plugin 'willothy/flatten.nvim'
return { "samjwill/nvim-unception", dependencies = { {"numToStr/FTerm.nvim"}, }, init = function() vim.g.unception_open_buffer_in_new_tab = true end, config = function() vim.api.nvim_create_autocmd( "User", { pattern = "UnceptionEditRequestReceived", callback = function() require('FTerm').toggle() end } ) end }
options.lua
vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.softtabstop = 4 vim.opt.expandtab = true vim.opt.encoding = 'utf-8' vim.scriptencoding = 'utf-8' -- vim.opt.ambiwidth= 'double' vim.opt.cursorline=true vim.opt.timeoutlen=300 vim.opt.updatetime=300 vim.opt.signcolumn="yes" vim.opt.splitright = true vim.opt.splitbelow = true vim.opt.mouse="a" vim.opt.swapfile = false vim.opt.backup = false vim.opt.undodir= vim.fn.getenv("HOME") .. "/.vimdid" vim.opt.undofile = true vim.opt.scrolloff = 999 vim.opt.laststatus = 2 vim.opt.ignorecase = true vim.opt.smartcase = true vim.opt.gdefault = true vim.opt.hlsearch = false vim.opt.incsearch = true vim.opt.termguicolors = true vim.opt.relativenumber = true vim.opt.number = true vim.o.foldenable = true vim.o.foldmethod = 'expr' vim.o.foldlevel = 1000 vim.o.foldexpr = 'nvim_treesitter#foldexpr()' if vim.fn.has('macunix') then vim.opt.clipboard:append { 'unnamedplus' } end -- au TextYankPost * silent! lua vim.highlight.on_yank() vim.cmd('au TextYankPost * silent! lua.highlight.on_yank()') -- no line numbers when using the teminal vim.cmd('au TermOpen * setlocal nonumber norelativenumber') -- neomutt text-flowed option vim.cmd('au BufNewFile,BufRead neomutt-* setf mail') -- format on save vim.cmd('au BufWritePre * lua vim.lsp.buf.format()')
keymaps.lua
-- some generic keymappings are in which-key.lua local keymap = vim.api.nvim_set_keymap local option = {noremap=true} keymap('i', 'jk', '<Esc>', option) keymap('n', 'j', 'gj', option) keymap('n', 'k', 'gk', option) keymap('n', ';', ':', option) keymap('v', 'J', ":m '>+1<cr>gv=gv", option) keymap('v', 'K', ":m '<-2<cr>gv=gv", option) keymap('n', '<C-d>', '<C-d>zz', option) keymap('n', '<C-u>', '<C-u>zz', option) keymap('n', 'n', 'nzzzv', option) keymap('n', 'N', 'Nzzzv', option) keymap('x', '<leader>p', '\"_dP', option) keymap('v', '<leader>y', '\"+y', option) keymap('n','Q','nop', option) -- exit terminal mode keymap('t', 'jk', '<c-\\><c-n>', {})