Added part of configurations

master
hheik 2025-12-30 17:50:40 +02:00
commit 70d36b38d8
21 changed files with 515 additions and 0 deletions

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# Requirements:
## Apt packages
There are some packages required by Mason, Telescope, etc.
**Note: this list is very loose list.**
```shell
sudo apt install gcc ripgrep unzip java-common default-jre luarocks cmake libbinutils moreutils shellcheck
```
## Language servers:
```
:MasonInstall lua-language-server@3.15.0
:MasonInstall typescript-language-server
:MasonInstall rust_analyzer
```
## NerdFont
A NerdFont with symbols is required to show icons in tree view

27
init.lua Normal file
View File

@ -0,0 +1,27 @@
require 'general'
require 'spec'
spec 'plugin/colorscheme'
spec 'plugin/treesitter'
spec 'plugin/telescope'
spec 'plugin/mason'
spec 'plugin/nvimtree'
spec 'plugin/nvimtree-icons'
spec 'plugin/toggleterm'
spec 'plugin/lspconfig'
-- spec 'plugin/bufferline'
-- spec 'plugin/copilot'
-- spec 'plugin/smartword'
-- spec 'plugin/gitsigns'
-- spec 'plugin/lualine'
spec 'plugin/autopairs'
spec 'plugin/lspkind'
spec 'plugin/nvim-cmp'
-- spec 'plugin/nvim-navic'
-- spec 'plugin/csvview'
-- spec 'plugin/which-key'
require 'plugin/lazy'
require 'lsp'
require 'scripts'
require 'keymap'

20
lazy-lock.json Normal file
View File

@ -0,0 +1,20 @@
{
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"lspkind.nvim": { "branch": "master", "commit": "3ddd1b4edefa425fda5a9f95a4f25578727c0bb3" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "4cfe411526a7a99c18281135e8b4765ae6330d15" },
"mason.nvim": { "branch": "main", "commit": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800" },
"nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" },
"nvim-cmp": { "branch": "main", "commit": "d97d85e01339f01b842e6ec1502f639b080cb0fc" },
"nvim-lspconfig": { "branch": "master", "commit": "41ceb6bba3a40128b7841f5b7f5a9dae7201e823" },
"nvim-tree.lua": { "branch": "master", "commit": "b8b44b6a2494d086a9177251a119f9daec6cace8" },
"nvim-treesitter": { "branch": "main", "commit": "7efc1b58a8061d29786860006c7257c90a5196dc" },
"nvim-web-devicons": { "branch": "master", "commit": "6788013bb9cb784e606ada44206b0e755e4323d7" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope.nvim": { "branch": "master", "commit": "4d0f5e0e7f69071e315515c385fab2a4eff07b3d" },
"toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" },
"tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }
}

17
lsp/lua_ls.lua Normal file
View File

@ -0,0 +1,17 @@
return {
cmd = { 'lua-language-server' },
filetypes = { 'lua' },
root_markers = { '.luarc.json', '.luarc.jsonc' },
settings = {
Lua = {
runtime = { version = 'LuaJIT' },
diagnostics = {
globals = { 'vim' },
},
workspace = {
library = vim.api.nvim_get_runtime_file('', true),
checkThirdParty = true,
},
},
},
}

34
lua/general.lua Normal file
View File

@ -0,0 +1,34 @@
local tab_width = 4
vim.g.mapleader = ' '
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.cursorline = true
vim.opt.hidden = true
vim.o.whichwrap = '<,>,[,]'
vim.opt.wrap = false
vim.opt.shiftwidth = tab_width
vim.opt.tabstop = tab_width
vim.opt.softtabstop = tab_width
vim.opt.expandtab = false
vim.opt.textwidth = 120
vim.opt.undofile = true
vim.opt.undodir = os.getenv('HOME') .. '/.vim/undodir'
vim.opt.list = true
vim.opt.listchars = {
leadmultispace = ' ',
multispace = '.',
tab = ' - ',
}
vim.opt.signcolumn = 'number'
vim.opt.scrolloff = 10
vim.diagnostic.config { virtual_text = true }

81
lua/keymap.lua Normal file
View File

@ -0,0 +1,81 @@
local vertical_resize_step = 4
local horizontal_resize_step = 8
local small_step = 5
local big_step = 25
vim.keymap.set('n', '<leader>w', '<cmd>w<cr>')
vim.keymap.set('n', '<leader>q', '<cmd>q<cr>')
vim.keymap.set('n', '<leader>c', '<cmd>bp<cr><cmd>bd#<cr>')
vim.keymap.set('n', '<leader>h', '<cmd>nohl<cr>')
vim.keymap.set('n', '<leader>z', '<cmd>set wrap! wrap?<cr>')
vim.keymap.set('n', '<leader>x', '<cmd>set cursorline! cursorline?<cr>')
vim.keymap.set('n', '<c-k>', '<c-w>k')
vim.keymap.set('n', '<c-j>', '<c-w>j')
vim.keymap.set('n', '<c-h>', '<c-w>h')
vim.keymap.set('n', '<c-l>', '<c-w>l')
vim.keymap.set('n', '<leader><up>', '<c-w>k')
vim.keymap.set('n', '<leader><down>', '<c-w>j')
vim.keymap.set('n', '<leader><left>', '<c-w>h')
vim.keymap.set('n', '<leader><right>', '<c-w>l')
vim.keymap.set('n', '<m-c-up>', '<cmd>resize +' .. vertical_resize_step .. '<cr>')
vim.keymap.set('n', '<m-c-down>', '<cmd>resize -' .. vertical_resize_step .. '<cr>')
vim.keymap.set('n', '<m-c-left>', '<cmd>vertical resize -' .. horizontal_resize_step .. '<cr>')
vim.keymap.set('n', '<m-c-right>', '<cmd>vertical resize +' .. horizontal_resize_step .. '<cr>')
vim.keymap.set({'n', 'v'}, '<s-up>', small_step .. 'k')
vim.keymap.set({'n', 'v'}, '<s-down>', small_step .. 'j')
vim.keymap.set({'n', 'v'}, '<c-up>', small_step .. '<c-y>' .. small_step .. 'k')
vim.keymap.set({'n', 'v'}, '<c-down>', small_step .. '<c-e>' .. small_step .. 'j')
vim.keymap.set({'n', 'v'}, '<pageup>', big_step .. '<c-y><cmd>lua center_cursor()<cr>')
vim.keymap.set({'n', 'v'}, '<pagedown>', big_step .. '<c-e><cmd>lua center_cursor()<cr>')
vim.keymap.set({'n', 'v'}, '<home>', '^')
vim.keymap.set({'n', 'v'}, '<end>', '$')
vim.keymap.set('n', 'zz', center_cursor)
vim.keymap.set('i', '<s-up>', '<c-o>' .. small_step .. 'k')
vim.keymap.set('i', '<s-down>', '<c-o>' .. small_step .. 'j')
vim.keymap.set('i', '<c-up>', '<c-o>' .. small_step .. '<c-y><c-o>' .. small_step .. 'k')
vim.keymap.set('i', '<c-down>', '<c-o>' .. small_step .. '<c-e><c-o>' .. small_step .. 'j')
vim.keymap.set('i', '<pageup>', '<c-o>' .. big_step .. '<c-y><cmd>lua center_cursor()<cr>')
vim.keymap.set('i', '<pagedown>', '<c-o>' .. big_step .. '<c-e><cmd>lua center_cursor()<cr>')
vim.keymap.set('i', '<home>', '<c-o>^')
vim.keymap.set('i', '<end>', '<c-o>$')
vim.keymap.set('i', '<c-h>', '<c-w>')
vim.keymap.set('i', '<c-delete>', '<c-o>"_dw')
vim.keymap.set('n', '<bs>', '"_dd')
vim.keymap.set('v', '<bs>', '"_d')
vim.keymap.set('n', '<m-bs>', 'mzk"_ddg`z')
vim.keymap.set('n', '<m-enter>', '<cmd>call append(line("."), "")<cr>')
vim.keymap.set('i', '<m-enter>', '<c-o>O')
vim.keymap.set({'n', 'i'}, '<m-up>', '<cmd>m -2<cr>')
vim.keymap.set({'n', 'i'}, '<m-down>', '<cmd>m +1<cr>')
vim.cmd [[
xnoremap <m-up> :m-2<cr>gv=gv
xnoremap <m-down> :m'>+<cr>gv=gv
]]
vim.keymap.set('v', '>', '>gv')
vim.keymap.set('v', '<', '<gv')
vim.keymap.set('n', 'gd', '<c-]>')
vim.keymap.set('n', '<leader>/', 'gcc', { remap = true })
vim.keymap.set('v', '<leader>/', 'gcgv', { remap = true })
vim.keymap.set('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
vim.keymap.set('n', 'gj', '<cmd>lua vim.diagnostic.goto_next()<cr>')
vim.keymap.set('n', 'gk', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
vim.keymap.set('n', '<leader>la', 'gra')
vim.keymap.set('n', '<leader>lf', '<cmd>lua vim.lsp.buf.format({ async = true })<cr>')
vim.keymap.set('n', '<leader>ln', '<cmd>lua vim.lsp.buf.rename()<cr>')
vim.keymap.set('n', '<leader>lr', '<cmd>lua vim.lsp.buf.references()<cr>')
for _, keymap in pairs(PLUGIN_KEYMAPS) do
keymap()
end

11
lua/lsp.lua Normal file
View File

@ -0,0 +1,11 @@
local enable = vim.lsp.enable
-- When calling `enable 'foo'`, there must be a given file in either:
-- * `~/.config/nvim/lsp/foo.lua`
-- * https://github.com/neovim/nvim-lspconfig/tree/master/lsp
-- you can then further configure them with `vim.lsp.config('foo'. {...})`
enable 'lua_ls'
enable 'rust_analyzer'
enable 'ts_ls'
enable 'vue_ls'

7
lua/plugin/autopairs.lua Normal file
View File

@ -0,0 +1,7 @@
local M = {
'windwp/nvim-autopairs',
event = 'InsertEnter',
config = true,
}
return M

View File

@ -0,0 +1,11 @@
local M = {
'folke/tokyonight.nvim',
lazy = false, -- load colorscheme immediately
priority = 1000,
}
M.config = function()
vim.cmd.colorscheme 'tokyonight-night'
end
return M

18
lua/plugin/lazy.lua Normal file
View File

@ -0,0 +1,18 @@
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',
lazypath
}
end
vim.opt.rtp:prepend(lazypath)
require 'lazy'.setup(LAZY_PLUGIN_SPEC, {
change_detection = {
notify = false
}
})

11
lua/plugin/lspconfig.lua Normal file
View File

@ -0,0 +1,11 @@
local M = {
'neovim/nvim-lspconfig',
dependencies = {
{
'mason-org/mason-lspconfig.nvim',
config = function() end,
},
},
}
return M

6
lua/plugin/lspkind.lua Normal file
View File

@ -0,0 +1,6 @@
local M = {
'onsails/lspkind.nvim',
config = true,
}
return M

14
lua/plugin/mason.lua Normal file
View File

@ -0,0 +1,14 @@
local M = {
'mason-org/mason.nvim',
opts = {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
},
},
},
}
return M

77
lua/plugin/nvim-cmp.lua Normal file
View File

@ -0,0 +1,77 @@
local M = {
'hrsh7th/nvim-cmp',
dependencies = {
'neovim/nvim-lspconfig',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'windwp/nvim-autopairs',
'onsails/lspkind.nvim',
},
}
M.config = function()
local cmp = require 'cmp'
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
cmp.setup {
window = {
completion = vim.tbl_deep_extend(
'force',
cmp.config.window.bordered(),
{
winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,Search:None',
col_offset = -3,
side_padding = -0,
}
),
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = { 'kind', 'abbr', 'menu' },
format = function(entry, vim_item)
local kind = require 'lspkind'.cmp_format {
mode = 'symbol_text',
maxwidth = 50,
}(entry, vim_item)
local strings = vim.split(kind.kind, '%s', { trimempty = true })
kind.kind = ' ' .. (strings[1] or '') .. ' '
kind.menu = ' (' .. (strings[2] or '') .. ')'
return kind
end
},
mapping = cmp.mapping.preset.insert({
['<c-b>'] = cmp.mapping.scroll_docs(-4),
['<c-f>'] = cmp.mapping.scroll_docs(4),
['<c-Space>'] = cmp.mapping.complete(),
['<c-e>'] = cmp.mapping.abort(),
['<down>'] = cmp.mapping.abort(),
['<up>'] = cmp.mapping.abort(),
['<c-down>'] = cmp.mapping.select_next_item(),
['<c-up>'] = cmp.mapping.select_prev_item(),
['<tab>'] = cmp.mapping.select_next_item(),
['<s-tab>'] = cmp.mapping.select_prev_item(),
['<cr>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources(
{
{ name = 'nvim_lsp' },
},
{
{ name = 'buffer' },
}
),
preselect = cmp.PreselectMode.Item,
experimental = {
ghost_text = false,
},
}
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)
end
return M

View File

@ -0,0 +1,5 @@
local M = {
'nvim-tree/nvim-web-devicons'
}
return M

33
lua/plugin/nvimtree.lua Normal file
View File

@ -0,0 +1,33 @@
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.g.termguicolors = true
local M = {
'nvim-tree/nvim-tree.lua',
opts = {
view = {
side = 'left',
width = 40,
},
actions = {
expand_all = {
max_folder_discovery = 1000,
exclude = { '.git', 'target', 'build', 'node_modules' },
},
},
update_focused_file = {
enable = true,
},
diagnostics = {
enable = true,
show_on_dirs = true,
show_on_open_dirs = true,
},
},
}
M.keymap = function()
vim.keymap.set('n', '<leader>e', '<cmd>NvimTreeFindFileToggle<cr>')
end
return M

74
lua/plugin/telescope.lua Normal file
View File

@ -0,0 +1,74 @@
local M = {
'nvim-telescope/telescope.nvim',
dependencies = { 'nvim-lua/plenary.nvim' },
lazy = true,
cmd = 'Telescope',
}
function M.config()
local actions = require 'telescope.actions'
require 'telescope'.setup {
defaults = {
path_display = { 'filename_first' },
layout_strategy = 'horizontal',
layout_config = {
prompt_position = 'top',
width = function(_, max_columns, _)
return math.min(max_columns, 180)
end,
horizontal = {
preview_width = 0.5,
},
},
sorting_strategy = 'ascending',
scroll_strategy = 'limit',
mappings = {
i = {},
n = {
['<esc>'] = actions.close,
['q'] = actions.close,
},
},
},
pickers = {
find_files = {
hidden = true,
},
live_grep = {
disable_coordinates = true,
},
grep_string = {
disable_coordinates = true,
},
},
extensions = {
file_browser = {
git_icons = {
added = "A",
changed = "M",
copied = "C",
deleted = "D",
renamed = "R",
unmerged = "U",
untracked = "?",
},
},
},
}
end
M.keymap = function()
local builtin = require 'telescope.builtin'
vim.keymap.set('n', '<leader>f', builtin.find_files)
vim.keymap.set('n', '<leader>r', builtin.resume)
vim.keymap.set('n', '<s-f>', function() builtin.grep_string { word_match = '-w' } end)
vim.keymap.set('v', '<s-f>', builtin.grep_string)
vim.keymap.set('n', '<leader>st', builtin.live_grep)
vim.keymap.set('n', '<leader>o', builtin.lsp_document_symbols)
vim.keymap.set('n', '<leader>p', builtin.lsp_workspace_symbols)
vim.keymap.set('n', '<leader>gb', builtin.git_branches)
vim.keymap.set('n', '<leader>gc', builtin.git_commits)
vim.keymap.set('n', '<m-q>', builtin.git_status)
end
return M

12
lua/plugin/toggleterm.lua Normal file
View File

@ -0,0 +1,12 @@
local M = {
'akinsho/toggleterm.nvim',
config = true
}
M.keymap = function()
for i = 1, 9 do
vim.keymap.set({'n', 't'}, '<m-' .. i .. '>', '<cmd>' .. i .. 'ToggleTerm direction=float name=term-' .. i .. '<cr>')
end
end
return M

16
lua/plugin/treesitter.lua Normal file
View File

@ -0,0 +1,16 @@
local M = {
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate', -- parsers must be kept up to date with the plugin
lazy = false, -- enable highlighting instantly
opts = {
ensure_installed = {
'bash'
},
sync_install = true,
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
},
}
return M

8
lua/scripts.lua Normal file
View File

@ -0,0 +1,8 @@
function center_cursor()
local window_height = vim.api.nvim_win_get_height(0)
local half_height = math.floor(window_height / 2)
local first_line = vim.fn.line('w0')
local pos = vim.fn.getpos('.')
pos[2] = first_line + half_height
vim.fn.setpos('.', pos)
end

10
lua/spec.lua Normal file
View File

@ -0,0 +1,10 @@
LAZY_PLUGIN_SPEC = {}
PLUGIN_KEYMAPS = {}
function spec(item)
table.insert(LAZY_PLUGIN_SPEC, { import = item })
local keymap = require(item).keymap
if keymap then
table.insert(PLUGIN_KEYMAPS, keymap)
end
end