Compare commits
44 commits
main
...
nvim-devel
Author | SHA1 | Date | |
---|---|---|---|
e4914f58de | |||
aa20450e89 | |||
ecd19d50d3 | |||
834038a59b | |||
![]() |
7eaa6551cb | ||
6363a15c3f | |||
82084adcb7 | |||
db5e4477d1 | |||
cb4c440d8c | |||
abc258d484 | |||
d05c69d8d5 | |||
a28b24c943 | |||
![]() |
835d2fa3c4 | ||
![]() |
f0fe804630 | ||
3af7600379 | |||
88b0c1ffc2 | |||
29884f0e0c | |||
![]() |
dec7cb040d | ||
![]() |
97a0858e33 | ||
![]() |
02246c2385 | ||
![]() |
d2239e1e96 | ||
21403a7774 | |||
ad9c779b20 | |||
e1dec1ee53 | |||
d3d7f6bd0a | |||
ecec0c4c56 | |||
053816706e | |||
8b4cda3834 | |||
9cc1cc99cb | |||
80481e2f1d | |||
e63ff2e483 | |||
d315070a8b | |||
f9c4d63afb | |||
ee4f78902b | |||
db10325c97 | |||
66fa89277e | |||
a45f1d47ec | |||
034fe4f764 | |||
77b3d15322 | |||
6c1e628a40 | |||
6ab96328ec | |||
4700af86a0 | |||
13e3813c29 | |||
8082bd0f1e |
67 changed files with 1055 additions and 996 deletions
|
@ -1,2 +0,0 @@
|
|||
# Useful links
|
||||
- [neovim stup guide](https://www.youtube.com/watch?v=6pAG3BHurdM)
|
37
Dockerfile
37
Dockerfile
|
@ -1,37 +0,0 @@
|
|||
FROM ubuntu:latest
|
||||
|
||||
# Install build tools and nvim deps
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
cmake \
|
||||
gettext \
|
||||
unzip \
|
||||
git \
|
||||
build-essential \
|
||||
curl \
|
||||
nodejs \
|
||||
npm \
|
||||
fzf \
|
||||
golang-go \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
ripgrep
|
||||
|
||||
# Clone neovim repo
|
||||
RUN git clone --depth 1 --branch v0.10.1 https://github.com/neovim/neovim.git
|
||||
# Build neovim
|
||||
RUN cd neovim && CMAKE_BUILD_TYPE=Release && make install
|
||||
|
||||
# Install rust
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -y | sh
|
||||
|
||||
# Create user
|
||||
RUN useradd -m nvim_playground
|
||||
USER nvim_playground
|
||||
|
||||
# Copy config to user folders
|
||||
RUN mkdir -p /home/nvim_playground/.config/nvim
|
||||
WORKDIR /home/nvim_playground/.config/nvim
|
||||
COPY --chown=nvim_playground:nvim_playground . .
|
||||
|
||||
USER nvim_playground
|
|
@ -1,26 +0,0 @@
|
|||
FROM ubuntu:latest
|
||||
|
||||
LABEL maintainer="pro100ton@gmail.com"
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
neovim \
|
||||
git \
|
||||
nodejs \
|
||||
npm \
|
||||
fzf \
|
||||
golang-go \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
unzip \
|
||||
ripgrep
|
||||
RUN useradd -m nvim_playground
|
||||
|
||||
USER nvim_playground
|
||||
|
||||
RUN mkdir /home/nvim_playground/.config
|
||||
RUN mkdir /home/nvim_playground/.config/nvim
|
||||
WORKDIR /home/nvim_playground/.config/nvim
|
||||
COPY . .
|
103
README.md
103
README.md
|
@ -1,52 +1,71 @@
|
|||
# Installation
|
||||
## obsidian.nvim
|
||||
Чтобы правильно работал плагин для obsidian'a - необходимо установить переменную окружения `OBSIDIAN_NOTES_PATH`, которая будет указывать путь до папки, где лежат документы obsidian.
|
||||
|
||||
Код, в котором это используется:
|
||||
|
||||
path: `lua/t0xa/plugins/obsidian.lua`
|
||||
code
|
||||
# Config refactor (v2.0)
|
||||
## Useful links
|
||||
- [Переписывание конфига с автором telescope](https://www.youtube.com/watch?v=kJVqxFnhIuw&t=510s)
|
||||
- [Документация по Lua в Nvim](https://neovim.io/doc/user/lua-guide.html)
|
||||
- [Конфиг TJ](https://github.com/tjdevries/config.nvim/tree/master)
|
||||
## Основные прицнипы формирования конфига
|
||||
### Root plugin папка
|
||||
Скрипты в этой папке загружаются автоматически после инициализации `neovim`, но до загрузки файлов типа `ftplugin/` или `after/`.
|
||||
### Plugins
|
||||
Разберем на примере `oil.nvim`: Сначала базовые настройки, такие как инструкция откуда качать и всякие зависимости и атрибуты по типу приоритета кладутся в директорию `custom/plugins` в виде названия плагина:
|
||||
*lua/custom/plugins/oil.lua*
|
||||
```lua
|
||||
...
|
||||
workspaces = {
|
||||
{
|
||||
name = "personal",
|
||||
path = os.getenv("OBSIDIAN_NOTES_PATH"),
|
||||
return {
|
||||
"stevearc/oil.nvim",
|
||||
dependencies = { { "echasnovski/mini.icons", opts = {} } },
|
||||
config = function()
|
||||
require "custom/oil"
|
||||
end,
|
||||
}
|
||||
```
|
||||
Затем, как можно видеть, сама функция настроек расположена отдельно в файле с идентичным названием, но в директории "повыше":
|
||||
*lua/custom/oil.lua*
|
||||
```lua
|
||||
require("oil").setup{
|
||||
opts = {
|
||||
keymaps = {
|
||||
["g?"] = "actions.show_help",
|
||||
},
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
# File structure
|
||||
## Разница между ftplugin и after/ftplugin
|
||||
Суть одна и та-же: загрузка конфигураций для конкретных типов файлов, однако:
|
||||
### ftplugin
|
||||
Тут храняться настройки, которые будут применены **до** загразуки плагинов. Т.е. настройки, что определны где-то в настройках плагинов будут переписывать если что те, которые установлены для типов файлов тут
|
||||
### after/ftplugin
|
||||
Настройки для типов файлов тут будут применены уже после того, как загрузится все содержимое neovim => эти настройки будут перегружать все то, что было настроено в плагинах
|
||||
## Включение / Выключение некоторых плагинов
|
||||
Из за возникновения случаев, когда некоторые плагины на некоторых машинах не нужно включать (например obsidian мне нужен только на хостовых машинах, на удаленных он будет только мешать открывать .md файлы), то в `init.lua` у меня в самом начале устанавливаются для таких плагинов глобальные переменные со следующей семантикой:
|
||||
```
|
||||
.
|
||||
├── Dockerfile
|
||||
├── README.md
|
||||
├── init.lua
|
||||
└── lua
|
||||
└── t0xa
|
||||
├── core
|
||||
│ └── options.lua
|
||||
└── plugins
|
||||
└── lazy.lua
|
||||
vim.g.<plugin_name>_enabled = <type:bool>
|
||||
```
|
||||
Например:
|
||||
```lua
|
||||
vim.g.obsidian_enabled = false
|
||||
```
|
||||
Это позволяет динамически включать/выключать плагины без необходимости усложнять конфиг `lazy`
|
||||
# FAQ
|
||||
> Зачем так мучаться? Не проще все кидать в один файл?
|
||||
|
||||
Проще, но такое распараллеливание позволяет легче дебажить файлы настроек. Т.е. исправляя настройки мы можем просто `source`ить файл настроек, не трогая конфигурации скачивания файлов, чтобы лишний раз не триггерить Lazy.
|
||||
|
||||
> Что делать, если в `checkhealth` выдается ошибка `luarocks not found`?
|
||||
|
||||
Необходимо его установить по инструкции с [сайта](https://luarocks.org/)
|
||||
|
||||
> Что делать, если при установке `luarocks` выдает ошибку что не найдены `.h` файлы?
|
||||
|
||||
Надо установить хэдеры lua командой:
|
||||
```bash
|
||||
sudo apt install liblua5.3-dev
|
||||
```
|
||||
|
||||
## init.lua
|
||||
Файл, в который "смотрит" neovim при [старте](https://neovim.io/doc/user/starting.html#initialization).
|
||||
|
||||
## t0xa
|
||||
Вместо того, чтобы использовать обращение к файлам настройки напрямую - используется данная
|
||||
папка.
|
||||
Можно обходиться без нее, однако для избегания конфликтов нейминга решил что буду использовать
|
||||
так.
|
||||
## core
|
||||
Тут хранятся базовые настройки для neovim
|
||||
## plugins
|
||||
Папка для хранения и настроек плагинов для neovim
|
||||
|
||||
# Команда для запуска контейнеров
|
||||
> checkhealth не может найти tree-sitter cli
|
||||
|
||||
Надо установить соответствующий `npm` пакет:
|
||||
```js
|
||||
npm install -g tree-sitter-cli
|
||||
```
|
||||
docker build -t nvim:nvim . && docker run -it --user nvim_playground nvim:nvim
|
||||
```
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
return {
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
dependencies = "nvim-tree/nvim-web-devicons",
|
||||
config = function()
|
||||
local nvimtree = require("nvim-tree")
|
||||
-- recommended settings from nvim-tree documentation
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
nvimtree.setup({
|
||||
view = {
|
||||
-- width = 35,
|
||||
adaptive_size = true,
|
||||
relativenumber = true,
|
||||
},
|
||||
-- disable window_picker for explorer to work well with window splits
|
||||
actions = {
|
||||
open_file = {
|
||||
window_picker = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- Custom list of vim regex for names that will not be shown
|
||||
filters = {
|
||||
custom = { ".DS_Store" },
|
||||
},
|
||||
-- Show files ignored by git
|
||||
git = {
|
||||
ignore = false,
|
||||
},
|
||||
})
|
||||
|
||||
-- set nvim-tree keypmaps
|
||||
local keymap = vim.keymap
|
||||
keymap.set('n', '<leader>nt', ':NvimTreeToggle<CR>', {desc = "Toggle file explorer"})
|
||||
keymap.set('n', '<leader>nf', ':NvimTreeFindFileToggle<CR>', {desc = "Toggle file explorer on current file"})
|
||||
|
||||
end
|
||||
}
|
0
ftplugin/go.lua
Normal file
0
ftplugin/go.lua
Normal file
44
init.lua
44
init.lua
|
@ -1,4 +1,40 @@
|
|||
-- Omitting `lua` directory, because neovim autmaticaly serching in it
|
||||
require("t0xa.core.options")
|
||||
require("t0xa.core.keybindings")
|
||||
require("t0xa.lazy")
|
||||
-- Global settings params
|
||||
--- Option to enable/disalbe obsidian plugin
|
||||
vim.g.obsidian_enabled = false
|
||||
|
||||
-- Making leader (<Leader>) key to space
|
||||
vim.g.mapleader = "\\"
|
||||
-- Making local leader (<LocalLeader>) key to backslash
|
||||
vim.g.maplocalleader = ""
|
||||
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- import your plugins
|
||||
{ import = "custom/plugins" },
|
||||
},
|
||||
-- Configure any other settings here. See the documentation for more details.
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
install = { colorscheme = { "gruvbox-material" } },
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = false },
|
||||
})
|
||||
|
||||
|
|
59
lua/custom/README.md
Normal file
59
lua/custom/README.md
Normal file
|
@ -0,0 +1,59 @@
|
|||
# Справка по интересным моментам в коде
|
||||
## Функция получения версии `python` в `lsp.lua`
|
||||
|
||||
```lua
|
||||
local function get_python_version()
|
||||
local handle = io.popen("python --version 2>&1") -- Redirect stderr to stdout
|
||||
if handle then
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
-- Check if the output contains a version number
|
||||
local version = result:match("Python (%d+%.%d+%.%d+)")
|
||||
if version then
|
||||
return version
|
||||
end
|
||||
end
|
||||
|
||||
handle = io.popen("python3 --version 2>&1") -- Redirect stderr to stdout
|
||||
if handle then
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
-- Check if the output contains a version number
|
||||
local version = result:match("Python (%d+%.%d+%.%d+)")
|
||||
if version then
|
||||
return version
|
||||
end
|
||||
end
|
||||
-- TODO: Add some exception handling if python not installed on user machine
|
||||
return "Python 0.0.0"
|
||||
end
|
||||
```
|
||||
Что тут есть примечательного:
|
||||
- Получение данных, выполняя команду в shell оболочке системы с помощью
|
||||
`io.popen`. *Важно*: Данная функция может работать не во всех ОС
|
||||
- Функция выполняет команду, указанную в аргументе, и возвращает *файловый
|
||||
дескриптор*, который можно использовать для чтения вывода команды (или
|
||||
записи в нее)
|
||||
|
||||
Разберем флоу подробнее:
|
||||
Если про `python --version` - все понятно, то вот:
|
||||
```lua
|
||||
2>&1
|
||||
```
|
||||
Уже надо прояснить:
|
||||
- В UNIX-подобных системах есть три стандартных потока - `stdin` = 0; `stdout` = 1;
|
||||
`strerr` = 2;
|
||||
- По умолчанию `io.popen` передает только вывод `stdout` в handle, поэтому для обработки
|
||||
ошибок, надо дополнительно захватывать поток `stderr`
|
||||
- `2>&1` означает, что мы хотим перенаправить поток ошибок 2 в стандартный вывод 1;
|
||||
- Это нужно для того, чтобы захватить не только вывод команды, но и возможные ошибки
|
||||
(например если питон не установлен);
|
||||
- `>&` - оператор перенаправления потоков.
|
||||
|
||||
Дополнительно:
|
||||
`*a` внутри `read` - конструкция формата чтения файловых объектов в `Lua`. Они
|
||||
указывают - как именно стоит читать данные из файла или потока. Помимо `a` есть
|
||||
еще:
|
||||
- `*a` - читать все содержимое
|
||||
- `*l` - читать строку
|
||||
- `*n` - читать число.
|
9
lua/custom/colorschemes.lua
Normal file
9
lua/custom/colorschemes.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
-- Turn on termguicolors for colorschemes
|
||||
-- (Have to use true color terminal to see theese setting work)
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.background = "dark" -- colorschemes that can be light or dark will be made dark
|
||||
vim.opt.signcolumn = "yes" -- show sigh columns so that text doesn't shift
|
||||
|
||||
vim.g.gruvbox_material_background = 'hard'
|
||||
vim.g.gruvbox_material_enable_italic = true
|
||||
vim.cmd.colorscheme("gruvbox-material")
|
65
lua/custom/completion.lua
Normal file
65
lua/custom/completion.lua
Normal file
|
@ -0,0 +1,65 @@
|
|||
-- Set some settings for competion
|
||||
-- For more info type `:help completeopt`
|
||||
-- menu: Show menu when completions available (more than 1)
|
||||
-- menuone: Show menu even when there is only 1 option
|
||||
-- noselect: Force user to select convinient option
|
||||
|
||||
-- Load luasnip setup
|
||||
require "custom.luasnip"
|
||||
|
||||
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||
|
||||
local lspkind = require "lspkind"
|
||||
|
||||
local kind_formatter = lspkind.cmp_format {
|
||||
mode = "symbol_text",
|
||||
menu = {
|
||||
buffer = "[buf]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[api]",
|
||||
path = "[path]",
|
||||
luasnip = "[snip]",
|
||||
gh_issues = "[issues]",
|
||||
tn = "[TabNine]",
|
||||
eruby = "[erb]",
|
||||
},
|
||||
}
|
||||
|
||||
local cmp = require "cmp"
|
||||
|
||||
cmp.setup {
|
||||
sources = {
|
||||
{ name = "luasnip" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "path" },
|
||||
{ name = "buffer" },
|
||||
},
|
||||
mapping = {
|
||||
["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
|
||||
["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
|
||||
["<C-y>"] = cmp.mapping(
|
||||
cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
},
|
||||
{ "i", "c" }
|
||||
),
|
||||
},
|
||||
|
||||
-- Enable luasnip to handle snippet expansion for nvim-cmp
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.snippet.expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
formatting = {
|
||||
fields = { "abbr", "kind", "menu" },
|
||||
expandable_indicator = true,
|
||||
format = function(entry, vim_item)
|
||||
-- Lspkind setup for icons
|
||||
vim_item = kind_formatter(entry, vim_item)
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
}
|
222
lua/custom/lsp.lua
Normal file
222
lua/custom/lsp.lua
Normal file
|
@ -0,0 +1,222 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
|
||||
local keymap = vim.keymap
|
||||
|
||||
local capabilities = nil
|
||||
if pcall(require, "cmp_nvim_lsp") then
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
end
|
||||
|
||||
|
||||
local servers = {
|
||||
gopls = {
|
||||
settings = {
|
||||
gopls = {
|
||||
hints = {
|
||||
assignVariableTypes = true,
|
||||
compositeLiteralFields = true,
|
||||
compositeLiteralTypes = true,
|
||||
constantValues = true,
|
||||
functionTypeParameters = true,
|
||||
parameterNames = true,
|
||||
rangeVariableTypes = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ruff = {
|
||||
init_options = {
|
||||
settings = {
|
||||
-- Ruff language server settings go here
|
||||
logLevel = "debug",
|
||||
},
|
||||
},
|
||||
},
|
||||
pyright = {
|
||||
settings = {
|
||||
pyright = {
|
||||
-- Using Ruff's import organizer
|
||||
disableOrganizeImports = true,
|
||||
},
|
||||
python = {
|
||||
analysis = {
|
||||
-- Ignore all files for analysis to exclusively use Ruff for linting
|
||||
-- ignore = { "*" },
|
||||
diagnosticMode = "off",
|
||||
-- typeCheckingMode = "off",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
lua_ls = {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
-- make the language server recognize "vim" global
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
clangd = {
|
||||
filetypes = { "c" },
|
||||
cmd = {
|
||||
"clangd",
|
||||
"--offset-encoding=utf-16",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local servers_to_install = vim.tbl_filter(function(key)
|
||||
local t = servers[key]
|
||||
if type(t) == "table" then
|
||||
return not t.manual_install
|
||||
else
|
||||
return t
|
||||
end
|
||||
end, vim.tbl_keys(servers))
|
||||
|
||||
|
||||
|
||||
require("mason").setup()
|
||||
local ensure_installed = {
|
||||
-- Normal settings
|
||||
"stylua",
|
||||
"lua_ls",
|
||||
"gofumpt",
|
||||
"golines",
|
||||
"prettier",
|
||||
}
|
||||
|
||||
local function get_python_version()
|
||||
local handle = io.popen("python --version 2>&1") -- Redirect stderr to stdout
|
||||
if handle then
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
-- Check if the output contains a version number
|
||||
local version = result:match("Python (%d+%.%d+%.%d+)")
|
||||
if version then
|
||||
return version
|
||||
end
|
||||
end
|
||||
|
||||
handle = io.popen("python3 --version 2>&1") -- Redirect stderr to stdout
|
||||
if handle then
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
-- Check if the output contains a version number
|
||||
local version = result:match("Python (%d+%.%d+%.%d+)")
|
||||
if version then
|
||||
return version
|
||||
end
|
||||
end
|
||||
-- TODO: Add some exception handling if python not installed on user machine
|
||||
return "Python 0.0.0"
|
||||
end
|
||||
|
||||
-- Now we need to make things work in Astra
|
||||
-- Main Astra cockblock - low python version, that prevents installation of
|
||||
-- some modules, so in order to prevent mason from whining - disable some
|
||||
-- autoinstall modules depending on currently installed python version
|
||||
-- NOTE: You must install removed dependencies manually
|
||||
local python_version = get_python_version()
|
||||
if python_version == nil then
|
||||
python_version = "Python 3.13"
|
||||
end
|
||||
local _, minor, _ = python_version:match(".*(%d+)%.(%d+)%.(%d+)")
|
||||
if tonumber(minor) < 8 then
|
||||
for i, k in pairs(servers_to_install) do
|
||||
-- Ruff is not supported for python lower than 3.8
|
||||
if k == "ruff" then
|
||||
table.remove(servers_to_install, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.list_extend(ensure_installed, servers_to_install)
|
||||
require("mason-tool-installer").setup { ensure_installed = ensure_installed }
|
||||
|
||||
for name, config in pairs(servers) do
|
||||
if config == true then
|
||||
config = {}
|
||||
end
|
||||
config = vim.tbl_deep_extend("force", {}, {
|
||||
capabilities = capabilities,
|
||||
}, config)
|
||||
|
||||
lspconfig[name].setup(config)
|
||||
end
|
||||
|
||||
-- Here it is used the LSP server attaches to file
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
-- Grouping together autocommands.
|
||||
-- Here we creating new group and calling it "UserLspConfig"
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
-- callback defining logic to execute on the event
|
||||
callback = function(ev)
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf, silent = true }
|
||||
|
||||
-- set keybinds
|
||||
-- show definition, references
|
||||
opts.desc = "Show LSP references"
|
||||
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts)
|
||||
|
||||
-- go to declaration
|
||||
opts.desc = "Go to declaration"
|
||||
keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
|
||||
-- show lsp definitions
|
||||
opts.desc = "Show LSP definitions"
|
||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
|
||||
|
||||
-- show lsp implementations
|
||||
opts.desc = "Show LSP implementations"
|
||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts)
|
||||
|
||||
-- show lsp type definitions
|
||||
opts.desc = "Show LSP type definitions"
|
||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts)
|
||||
|
||||
-- see available code actions, in visual mode will apply to selection
|
||||
opts.desc = "See available code actions"
|
||||
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
|
||||
-- smart rename
|
||||
opts.desc = "Smart rename"
|
||||
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
|
||||
-- show diagnostics for file
|
||||
opts.desc = "Show buffer diagnostics"
|
||||
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts)
|
||||
|
||||
-- show diagnostics for line
|
||||
opts.desc = "Show line diagnostics"
|
||||
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts)
|
||||
|
||||
-- jump to previous diagnostic in buffer
|
||||
opts.desc = "Go to previous diagnostic"
|
||||
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
||||
|
||||
-- jump to next diagnostic in buffer
|
||||
opts.desc = "Go to next diagnostic"
|
||||
keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
||||
|
||||
-- show documentation for what is under cursor
|
||||
opts.desc = "Show documentation for what is under cursor"
|
||||
keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
|
||||
-- mapping to restart lsp if necessary
|
||||
opts.desc = "Restart LSP"
|
||||
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts)
|
||||
|
||||
opts.desc = "Run formatting on current buffer"
|
||||
keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, opts)
|
||||
end,
|
||||
})
|
14
lua/custom/lualine.lua
Normal file
14
lua/custom/lualine.lua
Normal file
|
@ -0,0 +1,14 @@
|
|||
require("lualine").setup({
|
||||
options = {
|
||||
theme = "gruvbox-material",
|
||||
},
|
||||
sections = {
|
||||
lualine_c = {
|
||||
{
|
||||
"filename",
|
||||
file_status = true,
|
||||
path = 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
34
lua/custom/luasnip.lua
Normal file
34
lua/custom/luasnip.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
local ls = require "luasnip"
|
||||
local types = require "luasnip.util.types"
|
||||
|
||||
ls.config.set_config {
|
||||
history = true,
|
||||
updateevents = "TextChanged, TextChangedI",
|
||||
enable_autosnippets = true,
|
||||
store_selection_keys = "<c-s>",
|
||||
}
|
||||
|
||||
vim.keymap.set({ "i", "s" }, "<c-j>", function()
|
||||
if ls.expand_or_jumpable() then
|
||||
ls.expand_or_jump()
|
||||
end
|
||||
end, { silent = true })
|
||||
|
||||
vim.keymap.set({ "i", "s" }, "<c-k>", function()
|
||||
if ls.jumpable() then
|
||||
ls.jump(-1)
|
||||
end
|
||||
end, { silent = true })
|
||||
|
||||
vim.keymap.set({ "i", "s" }, "<c-l>", function()
|
||||
if ls.choice_active() then
|
||||
ls.change_choice(1)
|
||||
end
|
||||
end, { silent = true })
|
||||
|
||||
vim.keymap.set("n", "<leader><leader>s", "<cmd>source ~/.config/nvim/lua/custom/luasnip.lua<CR>")
|
||||
|
||||
-- Load custom snippets
|
||||
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/custom/snippets/*.lua", true)) do
|
||||
loadfile(ft_path)()
|
||||
end
|
7
lua/custom/neogen.lua
Normal file
7
lua/custom/neogen.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
require("neogen").setup {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
local keymap = vim.keymap
|
||||
local opts = { noremap = true, silent = true }
|
||||
keymap.set("n", "<Leader>ids", ":lua require('neogen').generate()<CR>", opts)
|
72
lua/custom/obsidian.lua
Normal file
72
lua/custom/obsidian.lua
Normal file
|
@ -0,0 +1,72 @@
|
|||
require("obsidian").setup {
|
||||
-- Set workspace setting
|
||||
workspaces = {
|
||||
{
|
||||
name = "personal",
|
||||
path = "~/Documents/t0xa_vault",
|
||||
}
|
||||
},
|
||||
-- Disable conceal level to supress varning log message
|
||||
ui = {
|
||||
enable = false
|
||||
},
|
||||
-- Set notes subdir to store new notes
|
||||
notes_subdir = "Unsorted",
|
||||
new_notes_location = "notes_subdir",
|
||||
-- Set template params
|
||||
templates = {
|
||||
folder = "Templates",
|
||||
date_format = "%Y-%m-%d",
|
||||
time_format = "%H:%M",
|
||||
substitutions = {
|
||||
yesterday = function()
|
||||
return os.date("%Y-%m-%d", os.time() - 86400)
|
||||
end
|
||||
}
|
||||
},
|
||||
-- Set behaviour of following links
|
||||
follow_url_func = function(url)
|
||||
-- vim.fn.jobstart({ "open", url }) -- Mac OS
|
||||
vim.fn.jobstart({ "xdg-open", url }) -- linux
|
||||
-- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows
|
||||
-- vim.ui.open(url) -- need Neovim 0.10.0+
|
||||
end,
|
||||
-- Set behaviour for opening images
|
||||
follow_img_func = function(img)
|
||||
-- vim.fn.jobstart { "qlmanage", "-p", img } -- Mac OS quick look preview
|
||||
vim.fn.jobstart({ "xdg-open", url }) -- linux
|
||||
-- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows
|
||||
end,
|
||||
-- Set sorting for creation date
|
||||
sort_by = "created",
|
||||
-- Set attachements new folder
|
||||
attachments = {
|
||||
img_folder = "Media"
|
||||
},
|
||||
-- Disable auto formatter for files
|
||||
disable_frontmatter = true,
|
||||
}
|
||||
|
||||
|
||||
-- Obsidian-related keybinds
|
||||
vim.keymap.set("n", "<leader>oit", "<cmd>ObsidianTemplate<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: insert template" })
|
||||
vim.keymap.set("n", "<leader>oo", "<cmd>ObsidianQuickSwitch<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: open file" })
|
||||
vim.keymap.set("n", "<leader>opi", "<cmd>ObsidianPasteImg<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: paste image" })
|
||||
vim.keymap.set("n", "<leader>or", "<cmd>ObsidianRename<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: rename file" })
|
||||
vim.keymap.set("n", "<leader>oc", "<cmd>ObsidianToggleCheckbox<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: toggle checkbox" })
|
||||
vim.keymap.set("n", "<leader>on", "<cmd>ObsidianNew<CR>", { silent = true, noremap = true, desc = "Obsidian: new file" })
|
||||
vim.keymap.set("n", "<leader>otoc", "<cmd>ObsidianTOC<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: open TOC" })
|
||||
vim.keymap.set("n", "<leader>ofl", "<cmd>ObsidianFollowLink<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: follow link" })
|
||||
vim.keymap.set("n", "<leader>olt", "<cmd>ObsidianTags<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: Get tags list" })
|
||||
vim.keymap.set("n", "<leader>osb", "<cmd>ObsidianBacklinks<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: Show Backlinks" })
|
||||
vim.keymap.set("n", "<leader>osl", "<cmd>ObsidianLinks<CR>",
|
||||
{ silent = true, noremap = true, desc = "Obsidian: Show Links" })
|
27
lua/custom/oil.lua
Normal file
27
lua/custom/oil.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
require("oil").setup {
|
||||
keymaps = {
|
||||
["g?"] = "actions.show_help",
|
||||
["<CR>"] = "actions.select",
|
||||
["<C-s>"] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" },
|
||||
["<C-h>"] = false,
|
||||
["<C-t>"] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" },
|
||||
["<C-p>"] = "actions.preview",
|
||||
["<C-c>"] = "actions.close",
|
||||
["<C-l>"] = false,
|
||||
["-"] = "actions.parent",
|
||||
["_"] = "actions.open_cwd",
|
||||
["`"] = "actions.cd",
|
||||
["~"] = { "actions.cd", opts = { scope = "tab" }, desc = ":tcd to the current oil directory", mode = "n" },
|
||||
["gs"] = "actions.change_sort",
|
||||
["gx"] = "actions.open_external",
|
||||
["g."] = "actions.toggle_hidden",
|
||||
["g\\"] = "actions.toggle_trash",
|
||||
["gr"] = "actions.refresh",
|
||||
},
|
||||
view_options = {
|
||||
show_hidden = true,
|
||||
},
|
||||
-- Open parent directory in current window
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
|
20
lua/custom/plugins/colorschemes.lua
Normal file
20
lua/custom/plugins/colorschemes.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
-- TODO: Need to refactor ways of downloading colorschemes
|
||||
-- Now it is just a hack to download all colorschemes as dependecies
|
||||
return {
|
||||
"folke/tokyonight.nvim",
|
||||
dependencies = {
|
||||
"ellisonleao/gruvbox.nvim",
|
||||
"sainnhe/everforest",
|
||||
"sainnhe/gruvbox-material",
|
||||
"rebelot/kanagawa.nvim",
|
||||
"catppuccin/nvim",
|
||||
"folke/tokyonight.nvim",
|
||||
"luisiacc/gruvbox-baby",
|
||||
},
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
config = function()
|
||||
require "custom/colorschemes"
|
||||
end,
|
||||
}
|
||||
|
20
lua/custom/plugins/completion.lua
Normal file
20
lua/custom/plugins/completion.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter", -- Only load plugin when in INSERT mode
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-buffer", -- source for text in buffer
|
||||
"hrsh7th/cmp-path", -- source for file system paths
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
-- follow latest release.
|
||||
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
|
||||
},
|
||||
"saadparwaiz1/cmp_luasnip", -- for autocompletion
|
||||
"rafamadriz/friendly-snippets", -- useful snippets
|
||||
"onsails/lspkind.nvim", -- vs-code like pictograms
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
config = function()
|
||||
require "custom/completion"
|
||||
end,
|
||||
}
|
35
lua/custom/plugins/lsp.lua
Normal file
35
lua/custom/plugins/lsp.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
{
|
||||
--`lazydev` configures Lua LSP for your Neovim config, runtime and plugins
|
||||
-- used for completion, annotations and signatures of Neovim apis
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua",
|
||||
opts = {
|
||||
library = {
|
||||
-- Load luvit types when the `vim.uv` word is found
|
||||
{ path = "luvit-meta/library", words = { "vim%.uv" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{ "Bilal2453/luvit-meta", lazy = true },
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
|
||||
-- Some enhancements for notifications in bottom-right corner
|
||||
{ "j-hui/fidget.nvim", opts = {} },
|
||||
|
||||
-- Following plugin enables enhancements for diagnostics info
|
||||
-- { "https://git.sr.ht/~whynothugo/lsp_lines.nvim" },
|
||||
|
||||
-- Autoformatting
|
||||
"stevearc/conform.nvim",
|
||||
},
|
||||
config = function()
|
||||
require "custom/lsp"
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -7,8 +7,8 @@ return {
|
|||
lualine.setup({
|
||||
options = {
|
||||
-- theme = "tokyonight",
|
||||
theme = "catppuccin-mocha",
|
||||
-- theme = "gruvbox-material",
|
||||
-- theme = "catppuccin-mocha",
|
||||
theme = "gruvbox-material",
|
||||
},
|
||||
sections = {
|
||||
lualine_c = {
|
||||
|
@ -22,3 +22,4 @@ return {
|
|||
})
|
||||
end,
|
||||
}
|
||||
|
9
lua/custom/plugins/luasnip.lua
Normal file
9
lua/custom/plugins/luasnip.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
return {
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
-- follow latest release.
|
||||
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
|
||||
-- install jsregexp (optional!).
|
||||
build = "make install_jsregexp"
|
||||
}
|
||||
}
|
12
lua/custom/plugins/neogen.lua
Normal file
12
lua/custom/plugins/neogen.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
-- Plugin for generating annotations
|
||||
return {
|
||||
{
|
||||
"danymat/neogen",
|
||||
config = true,
|
||||
-- Uncomment next line if you want to follow only stable versions
|
||||
version = "*",
|
||||
config = function()
|
||||
require "custom/neogen"
|
||||
end,
|
||||
}
|
||||
}
|
16
lua/custom/plugins/obsidian.lua
Normal file
16
lua/custom/plugins/obsidian.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
if vim.g.obsidian_enabled then
|
||||
return {
|
||||
"epwalsh/obsidian.nvim",
|
||||
version = "*",
|
||||
lazy = true,
|
||||
ft = "markdown",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
},
|
||||
config = function()
|
||||
require "custom.obsidian"
|
||||
end
|
||||
}
|
||||
else
|
||||
return {}
|
||||
end
|
8
lua/custom/plugins/oil.lua
Normal file
8
lua/custom/plugins/oil.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
"stevearc/oil.nvim",
|
||||
dependencies = { { "echasnovski/mini.icons", opts = {} } },
|
||||
config = function()
|
||||
require "custom/oil"
|
||||
end,
|
||||
}
|
||||
|
12
lua/custom/plugins/telescope.lua
Normal file
12
lua/custom/plugins/telescope.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
dependencies = {
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"folke/todo-comments.nvim",
|
||||
},
|
||||
config = function()
|
||||
require "custom.telescope"
|
||||
end
|
||||
}
|
|
@ -15,3 +15,4 @@ return {
|
|||
{ "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
|
||||
},
|
||||
}
|
||||
|
8
lua/custom/plugins/todo.lua
Normal file
8
lua/custom/plugins/todo.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
"folke/todo-comments.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
require "custom/todo"
|
||||
end,
|
||||
}
|
14
lua/custom/plugins/treesitter.lua
Normal file
14
lua/custom/plugins/treesitter.lua
Normal file
|
@ -0,0 +1,14 @@
|
|||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
-- open this plugin on two events:
|
||||
-- BufReadPre - open existing file
|
||||
-- BufNewFile - open new file
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
build = ":TSUpdate", -- Run whenever this plugin is installed or updated
|
||||
dependencies = {
|
||||
"windwp/nvim-ts-autotag", -- Auto-closing functionality within treesitter
|
||||
},
|
||||
config = function()
|
||||
require "custom/treesitter"
|
||||
end,
|
||||
}
|
10
lua/custom/plugins/trouble.lua
Normal file
10
lua/custom/plugins/trouble.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
return {
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
opts = {}, -- for default options, refer to the configuration section for custom setup.
|
||||
cmd = "Trouble",
|
||||
config = function()
|
||||
require "custom/trouble"
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -17,3 +17,4 @@ return {
|
|||
-- refer to the configuration section below
|
||||
}
|
||||
}
|
||||
|
20
lua/custom/snippets/README.md
Normal file
20
lua/custom/snippets/README.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Гайд по формированию сниппетов
|
||||
## fmta + f
|
||||
Рассмотрим пример использования `fmta` в сочетании с `f`:
|
||||
```
|
||||
f(function(args) return string.lower(args[1][1]) end, {1})
|
||||
```
|
||||
Тут:
|
||||
- `f`: Это функция LuaSnip, которая позволяет выполнять произвольные преобразования над входными данными.
|
||||
Она принимает два аргумента:
|
||||
- Функцию, которая выполняет преобразование.
|
||||
- Список индексов, указывающих, какие входные данные использовать.
|
||||
|
||||
- `function(args)`: Это функция, которая принимает аргумент args — таблица, содержащая значения, переданные из других узлов (например, i(1), i(2) и т.д.).
|
||||
- `args[1][1]`:
|
||||
- `args[1]` — это первая группа входных данных, переданная в f.
|
||||
- `args[1][1]` — это первое значение из этой группы. Например, если вы используете i(1), то args[1][1] будет содержать текст, введенный пользователем для этого узла.
|
||||
|
||||
- `string.lower(args[1][1])`: `string.lower` — это стандартная функция Lua, которая преобразует строку в нижний регистр.
|
||||
|
||||
- `{1}`: Это список индексов, указывающих, какие входные данные использовать. `{1}` означает, что функция будет использовать значение из первого узла (например, i(1)).
|
9
lua/custom/snippets/lua.lua
Normal file
9
lua/custom/snippets/lua.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
-- Clear snippets collection when souring lua file
|
||||
require("luasnip.session.snippet_collection").clear_snippets "lua"
|
||||
|
||||
local ls = require "luasnip"
|
||||
|
||||
ls.add_snippets("lua", {
|
||||
ls.parser.parse_snippet("expand", "-- this is what was expanded kek"),
|
||||
ls.parser.parse_snippet("pipa", "Pipasik"),
|
||||
})
|
121
lua/custom/snippets/python.lua
Normal file
121
lua/custom/snippets/python.lua
Normal file
|
@ -0,0 +1,121 @@
|
|||
-- Clear snippets collection when souring lua file
|
||||
require("luasnip.session.snippet_collection").clear_snippets "python"
|
||||
|
||||
local ls = require "luasnip"
|
||||
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local c = ls.choice_node
|
||||
local f = ls.function_node
|
||||
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local rep = require("luasnip.extras").rep
|
||||
|
||||
ls.add_snippets("python", {
|
||||
s(
|
||||
{ trig = "ctable", dscr = "Create method or function with test stub" },
|
||||
fmt(
|
||||
[[
|
||||
{} = Table(
|
||||
"{}",
|
||||
metadata_obj,
|
||||
Column("id", Integer, primary_key=True),
|
||||
{}
|
||||
)
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
rep(1),
|
||||
i(0)
|
||||
}
|
||||
)
|
||||
),
|
||||
s({ trig = "cmethod", dscr = "Create method or function with test stub" },
|
||||
fmta(
|
||||
[[
|
||||
def <>():
|
||||
"""<> for performing <>"""
|
||||
pass
|
||||
|
||||
def test_<>_<>():
|
||||
"""Test for checking correct work of <> <>"""
|
||||
assert 1 == 2
|
||||
<>
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
c(2, { t "Function", t "Method" }),
|
||||
i(3),
|
||||
rep(1),
|
||||
f(function(args) return string.lower(args[1][1]) end, { 2 }),
|
||||
rep(1),
|
||||
f(function(args) return string.lower(args[1][1]) end, { 2 }),
|
||||
i(0)
|
||||
}
|
||||
)
|
||||
),
|
||||
s({ trig = "implog", dscr = "Import necessary logging utils" }, {
|
||||
t({
|
||||
"import logging",
|
||||
"_log = logging.getLogger(__name__)"
|
||||
}
|
||||
)
|
||||
}),
|
||||
s({ trig = "logevent", dscr = "Import necessary logging utils" },
|
||||
fmt(
|
||||
[[
|
||||
_log.{}('{}' * 60))
|
||||
_log.{}({})
|
||||
_log.{}('{}' * 60))
|
||||
]],
|
||||
{
|
||||
c(1, { t "error", t "warning", t "info" }),
|
||||
i(2),
|
||||
rep(1),
|
||||
i(3),
|
||||
rep(1),
|
||||
rep(2)
|
||||
}
|
||||
)
|
||||
),
|
||||
s({ trig = "pybasetest", dscr = "Create test suite boilerplate" },
|
||||
fmt(
|
||||
[[
|
||||
class Test{}:
|
||||
"""Test suite for checking correct work of {} feature"""
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_test(self):
|
||||
"""Fixture for initializing test cases base data"""
|
||||
{}
|
||||
|
||||
{}
|
||||
]],
|
||||
{ i(1), rep(1), i(2), i(0) }
|
||||
)
|
||||
),
|
||||
s({ trig = "rupysection", dscr = "Secion snippet" },
|
||||
fmt(
|
||||
[[
|
||||
##################################### Секция #############################################
|
||||
# Тема: {}
|
||||
##########################################################################################
|
||||
{}
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
)
|
||||
),
|
||||
s({ trig = "pysection", dscr = "Secion snippet" },
|
||||
fmt(
|
||||
[[
|
||||
##################################### Section ############################################
|
||||
# Section topic: {}
|
||||
##########################################################################################
|
||||
{}
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
)
|
||||
),
|
||||
})
|
19
lua/custom/telescope.lua
Normal file
19
lua/custom/telescope.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
require("telescope").setup {
|
||||
defaults = {
|
||||
path_display = { shorten = 4 },
|
||||
},
|
||||
}
|
||||
|
||||
-- Load fzf extension to imporve performance
|
||||
pcall(require("telescope").load_extension, "fzf")
|
||||
|
||||
local builtin = require("telescope.builtin")
|
||||
local keymap = vim.keymap
|
||||
keymap.set("n", "<leader>ff", builtin.find_files, { desc = "FZF: find files in cwd" })
|
||||
keymap.set("n", "<leader>fml", builtin.marks, { desc = "FZF: find marks list" })
|
||||
keymap.set("n", "<leader>fmp", builtin.man_pages, { desc = "FZF: find available man pages" })
|
||||
keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "FZF: find string in cwd" })
|
||||
keymap.set("n", "<leader>fb", builtin.buffers, { desc = "FZF: display opened buffers" })
|
||||
keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "FZF: display help tags" })
|
||||
keymap.set("n", "<leader>ft", "<cmd>TodoTelescope<cr>", { desc = "FZF: display TODO comments" })
|
||||
keymap.set("n", "<leader>fds", builtin.lsp_document_symbols, { desc = "FZF: Document symbols" })
|
12
lua/custom/todo.lua
Normal file
12
lua/custom/todo.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
local todo_comments = require("todo-comments")
|
||||
local keymap = vim.keymap
|
||||
|
||||
keymap.set("n", "]t", function()
|
||||
todo_comments.jump_next()
|
||||
end, { desc = "Next todo comment" })
|
||||
|
||||
keymap.set("n", "[t", function()
|
||||
todo_comments.jump_prev()
|
||||
end, { desc = "Previous todo comment" })
|
||||
|
||||
todo_comments.setup(opts)
|
17
lua/custom/treesitter.lua
Normal file
17
lua/custom/treesitter.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
require 'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = {
|
||||
"python",
|
||||
"lua",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"query",
|
||||
"elixir",
|
||||
"heex",
|
||||
"javascript",
|
||||
"html",
|
||||
"go"
|
||||
},
|
||||
sync_install = false,
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
}
|
28
lua/custom/trouble.lua
Normal file
28
lua/custom/trouble.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
local trouble = require("trouble")
|
||||
|
||||
-- Setup Trouble
|
||||
trouble.setup()
|
||||
|
||||
-- Keybindings
|
||||
vim.keymap.set("n", "<leader>xx", "<cmd>Trouble diagnostics toggle<cr>", { desc = "Diagnostics (Trouble)" })
|
||||
vim.keymap.set("n", "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
|
||||
{ desc = "Buffer Diagnostics (Trouble)" })
|
||||
vim.keymap.set("n", "<leader>cs", "<cmd>Trouble symbols toggle focus=false<cr>", { desc = "Symbols (Trouble)" })
|
||||
vim.keymap.set("n", "<leader>cl", "<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
|
||||
{ desc = "LSP Definitions / references / ... (Trouble)" })
|
||||
vim.keymap.set("n", "<leader>xL", "<cmd>Trouble loclist toggle<cr>", { desc = "Location List (Trouble)" })
|
||||
vim.keymap.set("n", "<leader>xQ", "<cmd>Trouble qflist toggle<cr>", { desc = "Quickfix List (Trouble)" })
|
||||
|
||||
-- Telescope integration
|
||||
-- local actions = require("telescope.actions")
|
||||
local open_with_trouble = require("trouble.sources.telescope").open
|
||||
-- local add_to_trouble = require("trouble.sources.telescope").add
|
||||
|
||||
require("telescope").setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = { ["<c-t>"] = open_with_trouble },
|
||||
n = { ["<c-t>"] = open_with_trouble },
|
||||
},
|
||||
},
|
||||
})
|
|
@ -1,13 +0,0 @@
|
|||
-- Obsidian-related keybinds
|
||||
vim.keymap.set("n", "<leader>oit", "<cmd>ObsidianTemplate<CR>", { silent = true, noremap = true, desc="Obsidian: insert template" })
|
||||
vim.keymap.set("n", "<leader>oo", "<cmd>ObsidianQuickSwitch<CR>", { silent = true, noremap = true, desc="Obsidian: open file" })
|
||||
vim.keymap.set("n", "<leader>opi", "<cmd>ObsidianPasteImg<CR>", { silent = true, noremap = true, desc="Obsidian: paste image" })
|
||||
vim.keymap.set("n", "<leader>or", "<cmd>ObsidianRename<CR>", { silent = true, noremap = true, desc="Obsidian: rename file" })
|
||||
vim.keymap.set("n", "<leader>ol", "<cmd>ObsidianToggleCheckbox<CR>", { silent = true, noremap = true, desc="Obsidian: toggle checkbox" })
|
||||
vim.keymap.set("n", "<leader>on", "<cmd>ObsidianNew<CR>", { silent = true, noremap = true, desc="Obsidian: new file" })
|
||||
vim.keymap.set("n", "<leader>otoc", "<cmd>ObsidianTOC<CR>", { silent = true, noremap = true, desc="Obsidian: open TOC" })
|
||||
vim.keymap.set("n", "<leader>ofl", "<cmd>ObsidianFollowLink<CR>", { silent = true, noremap = true, desc="Obsidian: follow link" })
|
||||
-- Oil keybinds
|
||||
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
|
||||
-- Easy escape from terminal
|
||||
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")
|
|
@ -1,51 +0,0 @@
|
|||
local opt = vim.opt -- Shorcut to scip writing vim.opt.* in settings beneath
|
||||
|
||||
-- enable line number and relative line number
|
||||
opt.number = true -- This will show the line number cursor is currently standing
|
||||
opt.relativenumber = true -- This will enable relative numbers on the left side
|
||||
|
||||
-- tabs & indentation
|
||||
opt.shiftwidth = 2 -- Set spaces for tabs == 2
|
||||
opt.tabstop = 2 -- Set spaces for indent with == 2
|
||||
opt.expandtab = true -- use number of spaces to insert a <Tab>
|
||||
opt.softtabstop = 2
|
||||
|
||||
-- search settings
|
||||
opt.ignorecase = true -- ignore case when searching
|
||||
opt.smartcase = true -- If mixing cases while searching = you want case-sensitive search
|
||||
|
||||
-- Cursor line setting
|
||||
opt.cursorline = true
|
||||
|
||||
-- Turn on termguicolors for colorschemes
|
||||
-- (Have to use true color terminal to see theese setting work)
|
||||
opt.termguicolors = true
|
||||
opt.background = "dark" -- colorschemes that can be light or dark will be made dark
|
||||
opt.signcolumn = "yes" -- show sigh columns so that text doesn't shift
|
||||
|
||||
-- backspace setting
|
||||
opt.backspace = "indent,eol,start" -- allow backspace on indent, end of line or insert mode start position
|
||||
|
||||
-- clipboard
|
||||
opt.clipboard:append("unnamedplus") -- config to set up clipboard as default register
|
||||
|
||||
-- split windows settings
|
||||
opt.splitright = true -- split vertical window to the right
|
||||
opt.splitbelow = true -- split horizontal window to the bottom
|
||||
|
||||
-- disable swap files creation
|
||||
opt.swapfile = false
|
||||
|
||||
-- Add line at 88 symbols
|
||||
opt.colorcolumn = "120"
|
||||
|
||||
-- Obsidian setting fot concealing charachters
|
||||
opt.conceallevel = 0
|
||||
|
||||
-- Enbale folding column
|
||||
opt.foldmethod = "indent"
|
||||
opt.foldcolumn = "1"
|
||||
opt.foldlevelstart = 10
|
||||
|
||||
-- Live buffer editing
|
||||
opt.inccommand = "split"
|
|
@ -1,22 +0,0 @@
|
|||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or 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)
|
||||
|
||||
-- Initializing `lazy` lib and
|
||||
require("lazy").setup({
|
||||
{
|
||||
import = "t0xa.plugins",
|
||||
},
|
||||
{
|
||||
import = "t0xa.plugins.lsp",
|
||||
},
|
||||
})
|
|
@ -1,31 +0,0 @@
|
|||
return {
|
||||
"windwp/nvim-autopairs",
|
||||
event = { "InsertEnter" },
|
||||
dependencies = {
|
||||
"hrsh7th/nvim-cmp",
|
||||
},
|
||||
config = function()
|
||||
-- import nvim-autopairs
|
||||
local autopairs = require("nvim-autopairs")
|
||||
|
||||
-- configure autopairs
|
||||
autopairs.setup({
|
||||
check_ts = true, -- enable treesitter
|
||||
ts_config = {
|
||||
lua = { "string" }, -- don't add pairs in lua string treesitter nodes
|
||||
javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes
|
||||
java = false, -- don't check treesitter on java
|
||||
},
|
||||
})
|
||||
|
||||
-- import nvim-autopairs completion functionality
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
|
||||
-- import nvim-cmp plugin (completions plugin)
|
||||
local cmp = require("cmp")
|
||||
|
||||
-- make autopairs and completion work together
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
return {
|
||||
"FabijanZulj/blame.nvim",
|
||||
config = function()
|
||||
require("blame").setup()
|
||||
end
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
return {
|
||||
"folke/tokyonight.nvim",
|
||||
dependencies = {
|
||||
"ellisonleao/gruvbox.nvim",
|
||||
-- "morphez/gruvbox.nvim",
|
||||
"sainnhe/everforest",
|
||||
"sainnhe/gruvbox-material",
|
||||
"rebelot/kanagawa.nvim",
|
||||
"catppuccin/nvim",
|
||||
"folke/tokyonight.nvim",
|
||||
"luisiacc/gruvbox-baby",
|
||||
},
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
config = function()
|
||||
-- vim.cmd.colorscheme("tokyonight-night")
|
||||
-- vim.cmd.colorscheme("gruvbox")
|
||||
-- vim.cmd.colorscheme("gruvbox-baby")
|
||||
-- vim.g.gruvbox_material_background = 'hard'
|
||||
-- vim.g.gruvbox_material_enable_italic = true
|
||||
-- vim.cmd.colorscheme("gruvbox-material")
|
||||
vim.cmd.colorscheme("catppuccin-mocha")
|
||||
end,
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
return {
|
||||
"numToStr/Comment.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
"JoosepAlviste/nvim-ts-context-commentstring",
|
||||
},
|
||||
config = function()
|
||||
-- import comment plugin safely
|
||||
local comment = require("Comment")
|
||||
|
||||
local ts_context_commentstring = require("ts_context_commentstring.integrations.comment_nvim")
|
||||
|
||||
-- enable comment
|
||||
comment.setup({
|
||||
-- for commenting tsx, jsx, svelte, html files
|
||||
pre_hook = ts_context_commentstring.create_pre_hook(),
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
return {
|
||||
"tpope/vim-dadbod",
|
||||
"kristijanhusak/vim-dadbod-completion",
|
||||
"kristijanhusak/vim-dadbod-ui",
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
-- Some additional QOL impovements like rename imports when file is renamed
|
||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||
-- Improved functionality when working with neovim config
|
||||
{ "folke/neodev.nvim", opts = {} },
|
||||
},
|
||||
config = function()
|
||||
-- import lspconfig plugin
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- import mason_lspconfig plugin
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
|
||||
-- import cmp-nvim-lsp plugin
|
||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||
|
||||
local keymap = vim.keymap -- for conciseness
|
||||
|
||||
-- nvim_create_autocmd - used to execute some logic automaticaly on a specific event
|
||||
-- Here it is used the LSP server attaches to file
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
-- Grouping together autocommands. Here we creating new group and calling it "UserLspConfig"
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
-- callback defining logic to execute on the event
|
||||
callback = function(ev)
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf, silent = true }
|
||||
|
||||
-- set keybinds
|
||||
opts.desc = "Show LSP references"
|
||||
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
|
||||
|
||||
opts.desc = "Go to declaration"
|
||||
keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
|
||||
|
||||
opts.desc = "Show LSP definitions"
|
||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
|
||||
|
||||
opts.desc = "Show LSP implementations"
|
||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
|
||||
|
||||
opts.desc = "Show LSP type definitions"
|
||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
|
||||
|
||||
opts.desc = "See available code actions"
|
||||
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
|
||||
|
||||
opts.desc = "Smart rename"
|
||||
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
|
||||
|
||||
opts.desc = "Show buffer diagnostics"
|
||||
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
|
||||
|
||||
opts.desc = "Show line diagnostics"
|
||||
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
|
||||
|
||||
opts.desc = "Go to previous diagnostic"
|
||||
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
|
||||
|
||||
opts.desc = "Go to next diagnostic"
|
||||
keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
|
||||
|
||||
opts.desc = "Show documentation for what is under cursor"
|
||||
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
|
||||
|
||||
opts.desc = "Restart LSP"
|
||||
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
|
||||
|
||||
opts.desc = "Run formatting on current buffer"
|
||||
keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
-- used to enable autocompletion (assign to every lsp server config)
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
|
||||
mason_lspconfig.setup({
|
||||
-- default handler for installed servers
|
||||
function(server_name)
|
||||
lspconfig[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end,
|
||||
["clangd"] = function()
|
||||
lspconfig["clangd"].setup({
|
||||
filetypes = { "c" },
|
||||
cmd = {
|
||||
"clangd",
|
||||
"--offset-encoding=utf-16",
|
||||
},
|
||||
})
|
||||
end,
|
||||
["lua_ls"] = function()
|
||||
-- configure lua server (with special settings)
|
||||
lspconfig["lua_ls"].setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
-- make the language server recognize "vim" global
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- Ruff setup
|
||||
lspconfig.ruff.setup({
|
||||
init_options = {
|
||||
settings = {
|
||||
-- Ruff language server settings go here
|
||||
logLevel = "debug",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Pyright setup
|
||||
lspconfig.pyright.setup({
|
||||
settings = {
|
||||
pyright = {
|
||||
-- Using Ruff's import organizer
|
||||
disableOrganizeImports = true,
|
||||
},
|
||||
python = {
|
||||
analysis = {
|
||||
-- Ignore all files for analysis to exclusively use Ruff for linting
|
||||
ignore = { "*" },
|
||||
diagnosticMode = "off",
|
||||
typeCheckingMode = "off",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
return {
|
||||
"williamboman/mason.nvim",
|
||||
dependencies = {
|
||||
"williamboman/mason-lspconfig.nvim", -- util for better language servers manipulation
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
},
|
||||
config = function()
|
||||
-- import mason
|
||||
local mason = require("mason")
|
||||
|
||||
-- import mason-lspconfig
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
|
||||
local mason_tool_installer = require("mason-tool-installer")
|
||||
|
||||
-- enable mason and configure icons
|
||||
mason.setup({
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
mason_lspconfig.setup({
|
||||
-- list of servers for mason to install
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"gopls",
|
||||
},
|
||||
})
|
||||
|
||||
mason_tool_installer.setup({
|
||||
ensure_installed = {
|
||||
"golines",
|
||||
"goimports-reviser",
|
||||
"prettier", -- prettier formatter
|
||||
"stylua", -- lua formatter
|
||||
"ruff", -- Python formatter and linter
|
||||
"gofumpt",
|
||||
-- Astra settings for 3.7 Python
|
||||
-- NOTE: On Astra you need to install Ruff as standalone package
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
return {
|
||||
"danymat/neogen",
|
||||
version = "*", -- Follow only stable versions
|
||||
enabled = true,
|
||||
config = function()
|
||||
local neogen = require("neogen")
|
||||
neogen.setup({
|
||||
enabled = true
|
||||
})
|
||||
local keymap = vim.keymap
|
||||
local opts = { noremap = true, silent = true }
|
||||
keymap.set("n", "<Leader>ids", ":lua require('neogen').generate()<CR>", opts)
|
||||
end,
|
||||
-- config = true,
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
return {
|
||||
"nvimtools/none-ls.nvim",
|
||||
dependencies = {
|
||||
"nvimtools/none-ls-extras.nvim",
|
||||
},
|
||||
config = function()
|
||||
local null_ls = require("null-ls")
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.formatting.gofumpt,
|
||||
null_ls.builtins.formatting.goimports_reviser,
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.formatting.golines,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter", -- Only load plugin when in INSERT mode
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-buffer", -- source for text in buffer
|
||||
"hrsh7th/cmp-path", -- source for file system paths
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
-- follow latest release.
|
||||
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
|
||||
},
|
||||
"saadparwaiz1/cmp_luasnip", -- for autocompletion
|
||||
"rafamadriz/friendly-snippets", -- useful snippets
|
||||
"onsails/lspkind.nvim", -- vs-code like pictograms
|
||||
},
|
||||
config = function()
|
||||
-- Load custom snippets from path
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
require("luasnip.loaders.from_vscode").lazy_load({ paths = vim.fn.stdpath("config") .. "/snippets/" })
|
||||
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
local lspkind = require("lspkind")
|
||||
|
||||
-- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
cmp.setup({
|
||||
completion = {
|
||||
completeopt = "menu,menuone,preview,noselect",
|
||||
},
|
||||
snippet = { -- configure how nvim-cmp interacts with snippet engine
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-j>"] = cmp.mapping.select_next_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
-- sources for autocompletion
|
||||
-- !! Priority is important - autocompletion will be ordered from top to bottom
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" }, -- nvim LSP servers
|
||||
{ name = "luasnip" }, -- snippets
|
||||
{ name = "buffer" }, -- text within current buffer
|
||||
{ name = "path" }, -- file system paths
|
||||
}),
|
||||
|
||||
-- configure lspkind for vs-code like pictograms in completion menu
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
maxwidth = 50,
|
||||
ellipsis_char = "...",
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
cmp.setup.filetype({ "sql" }, {
|
||||
sources = {
|
||||
{ name = "vim-dadbod-completion" },
|
||||
{ name = "buffer" }
|
||||
}
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
return {
|
||||
|
||||
}
|
||||
-- return {
|
||||
-- "nvim-tree/nvim-tree.lua",
|
||||
-- dependencies = "nvim-tree/nvim-web-devicons",
|
||||
-- config = function()
|
||||
-- local nvimtree = require("nvim-tree")
|
||||
-- -- recommended settings from nvim-tree documentation
|
||||
-- vim.g.loaded_netrw = 1
|
||||
-- vim.g.loaded_netrwPlugin = 1
|
||||
--
|
||||
-- nvimtree.setup({
|
||||
-- view = {
|
||||
-- -- width = 35,
|
||||
-- adaptive_size = true,
|
||||
-- relativenumber = true,
|
||||
-- },
|
||||
-- -- disable window_picker for explorer to work well with window splits
|
||||
-- actions = {
|
||||
-- open_file = {
|
||||
-- window_picker = {
|
||||
-- enable = true,
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- -- Custom list of vim regex for names that will not be shown
|
||||
-- filters = {
|
||||
-- custom = { ".DS_Store" },
|
||||
-- },
|
||||
-- -- Show files ignored by git
|
||||
-- git = {
|
||||
-- ignore = false,
|
||||
-- },
|
||||
-- })
|
||||
--
|
||||
-- -- set nvim-tree keypmaps
|
||||
-- local keymap = vim.keymap
|
||||
-- keymap.set('n', '<leader>nt', ':NvimTreeToggle<CR>', {desc = "Toggle file explorer"})
|
||||
-- keymap.set('n', '<leader>nf', ':NvimTreeFindFileToggle<CR>', {desc = "Toggle file explorer on current file"})
|
||||
--
|
||||
-- end
|
||||
-- }
|
|
@ -1,32 +0,0 @@
|
|||
return {
|
||||
"epwalsh/obsidian.nvim",
|
||||
version = "*", -- recommended, use latest release instead of latest commit
|
||||
lazy = true,
|
||||
ft = "markdown",
|
||||
dependencies = {
|
||||
-- Required.
|
||||
"nvim-lua/plenary.nvim",
|
||||
},
|
||||
opts = {
|
||||
workspaces = {
|
||||
{
|
||||
name = "personal",
|
||||
path = os.getenv("OBSIDIAN_NOTES_PATH"),
|
||||
},
|
||||
},
|
||||
templates = {
|
||||
folder = "Templates",
|
||||
date_format = "%d.%m.%Y",
|
||||
time_format = "%H:%M",
|
||||
},
|
||||
-- disable adding properties on top of file on save
|
||||
disable_frontmatter = true,
|
||||
ui = {
|
||||
enable = false
|
||||
},
|
||||
follow_url_func = function(url)
|
||||
print("Hello from URL")
|
||||
vim.fn.jobstart({ "xdg-open", url })
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
return {
|
||||
"stevearc/oil.nvim",
|
||||
---@module 'oil'
|
||||
---@type oil.SetupOpts
|
||||
opts = {
|
||||
keymaps = {
|
||||
["g?"] = "actions.show_help",
|
||||
["<CR>"] = "actions.select",
|
||||
["<C-s>"] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" },
|
||||
["<C-h>"] = false,
|
||||
["<C-t>"] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" },
|
||||
["<C-p>"] = "actions.preview",
|
||||
["<C-c>"] = "actions.close",
|
||||
["<C-l>"] = false,
|
||||
["-"] = "actions.parent",
|
||||
["_"] = "actions.open_cwd",
|
||||
["`"] = "actions.cd",
|
||||
["~"] = { "actions.cd", opts = { scope = "tab" }, desc = ":tcd to the current oil directory", mode = "n" },
|
||||
["gs"] = "actions.change_sort",
|
||||
["gx"] = "actions.open_external",
|
||||
["g."] = "actions.toggle_hidden",
|
||||
["g\\"] = "actions.toggle_trash",
|
||||
},
|
||||
view_options = {
|
||||
show_hidden = true,
|
||||
},
|
||||
},
|
||||
-- Optional dependencies
|
||||
dependencies = { { "echasnovski/mini.icons", opts = {} } },
|
||||
-- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
return {
|
||||
"nvim-lua/plenary.nvim"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
return {
|
||||
"simrat39/rust-tools.nvim",
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.6",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
-- Improving performance of finder
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
|
||||
-- Display dev icons
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"folke/todo-comments.nvim",
|
||||
},
|
||||
config = function()
|
||||
local telescope = require("telescope")
|
||||
local actions = require("telescope.actions")
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
path_display = { "smart" },
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-k>"] = actions.move_selection_previous, -- move to prev result
|
||||
["<C-j>"] = actions.move_selection_next, -- move to next result
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
telescope.load_extension("fzf") -- load FZF extension to improve performance
|
||||
|
||||
local builtin = require("telescope.builtin")
|
||||
local keymap = vim.keymap
|
||||
keymap.set("n", "<leader>ff", builtin.find_files, { desc = "FZF: find files in cwd" })
|
||||
keymap.set("n", "<leader>fml", builtin.marks, { desc = "FZF: find marks list" })
|
||||
keymap.set("n", "<leader>fmp", builtin.man_pages, { desc = "FZF: find available man pages" })
|
||||
keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "FZF: find string in cwd" })
|
||||
keymap.set("n", "<leader>fb", builtin.buffers, { desc = "FZF: display opened buffers" })
|
||||
keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "FZF: display help tags" })
|
||||
keymap.set("n", "<leader>ft", "<cmd>TodoTelescope<cr>", { desc = "FZF: display TODO comments" })
|
||||
keymap.set("n", "<leader>fds", builtin.lsp_document_symbols, { desc = "FZF: Document symbols" })
|
||||
keymap.set("n", "<leader>fr", builtin.resume, { desc = "Redo previous search" })
|
||||
end,
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
return {
|
||||
"folke/todo-comments.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local todo_comments = require("todo-comments")
|
||||
|
||||
-- set keymaps
|
||||
local keymap = vim.keymap -- for conciseness
|
||||
|
||||
keymap.set("n", "]t", function()
|
||||
todo_comments.jump_next()
|
||||
end, { desc = "Next todo comment" })
|
||||
|
||||
keymap.set("n", "[t", function()
|
||||
todo_comments.jump_prev()
|
||||
end, { desc = "Previous todo comment" })
|
||||
|
||||
todo_comments.setup()
|
||||
end,
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
-- open this plugin on two events:
|
||||
-- BufReadPre - open existing file
|
||||
-- BufNewFile - open new file
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
build = ":TSUpdate", -- Run whenever this plugin is installed or updated
|
||||
dependencies = {
|
||||
"windwp/nvim-ts-autotag", -- Auto-closing functionality within treesitter
|
||||
},
|
||||
config = function()
|
||||
-- import nvim-treesitter plugin
|
||||
local treesitter = require("nvim-treesitter.configs")
|
||||
|
||||
-- Configure treesitter
|
||||
-- treesitter.setup({
|
||||
-- -- enable syntax highlighting
|
||||
-- highligh = {
|
||||
-- enable = true,
|
||||
-- },
|
||||
--
|
||||
-- -- enable better indentation
|
||||
-- indent = {
|
||||
-- enable = true,
|
||||
-- },
|
||||
--
|
||||
-- -- enable auto-tagging
|
||||
-- autotag = {
|
||||
-- enable = true,
|
||||
-- },
|
||||
--
|
||||
-- -- ensure these languages parsers are installed
|
||||
-- ensure_installed = {
|
||||
-- "python",
|
||||
-- "go",
|
||||
-- "lua",
|
||||
-- "bash",
|
||||
-- "json",
|
||||
-- "javascript",
|
||||
-- "jq",
|
||||
-- "markdown",
|
||||
-- "markdown_inline",
|
||||
-- "regex",
|
||||
-- "vim",
|
||||
-- "dockerfile",
|
||||
-- },
|
||||
-- })
|
||||
-- end,
|
||||
treesitter.setup({
|
||||
ensure_installed = {
|
||||
"python",
|
||||
"lua",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"query",
|
||||
"elixir",
|
||||
"heex",
|
||||
"javascript",
|
||||
"html",
|
||||
},
|
||||
sync_install = false,
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
return {
|
||||
"folke/trouble.nvim",
|
||||
opts = {}, -- for default options, refer to the configuration section for custom setup.
|
||||
cmd = "Trouble",
|
||||
keys = {
|
||||
{
|
||||
"<leader>xx",
|
||||
"<cmd>Trouble diagnostics toggle<cr>",
|
||||
desc = "Diagnostics (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>xX",
|
||||
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
|
||||
desc = "Buffer Diagnostics (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>cs",
|
||||
"<cmd>Trouble symbols toggle focus=false<cr>",
|
||||
desc = "Symbols (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>cl",
|
||||
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
|
||||
desc = "LSP Definitions / references / ... (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>xL",
|
||||
"<cmd>Trouble loclist toggle<cr>",
|
||||
desc = "Location List (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>xQ",
|
||||
"<cmd>Trouble qflist toggle<cr>",
|
||||
desc = "Quickfix List (Trouble)",
|
||||
},
|
||||
},
|
||||
}
|
1
main.py
Normal file
1
main.py
Normal file
|
@ -0,0 +1 @@
|
|||
|
15
plugin/keymaps.lua
Normal file
15
plugin/keymaps.lua
Normal file
|
@ -0,0 +1,15 @@
|
|||
local set = vim.keymap.set
|
||||
|
||||
-- Basic movement keybinds, these make navigating splits easy for me
|
||||
-- set("n", "<c-j>", "<c-w><c-j>")
|
||||
-- set("n", "<c-k>", "<c-w><c-k>")
|
||||
-- set("n", "<c-l>", "<c-w><c-l>")
|
||||
-- set("n", "<c-h>", "<c-w><c-h>")
|
||||
|
||||
-- Bindings for reloading LUA files (used when working with lua files)
|
||||
-- set("n", "<leader>x", "<cmd>.lua<CR>", { desc = "Execute the current lne" })
|
||||
set("n", "<leader><leader>x", "<cmd>source %<CR>", { desc = "Execute the current file" })
|
||||
|
||||
-- Following section purprose is to rebind some Russian missing binds
|
||||
-- TODO: Maybe there is more clean and percise way, dunno right now
|
||||
set("i", "<C-ц>", "<C-W>")
|
29
plugin/options.lua
Normal file
29
plugin/options.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
local opt = vim.opt
|
||||
|
||||
-- Command to show inline what are you trying to perform
|
||||
opt.inccommand = "split"
|
||||
|
||||
-- Search settings to toggle "smart case" search only if 1+ uppercase char
|
||||
-- persist in search line
|
||||
opt.smartcase = true
|
||||
opt.ignorecase = true
|
||||
|
||||
-- Enable line numbers and relative setting
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
|
||||
-- Tabulation and indentation settings
|
||||
opt.shiftwidth = 2 -- Set spaces for tabs == 2
|
||||
opt.tabstop = 2 -- Set spaces for indent with == 2
|
||||
opt.expandtab = true -- use number of spaces to insert a <Tab>
|
||||
opt.softtabstop = 2
|
||||
|
||||
-- Disable swap files creation
|
||||
opt.swapfile = false
|
||||
|
||||
-- Add line at 80 symbols
|
||||
opt.colorcolumn = "99"
|
||||
|
||||
-- config to set up clipboard as default register
|
||||
opt.clipboard:append("unnamedplus")
|
||||
|
3
plugin/providers.lua
Normal file
3
plugin/providers.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
-- Disable unneccesary providers
|
||||
vim.g.loaded_ruby_provider = 0
|
||||
vim.g.loaded_perl_provider = 0
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"for statement": {
|
||||
"prefix": "for",
|
||||
"body": "for ${1:i} := 0; $1 < ${2:count}; $1${3:++} {\n\t$0\n}",
|
||||
"description": "Snippet for a for loop"
|
||||
},
|
||||
"for range statement": {
|
||||
"prefix": "forrrrrr",
|
||||
"body": "for ${1:_, }${2:var} := range ${3:var} {\n\t$0\n}",
|
||||
"description": "Snippet for a for range loop"
|
||||
},
|
||||
"if err != nil": {
|
||||
"prefix": "iferr",
|
||||
"body": "if err != nil {\n\t${1:return ${2:nil, }${3:err}}\n}",
|
||||
"description": "Snippet for if err != nil"
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"name": "custom-snippets",
|
||||
"engines": {
|
||||
"vscode": "^1.11.0"
|
||||
},
|
||||
"contributes": {
|
||||
"snippets": [
|
||||
{
|
||||
"language": "python",
|
||||
"path": "./python.json"
|
||||
},
|
||||
{
|
||||
"language": "go",
|
||||
"path": "./go.json"
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
"implog": {
|
||||
"prefix": "implog",
|
||||
"body": [
|
||||
"import logging",
|
||||
"_log = logging.getLogger(__name__)"
|
||||
],
|
||||
"description": "Snippet for importing logger"
|
||||
},
|
||||
"Log event": {
|
||||
"prefix": "logevent",
|
||||
"body": [
|
||||
"_log.error('${1:delimiter}' * 60)",
|
||||
"_log.error(${2})",
|
||||
"_log.error('${1:delimiter}' * 60)"
|
||||
],
|
||||
"description": "Snippet for inserting error log"
|
||||
},
|
||||
"Log debug": {
|
||||
"prefix": "logdebug",
|
||||
"body": [
|
||||
"_log.debug(${1:deug_body})"
|
||||
],
|
||||
"description": "Snippet for inserting debug log"
|
||||
},
|
||||
"tryexcept": {
|
||||
"prefix": "tryexe",
|
||||
"body": [
|
||||
"try:",
|
||||
" print(x)",
|
||||
"except ${1:exception}:",
|
||||
" print('An exception occurred')"
|
||||
],
|
||||
"description": "tryexcept method"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue