NeoVim

NeoVim: Build Your Own Personal IDE

Let’s start a never-ending thread about customising and tuning the NeoVim editor.
Feel free to ask anything, share your own configs or links to plugins!

How to Vim?

Where to Start?

Where to Dig?

For Video Fans

6 Likes

This is the copy of kickstart.nvim config without extra bloat and with some additional (missing?) parts.

-- Set <space> as the leader key
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

-- [[ Setting options ]]
-- See `:help vim.opt`
vim.opt.number = true
vim.opt.mouse = 'a'
vim.opt.showmode = false
vim.opt.clipboard = 'unnamedplus'
vim.opt.breakindent = true
vim.opt.undofile = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.signcolumn = 'yes'
vim.opt.updatetime = 250
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.opt.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
vim.opt.inccommand = 'split'
vim.opt.cursorline = true
vim.opt.scrolloff = 10

-- [[ Basic Keymaps ]]
--  See `:help vim.keymap.set()`

vim.opt.hlsearch = true
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')

-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })

vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })

-- [[ Basic Autocommands ]]
--  See `:help lua-guide-autocommands`

-- Highlight when yanking (copying) text
vim.api.nvim_create_autocmd('TextYankPost', {
  desc = 'Highlight when yanking (copying) text',
  group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
  callback = function()
    vim.highlight.on_yank()
  end,
})

-- [[ Install `lazy.nvim` plugin manager ]]
--    See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
  vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)

-- [[ Configure and install plugins ]]
require('lazy').setup({
  'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically

  { 'numToStr/Comment.nvim', opts = {} }, -- "gc" to comment visual regions/lines

  { -- Adds git related signs to the gutter, as well as utilities for managing changes
    'lewis6991/gitsigns.nvim',
    opts = {
      signs = {
        add = { text = '│' },
        change = { text = '│' },
        delete = { text = '_' },
        topdelete = { text = '‾' },
        changedelete = { text = '│' },
      },
    },
  },

  { -- LSP Configuration & Plugins
    'neovim/nvim-lspconfig',
    dependencies = {
      'williamboman/mason.nvim',
      'williamboman/mason-lspconfig.nvim',
      'WhoIsSethDaniel/mason-tool-installer.nvim',
      { 'j-hui/fidget.nvim', opts = {} },
      { 'folke/neodev.nvim', opts = {} },
    },
    config = function()
      vim.api.nvim_create_autocmd('LspAttach', {
        group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
        callback = function(event)
          local map = function(keys, func, desc)
            vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
          end

          map('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
          map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
          map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
          map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
          map('K', vim.lsp.buf.hover, 'Hover Documentation')

          local client = vim.lsp.get_client_by_id(event.data.client_id)
          if client and client.server_capabilities.documentHighlightProvider then
            vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
              buffer = event.buf,
              callback = vim.lsp.buf.document_highlight,
            })

            vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
              buffer = event.buf,
              callback = vim.lsp.buf.clear_references,
            })
          end
        end,
      })

      local capabilities = vim.lsp.protocol.make_client_capabilities()
      capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())

      local servers = {
        tsserver = {},
      }

      require('mason').setup()

      local ensure_installed = vim.tbl_keys(servers or {})
      require('mason-tool-installer').setup { ensure_installed = ensure_installed }

      require('mason-lspconfig').setup {
        handlers = {
          function(server_name)
            local server = servers[server_name] or {}
            server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
            require('lspconfig')[server_name].setup(server)
          end,
        },
      }
    end,
  },

  { -- Autocompletion
    'hrsh7th/nvim-cmp',
    event = 'InsertEnter',
    dependencies = {
      {
        'L3MON4D3/LuaSnip',
        build = (function()
          return 'make install_jsregexp'
        end)(),
      },
      'saadparwaiz1/cmp_luasnip',
      'hrsh7th/cmp-nvim-lsp',
      'hrsh7th/cmp-path',
    },
    config = function()
      local cmp = require 'cmp'
      local luasnip = require 'luasnip'
      luasnip.config.setup {}

      cmp.setup {
        snippet = {
          expand = function(args)
            luasnip.lsp_expand(args.body)
          end,
        },
        completion = { completeopt = 'menu,menuone,noinsert' },

        mapping = cmp.mapping.preset.insert {
          ['<CR>'] = cmp.mapping.confirm {
            behavior = cmp.ConfirmBehavior.Insert,
            select = true,
          },
          ['<C-n>'] = cmp.mapping.select_next_item(),
          ['<C-p>'] = cmp.mapping.select_prev_item(),
          ['<C-b>'] = cmp.mapping.scroll_docs(-4),
          ['<C-f>'] = cmp.mapping.scroll_docs(4),
          ['<C-y>'] = cmp.mapping.confirm { select = true },
          ['<C-Space>'] = cmp.mapping.complete {},
          ['<C-l>'] = cmp.mapping(function()
            if luasnip.expand_or_locally_jumpable() then
              luasnip.expand_or_jump()
            end
          end, { 'i', 's' }),
          ['<C-h>'] = cmp.mapping(function()
            if luasnip.locally_jumpable(-1) then
              luasnip.jump(-1)
            end
          end, { 'i', 's' }),
        },
        sources = {
          { name = 'nvim_lsp' },
          { name = 'luasnip' },
          { name = 'path' },
        },
      }
    end,
  },

  { -- You can easily change to a different colorscheme.
    'folke/tokyonight.nvim',
    priority = 1000, -- Make sure to load this before all the other start plugins.
    init = function()
      vim.cmd.colorscheme 'tokyonight-night'
    end,
  },

  { -- Highlight, edit, and navigate code
    'nvim-treesitter/nvim-treesitter',
    build = ':TSUpdate',
    opts = {
      ensure_installed = { 'bash', 'c', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' },
      auto_install = true,
      highlight = {
        enable = true,
      },
      indent = { enable = true },
    },
    config = function(_, opts)
      require('nvim-treesitter.configs').setup(opts)
    end,
  },
})

-- vim: ts=2 sts=2 sw=2 et
3 Likes

My list of plugins (sorted from favourites to must-haves):

I’d also want to mention the popular NeoVim “distributions” (AstroVim, LazyVim, NvChad, etc). They look like the easy way to go, but I would recommend you create your own config from scratch. It will help you be more familiar with the tool you want to create and use =) The only exception is mini.nvim. It’s not a “distribution” but a library of independent Lua modules that require a deep understanding and can be used independently.

4 Likes

I’ve been wanting to do this and putting it off for months, but you helped me bite the bullet, thank you :slight_smile:

2 Likes

Glad to hear that!
Maybe you can share your config (or screenshots) to inspire someone else =)

More vim is always good.

1 Like

Hey here is one resource that helped me learn vim motions the first time

3 Likes
2 Likes

kad san u terminalu vim mi je view a nano editor…
nano je malo laksi za zahvatit i zapamtit komande, dok vim ima bolji preglet al komplicirano malo za editor… bar sta se tice na android uredajima…
jedino sta znam od vim.a jest:
:w :qa!
ovakav post mnogo znaci +

1 Like
2 Likes

@coja radi li na win7 32bit znas li?
hh a jest ancient OS al stas hh…

evo malo studiram ovaj naovim na liuxu
i mogao bih rec jako opsiran editor ima mogucnosti masu… malo kad uvatis komande kao hjkl za kretnju i komande za edit text nvim jako dobro…

nego @coja znas li mozda kako ovaj split screen da mi bude na pola ekrena ovo di je bila traka spustit malo doli…znaci dijezuta linija da bude di je poluzelena kao…
ako koristis na androidu, i jel se stavlja .vimrc u .vim folder il … nvim isto poteze config iz .vimrc…

ono sta nisan skuzija prije jest da ovi vim editor ima 4moda kao view/insert/ex/command hh kasnije se uigras s komandama…

@coja
e kako se installira ovaj fajl za linx:

neovide.AppImage

ova appImage za neovide

You need to set up the execution permission for the AppImage file:

chmod +x ./filename.appimage

After that you could run it with ./filename.appimage or with a doubleclick.

  • Ctrl+W +/- increase/decrease height (ex. 20<C-w>+)
  • Ctrl+W >/< increase/decrease width (ex. 30<C-w><)
  • Ctrl+W = equalize width and height of all windows

See also :help CTRL-W or this chapter for basic introduction.

Hope it helps! =)

2 Likes

Did you try it?

I like the cursor animation and smooth scrolling, but kitty still much more suitable for my workflow: I’m too lazy to switch working directory inside of the vim, old good cd + nvim still works :smiley:

@disu1950 Ne znam za win7 32bita, preporucujem da ga oboris i instalias debian 32bita, poslednju verziju, imaces mng vise mogucnosti i bice znatno brzi.

Za split terminala nzm, vidim da je to termux. Mozes da probas sa tmux, sa njim moze split kako zelis.

1 Like

I did, added some neovide config to init.lua, like window size, transperentcy, zoom, cursor is more fun… looks cool and seems to be a faster.

1 Like

@coja

instalias debian 32bita, poslednju verzij

ako moze link di mogu skinit i koliko GB je potrebo ?

@He4eT
thx for info, ill try … just came online… +

https://cdimage.debian.org/debian-cd/current/i386/iso-cd/debian-12.6.0-i386-netinst.iso

1 Like

yees this one i needed:

Ctrl+W +/- increase/decrease height (ex. 20<C-w>+)

thx for this
sad je to ovako pola-pola screen

while testing these also found out we can split screen on many ways to open many files…

using these
navigate between windows, use these shortcuts:

Ctrl-W H Moves the cursor to the left window 
Ctrl-W J Moves the cursor to the window below 
Ctrl-W K Moves the cursor to the window upper 
Ctrl-W L Moves the cursor to the right window

*premda je lakse na android mos tap da pribaci kurson stoga bolje i brze nego ovi gori shortcuts…

useful normal-mode window commands:

Ctrl-W V Opens a new vertical split 
Ctrl-W S Opens a new horizontal split 
Ctrl-W C Closes a window 
Ctrl-W O Makes the current window the only one on screen and closes other windows 

And here is a list of useful window command-line commands:

:vsplit filename Split window vertically 
:split filename Split window horizontally 
:new filename Create new window

@coja

thx…
dns cu bas vidit…
download sam…
600mb+ to je prihvatljivo hh