This commit is contained in:
2023-07-11 10:41:59 +03:00
commit d14a10c8a7
47 changed files with 2297 additions and 0 deletions

View File

@@ -0,0 +1 @@
require('axp')

View File

@@ -0,0 +1,47 @@
-- Encoding.
vim.o.encoding = 'utf-8'
vim.o.fileencoding = 'utf-8'
vim.o.backup = false
vim.o.swapfile = false
-- Lines.
vim.o.number = true
vim.o.relativenumber = true
vim.o.colorcolumn = '79'
vim.o.signcolumn = 'yes'
-- Tabs.
vim.o.tabstop = 2
vim.o.shiftwidth = 2
-- vim.o.expandtab = true
-- Etc.
vim.o.guicursor = ''
vim.o.clipboard = 'unnamedplus'
-- View.
vim.g.mapleader = ' '
vim.g.netrw_liststyle = 3
vim.o.list = true
vim.opt.listchars:append 'space:⋅'
-- vim.opt.listchars:append 'eol:↴'
-- vim.opt.listchars:append 'tab:>-'
-- Mappings tabs.
vim.keymap.set('n', '<C-h>', ':-tabmove<CR>')
vim.keymap.set('n', '<C-l>', ':+tabmove<CR>')
-- Mappings buffers.
vim.keymap.set('n', '<leader>k', ':bn<CR>')
vim.keymap.set('n', '<leader>j', ':bp<CR>')
-- Move cursour vertical.
vim.keymap.set('n', '<C-d>', '<C-d>zz')
vim.keymap.set('n', '<C-u>', '<C-u>zz')
-- Diagnostic keymaps.
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" })

View File

@@ -0,0 +1,2 @@
require('axp.base')
require('axp.manager.packer')

View File

@@ -0,0 +1,54 @@
-- Download packer.
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
print('Download packer...')
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
-- Bootstrap packer.
local packer_bootstrap = ensure_packer()
-- Chek packer.
local status, packer = pcall(require, 'packer')
if (not status) then
print('Oops. Packer is not installed!')
return
end
-- Init packer.
packer.init({
display = {
open_fn = function()
return require('packer.util').float({ border = 'single' })
end
}
})
-- Plugins.
local plugins = require('axp.plugins')
-- Startup packer.
packer.startup(function(use)
use 'wbthomason/packer.nvim'
-- Use pludins.
for _, plugin in ipairs(plugins.list) do
use(plugin)
end
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
print('Packer sync...')
require('packer').sync()
end
end)
-- Init plugins.
plugins.init()

View File

@@ -0,0 +1,2 @@
local status, autopairs = pcall(require, 'nvim-autopairs')
if status then autopairs.setup {} end

View File

@@ -0,0 +1,10 @@
local status, blankline = pcall(require, 'indent_blankline')
if (not status) then return end
blankline.setup {
char = '',
show_trailing_blankline_indent = false,
-- for example, context is off by default, use this to turn it on
-- show_current_context = true,
-- show_current_context_start = true,
}

View File

@@ -0,0 +1,2 @@
local status, comment = pcall(require, 'Comment')
if (status) then comment.setup {} end

View File

@@ -0,0 +1,55 @@
local M = {}
M.list = {
-- Common.
'nvim-lua/plenary.nvim',
-- Etc.
'nvim-treesitter/nvim-treesitter',
'nvim-telescope/telescope.nvim',
'windwp/nvim-autopairs',
'numToStr/Comment.nvim',
-- View.
'EdenEast/nightfox.nvim',
'lukas-reineke/indent-blankline.nvim',
-- 'nvim-lualine/lualine.nvim',
-- Lsp.
'neovim/nvim-lspconfig',
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
'hrsh7th/cmp-nvim-lsp',
--- Null-ls.
'jose-elias-alvarez/null-ls.nvim',
-- Autocompletion
'L3MON4D3/LuaSnip',
'hrsh7th/nvim-cmp'
}
M.init = function ()
-- Etc.
require('axp.plugins.autopairs')
require('axp.plugins.comment')
require('axp.plugins.telescope')
require('axp.plugins.treesitter')
-- View.
require('axp.plugins.nightfox')
-- require('axp.plugins.lualine')
require('axp.plugins.blankline')
-- Lsp.
require('axp.plugins.lsp')
-- Null-ls.
require('axp.plugins.null-ls')
-- Autocompletion
require('axp.plugins.luasnip')
require('axp.plugins.nvim-cmp')
end
return M

View File

@@ -0,0 +1,103 @@
-- Check Lspconfig.
local status_lspconfig, lspconfig = pcall(require, 'lspconfig')
if (not status_lspconfig) then return end
-- Check Mason.
local status_mason, mason = pcall(require, 'mason')
if (not status_mason) then return end
-- Check Mason lsp installer.
local status_mason_lspconfig, mason_lspconfig = pcall(require, 'mason-lspconfig')
if (not status_mason_lspconfig) then return end
-- Config servers.
local servers = {
lua_ls = {
Lua = {
diagnostics = {
-- Get the language server to recognize the 'vim' global.
globals = { 'vim' }
},
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
},
bashls = {},
clangd = {},
cmake = {},
tsserver = {},
dockerls = {},
volar = {},
astro = {},
html = {},
cssls = {},
jsonls = {},
pyright = {},
yamlls = {}
}
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr)
-- NOTE: Remember that lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself
-- many times.
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
end
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- Mason.
mason.setup {}
-- Mason lsp installer.
mason_lspconfig.setup {
ensure_installed = vim.tbl_keys(servers),
}
-- Mason configure servers.
mason_lspconfig.setup_handlers {
function(server_name)
lspconfig[server_name].setup {
capabilities = capabilities,
on_attach = on_attach,
settings = servers[server_name],
}
end
}

View File

@@ -0,0 +1,4 @@
local status, lualine = pcall(require, 'lualine')
if (not status) then return end
lualine.setup {}

View File

@@ -0,0 +1,18 @@
local status_luasnip, ls = pcall(require, 'luasnip')
if (not status_luasnip) then return end
-- Init.
ls.config.set_config {}
-- Snippets.
local snippets = require 'axp.plugins.luasnip.snippets'
for name, snippet in pairs(snippets.list) do
ls.add_snippets(name, snippet)
end
-- Keymaps.
vim.keymap.set({ 'i', 's' }, '<C-k>', function()
if ls.expand_or_jumpable() then
ls.expand_or_jump()
end
end, { silent = true })

View File

@@ -0,0 +1,109 @@
local M = {}
M.list = {}
local status_luasnip, ls = pcall(require, 'luasnip')
if (status_luasnip) then
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
-- local c = ls.choice_node
local fmt = require('luasnip.extras.fmt').fmt
local javascript = {
s('import', {
t('import '),
i(2, 'lib'),
t(' from \''),
i(1, 'lib'),
t('\'')
}),
s('try', fmt(
[[
try {{
{}
}} catch (e) {{}}
]],
{
i(1)
}
)),
s('/**', fmt(
[[
/**
* {}
*/
]],
{
i(1)
}
)),
s('const fn', {
t('const '),
i(1, 'fn'),
t(' = '),
i(2, 'async'),
t(' ('),
i(3),
t(') => {'),
i(4),
t('}')
})
}
local vue = {
s('<script', {
t('<script '),
i(1, 'setup'),
t(' lang="'),
i(2, 'ts'),
t('">'),
i(3),
t('</script>')
}),
s('<template', {
t('<template'),
i(1),
t('>'),
i(2),
t('</template>')
}),
s('<style', {
t('<style lang="'),
i(1, 'sass'),
t('">'),
i(2),
t('</style>')
}),
s('const props', {
t('const props = defineProps<{'),
i(1),
t('}>()')
}),
s('const emit', {
t('const emit = defineEmits<{ (e: \''),
i(1, 'update:modelValue'),
t('\', v: '),
i(2, 'any'),
t('): void }>()')
}),
s('onMounted', {
t('onMounted(() => '),
i(1, 'loadData()'),
t(')')
})
}
-- Add javascript in vue.
for number, value in ipairs(javascript) do
vue[6 + number] = value
end
M.list = {
javascript = javascript,
typescript = javascript,
vue = vue
}
end
return M

View File

@@ -0,0 +1,5 @@
local status = pcall(require, 'nightfox')
if status then
vim.cmd [[colorscheme terafox]]
end

View File

@@ -0,0 +1,9 @@
{
"useTabs": true,
"tabWidth": 2,
"singleQuote": true,
"semi": false,
"trailingComma": "none",
"arrowParens": "avoid",
"printWidth": 79
}

View File

@@ -0,0 +1,15 @@
-- Null-ls.
local status_null_ls, null_ls = pcall(require, 'null-ls')
if (not status_null_ls) then return end
-- Config.
local prettier_config = vim.fn.stdpath('config') .. '/lua/axp/plugins/null-ls/.prettierrc'
local formatting = null_ls.builtins.formatting
-- local diagnostics = null_ls.builtins.diagnostics
-- Init.
null_ls.setup {
sources = {
formatting.prettier.with({ extra_args = { "--config", prettier_config } })
}
}

View File

@@ -0,0 +1,27 @@
local status, cmp = pcall(require, 'cmp')
if (not status) then return end
local status_ls, ls = pcall(require, 'luasnip')
cmp.setup {
snippet = {
expand = function(args)
if (status_ls) then
ls.lsp_expand(args.body)
end
end,
},
mapping = cmp.mapping.preset.insert {
['<C-d>'] = cmp.mapping.scroll_docs( -4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}
}

View File

@@ -0,0 +1,31 @@
local status, telescope = pcall(require, 'telescope')
if (not status) then return end
telescope.setup {
defaults = {
file_ignore_patterns = {
'.git',
'node_modules',
'dist',
'static',
'public'
}
}
}
-- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to telescope to change theme, layout, etc.
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })

View File

@@ -0,0 +1,64 @@
local status, ts = pcall(require, 'nvim-treesitter.configs')
if (not status) then return end
ts.setup {
-- A list of parser names, or 'all' (the four listed parsers should always be installed)
ensure_installed = {
'dockerfile',
'lua',
'vim',
'bash',
'javascript',
'typescript',
'json',
'html',
'pug',
'vue',
'css',
'scss',
'python',
'regex',
'markdown',
'yaml',
'astro',
'cmake'
},
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (for 'all')
-- ignore_install = { 'javascript' },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = '/some/path/to/store/parsers', -- Remember to run vim.opt.runtimepath:append('/some/path/to/store/parsers')!
highlight = {
enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
-- disable = { 'c', 'rust' },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
}
}

View File

@@ -0,0 +1,169 @@
-- Automatically generated packer.nvim plugin loader code
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end
vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
_G._packer = _G._packer or {}
_G._packer.inside_compile = true
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
if threshold then
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
end
_G._packer.profile_output = results
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/antoxa/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/antoxa/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/antoxa/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/antoxa/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/antoxa/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
["Comment.nvim"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/Comment.nvim",
url = "https://github.com/numToStr/Comment.nvim"
},
LuaSnip = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/LuaSnip",
url = "https://github.com/L3MON4D3/LuaSnip"
},
["cmp-nvim-lsp"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
},
["indent-blankline.nvim"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim",
url = "https://github.com/lukas-reineke/indent-blankline.nvim"
},
["mason-lspconfig.nvim"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim",
url = "https://github.com/williamboman/mason-lspconfig.nvim"
},
["mason.nvim"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/mason.nvim",
url = "https://github.com/williamboman/mason.nvim"
},
["nightfox.nvim"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/nightfox.nvim",
url = "https://github.com/EdenEast/nightfox.nvim"
},
["null-ls.nvim"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/null-ls.nvim",
url = "https://github.com/jose-elias-alvarez/null-ls.nvim"
},
["nvim-autopairs"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/nvim-autopairs",
url = "https://github.com/windwp/nvim-autopairs"
},
["nvim-cmp"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/nvim-cmp",
url = "https://github.com/hrsh7th/nvim-cmp"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["nvim-treesitter"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["packer.nvim"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["plenary.nvim"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["telescope.nvim"] = {
loaded = true,
path = "/home/antoxa/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
}
}
time([[Defining packer_plugins]], false)
_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then
vim.cmd("doautocmd BufRead")
end
_G._packer.needs_bufread = false
if should_profile then save_profiles() end
end)
if not no_errors then
error_msg = error_msg:gsub('"', '\\"')
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end