initial commit

This commit is contained in:
Andre Schaf 2023-07-13 10:45:16 +02:00
commit 9784dfe498
12 changed files with 329 additions and 0 deletions

7
init.lua Normal file
View file

@ -0,0 +1,7 @@
vim.g.mapleader = " "
require('plugins')
require('lsp')
require('set')
require('remap')

16
lazy-lock.json Normal file
View file

@ -0,0 +1,16 @@
{
"LuaSnip": { "branch": "master", "commit": "a658ae2906344a1d2b9c507738e585cf68e685c7" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"copilot.vim": { "branch": "release", "commit": "a4a6d6b3f9e284e7f5c849619e06cd228cad8abd" },
"gruvbox": { "branch": "master", "commit": "2b5b1f777f0583ffb39086d6c16f39e6e37459c0" },
"lazy.nvim": { "branch": "main", "commit": "5af331ea65418dc9361769891921fdee4bcc837a" },
"lsp-zero.nvim": { "branch": "v2.x", "commit": "7b9627c2cb50906993e194290b2e539c95dfdf47" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "82685fdd0f67a694b244cb058b83761f54664d68" },
"mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" },
"nvim-cmp": { "branch": "main", "commit": "2743dd989e9b932e1b4813a4927d7b84272a14e2" },
"nvim-lspconfig": { "branch": "master", "commit": "a7ecaff3245ba4b9e5ed784ebefbedba54e7f0ad" },
"nvim-treesitter": { "branch": "master", "commit": "e1ab5391e5c4820dd1ffc2566d29b01573ab52a9" },
"plenary.nvim": { "branch": "master", "commit": "102c02903c74b93c705406bf362049383abc87c8" },
"telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" },
"vim-startify": { "branch": "master", "commit": "81e36c352a8deea54df5ec1e2f4348685569bed2" }
}

25
lua/.luarc.json Normal file
View file

@ -0,0 +1,25 @@
{
"workspace.library": [
"/home/arne23/.config/nvim",
"/home/arne23/.local/share/nvim/lazy/lazy.nvim",
"/home/arne23/.local/share/nvim/lazy/gruvbox",
"/home/arne23/.local/share/nvim/lazy/vim-startify",
"/home/arne23/.local/share/nvim/lazy/copilot.vim",
"/home/arne23/.local/share/nvim/lazy/LuaSnip",
"/home/arne23/.local/share/nvim/lazy/cmp-nvim-lsp",
"/home/arne23/.local/share/nvim/lazy/nvim-cmp",
"/home/arne23/.local/share/nvim/lazy/mason-lspconfig.nvim",
"/home/arne23/.local/share/nvim/lazy/mason.nvim",
"/home/arne23/.local/share/nvim/lazy/nvim-lspconfig",
"/home/arne23/.local/share/nvim/lazy/lsp-zero.nvim",
"/home/arne23/.local/share/nvim/lazy/plenary.nvim",
"/home/arne23/.local/share/nvim/lazy/telescope.nvim",
"/home/arne23/.local/share/nvim/lazy/nvim-treesitter",
"/home/linuxbrew/.linuxbrew/Cellar/neovim/0.9.1/share/nvim/runtime",
"/home/linuxbrew/.linuxbrew/Cellar/neovim/0.9.1/share/nvim/runtime/pack/dist/opt/matchit",
"/home/linuxbrew/.linuxbrew/Cellar/neovim/0.9.1/lib/nvim",
"/home/arne23/.local/state/nvim/lazy/readme",
"/home/arne23/.local/share/nvim/lazy/cmp-nvim-lsp/after",
"${3rd}/luassert/library"
]
}

84
lua/lsp.lua Normal file
View file

@ -0,0 +1,84 @@
local lsp = require('lsp-zero').preset({})
local lspconfig = require('lspconfig')
local loaded_configs = require('lspconfig.configs')
local function get_config()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
return {
capabilities = capabilities,
}
end
local function load_custom_configs()
local config_files = vim.split(vim.fn.globpath(vim.fn.stdpath('config') .. '/lua/lspconf', '*.lua', true), '\n')
for _, f in ipairs(config_files) do
local name = vim.fn.fnamemodify(f, ':t:r')
require('lspconf.' .. name)
end
end
local function setup_default_configs()
local available_servers = require('mason-lspconfig').get_installed_servers()
for _, server in pairs(available_servers) do
if not loaded_configs[server] then
local config = get_config()
lspconfig[server].setup(config)
end
end
end
load_custom_configs()
setup_default_configs()
lsp.on_attach(function(_, bufnr)
local opts = { buffer = bufnr, remap = false, }
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end)
lsp.setup()
-- You need to setup `cmp` after lsp-zero
local cmp = require('cmp')
local cmp_action = require('lsp-zero').cmp_action()
cmp.setup({
mapping = {
-- `Enter` key to confirm completion
['<CR>'] = cmp.mapping.confirm({select = false}),
-- Ctrl+Space to trigger completion menu
['<C-Space>'] = cmp.mapping.complete(),
-- Navigate between snippet placeholder
['<C-f>'] = cmp_action.luasnip_jump_forward(),
['<C-b>'] = cmp_action.luasnip_jump_backward(),
}
})
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer

29
lua/lspconf/lua.lua Normal file
View file

@ -0,0 +1,29 @@
local lspconfig = require('lspconfig')
lspconfig.lua_ls.setup {
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {
'vim',
'require',
'opt',
},
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
}

34
lua/lspconf/php.lua Normal file
View file

@ -0,0 +1,34 @@
local lspconfig = require 'lspconfig'
local configs = require 'lspconfig.configs'
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
if not configs.intelephense then
configs.intelephense = {
default_config = {
cmd = { 'intelephense', '--stdio' };
filetypes = { 'php' };
root_dir = function(fname)
return vim.loop.cwd()
end;
settings = {
intelephense = {
files = {
maxSize = 1000000;
};
environment = {
includePaths = {
"/home/serii/Sites/wordpress",
"/home/serii/Sites/advanced-custom-fields-pro",
"/home/serii/Sites/woocommerce"
}
}
}
}
}
}
end
lspconfig.intelephense.setup { capabilities = capabilities }

2
lua/plugin/colors.lua Normal file
View file

@ -0,0 +1,2 @@
vim.cmd.colorscheme('gruvbox')

6
lua/plugin/telescope.lua Normal file
View file

@ -0,0 +1,6 @@
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>jj', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})

View file

@ -0,0 +1,8 @@
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html" },
sync_install = false,
highlight = { enable = true },
indent = { enable = true },
})

61
lua/plugins.lua Normal file
View file

@ -0,0 +1,61 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
'nvim-telescope/telescope.nvim',
tag = '0.1.2',
dependencies = { 'nvim-lua/plenary.nvim' }
},
{
"nvim-treesitter/nvim-treesitter", build = ":TSUpdate"
},
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v2.x',
dependencies = {
-- LSP Support
{ 'neovim/nvim-lspconfig' }, -- Required
{ -- Optional
'williamboman/mason.nvim',
build = function()
pcall(vim.cmd, 'MasonUpdate')
end,
},
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional
-- Autocompletion
{ 'hrsh7th/nvim-cmp' }, -- Required
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
{ 'L3MON4D3/LuaSnip' }, -- Required
{ 'nvim-cmp' },
{ 'github/copilot.vim' },
{ 'mhinz/vim-startify' },
-- themes
{ 'gruvbox-community/gruvbox' },
}
},
}, opts)
local files = vim.split(vim.fn.globpath(vim.fn.stdpath('config') .. '/lua/plugin', '*.lua', true), '\n')
for _, f in ipairs(files) do
local name = vim.fn.fnamemodify(f, ':t:r')
require('plugin.' .. name)
end

24
lua/remap.lua Normal file
View file

@ -0,0 +1,24 @@
vim.keymap.set("n", "<leader>;;", vim.cmd.Ex)
-- jk to escape
vim.keymap.set("i", "jk", "<Esc>")
-- allow moving line / lines in all modes with M-j/k
vim.keymap.set("n", "<M-j>", ":m .+1<CR>==")
vim.keymap.set("n", "<M-k>", ":m .-2<CR>==")
vim.keymap.set("i", "<M-j>", "<Esc>:m .+1<CR>==gi")
vim.keymap.set("i", "<M-k>", "<Esc>:m .-2<CR>==gi")
vim.keymap.set("v", "<M-j>", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "<M-k>", ":m '<-2<CR>gv=gv")
-- C-x to close buffer
vim.keymap.set("n", "<C-x>", ":bd<CR>")
-- C-l / C-h to go to nex / previouse buffer
vim.keymap.set("n", "<C-l>", ":bn<CR>")
vim.keymap.set("n", "<C-h>", ":bp<CR>")
-- leader-t-space 2 to set expandtab, shiftwidth, softtabstop to 2
vim.keymap.set("n", "<leader>t<Space>2", ":set expandtab shiftwidth=2 softtabstop=2<CR>")
vim.keymap.set("n", "<leader>t<Space>4", ":set expandtab shiftwidth=4 softtabstop=4<CR>")
vim.keymap.set("n", "<leader>t<Space><Tab>", ":set noexpandtab shiftwidth=4 softtabstop=4<CR>")

33
lua/set.lua Normal file
View file

@ -0,0 +1,33 @@
vim.opt.guicursor = ""
vim.opt.nu = true
vim.opt.rnu = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.wrap = false
vim.opt.list = true
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.updatetime = 50
-- use system clipboard
vim.opt.clipboard = "unnamedplus"