apllied config

This commit is contained in:
Andre Schaf 2024-01-03 15:39:31 +01:00
parent 5978ec3f28
commit 0874dcd113
15 changed files with 343 additions and 121 deletions

View file

@ -1,18 +1,22 @@
{ {
"LuaSnip": { "branch": "master", "commit": "45a4e899ca8f54936fe32ead6bba65f2a8d42e12" }, "LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"copilot.vim": { "branch": "release", "commit": "a4a6d6b3f9e284e7f5c849619e06cd228cad8abd" }, "conform.nvim": { "branch": "master", "commit": "c4b2efb8aee4af0ef179a9b49ba401de3c4ef5d2" },
"gitsigns.nvim": { "branch": "main", "commit": "5a04466685008f29c71fa5ec25d421deb1c83fea" }, "gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" },
"gruvbox": { "branch": "master", "commit": "2b5b1f777f0583ffb39086d6c16f39e6e37459c0" }, "gruvbox": { "branch": "master", "commit": "e1f033164931797a67b68089995c8078415f9d7d" },
"lazy.nvim": { "branch": "main", "commit": "14d76aac4bd3ff07c1fca074c210f28f766a931e" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lsp-zero.nvim": { "branch": "v2.x", "commit": "0b4c5966884e80c5100c04790defe1fd72d918aa" }, "lazygit.nvim": { "branch": "main", "commit": "1e08e3f5ac1152339690140e61a4a32b3bdc7de5" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "796008869e67ef27a5aa5ac44c08ce2a60b89f55" }, "lsp-zero.nvim": { "branch": "v2.x", "commit": "84771a9ec7f7d1fecec8bb84c0c97d811e4b08ec" },
"mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" },
"nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" }, "mason.nvim": { "branch": "main", "commit": "a09da6ac634926a299dd439da08bdb547a8ca011" },
"nvim-lspconfig": { "branch": "master", "commit": "b88b227cf8d61d6e43dd23d8a39b8b2897bc17e5" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" },
"nvim-treesitter": { "branch": "master", "commit": "a51236f068547487ed34c3a32d9a0b3bf793afa7" }, "nui.nvim": { "branch": "main", "commit": "80445d015d2b5f9af0d9e8bce63d303bc86eda8a" },
"plenary.nvim": { "branch": "master", "commit": "bda256fab0eb66a15e8190937e417e6a14ee5d72" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
"nvim-lspconfig": { "branch": "master", "commit": "ce0e625df61be77abe1340fbc9afe9ad39b31dd8" },
"nvim-treesitter": { "branch": "master", "commit": "3ef514b10b9557e3905b9817ca632e7506dd384a" },
"nvim-web-devicons": { "branch": "master", "commit": "cff25ce621e6d15fae0b0bfe38c00be50ce38468" },
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
"telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" },
"vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" }, "vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" },
"vim-startify": { "branch": "master", "commit": "81e36c352a8deea54df5ec1e2f4348685569bed2" } "vim-startify": { "branch": "master", "commit": "4e089dffdad46f3f5593f34362d530e8fe823dcf" }
} }

View file

@ -1,39 +1,9 @@
local lsp = require('lsp-zero').preset({}) local lsp = require('lsp-zero').preset({})
local lspconfig = require('lspconfig') local lspconfig = require('lspconfig')
local loaded_configs = require('lspconfig.configs') local loaded_configs = require('lspconfig.configs')
local conform = require('conform')
local function get_config() local on_attach = function(_, bufnr)
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, } local opts = { buffer = bufnr, remap = false, }
-- Global mappings. -- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions -- See `:help vim.diagnostic.*` for documentation on any of the below functions
@ -55,11 +25,51 @@ lsp.on_attach(function(_, bufnr)
end, opts) end, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, 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', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function() vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true } vim.lsp.buf.format { async = true }
end, opts) end, opts)
end)
vim.keymap.set('n', '<space>L', ':EslintFixAll<cr>')
vim.keymap.set('n', '<space>F', function()
conform.format()
end, opts)
end
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()
local config = get_config()
for _, server in pairs(available_servers) do
if not loaded_configs[server] then
lspconfig[server].setup(config)
end
end
end
load_custom_configs()
setup_default_configs()
lsp.on_attach(on_attach)
lsp.setup() lsp.setup()
-- You need to setup `cmp` after lsp-zero -- You need to setup `cmp` after lsp-zero
@ -79,6 +89,3 @@ cmp.setup({
['<C-b>'] = cmp_action.luasnip_jump_backward(), ['<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

12
lua/lspconf/angular.lua Normal file
View file

@ -0,0 +1,12 @@
local lspconfig = require 'lspconfig'
lspconfig.angularls.setup({
on_attach = function()
for _, server in ipairs(vim.lsp.buf_get_clients()) do
if server.name == "tsserver" then
local tsserver = vim.lsp.get_client_by_id(server.id)
tsserver.server_capabilities.renameProvider = false
end
end
end
})

92
lua/lspconf/csharp.lua Normal file
View file

@ -0,0 +1,92 @@
local util = require 'lspconfig.util'
local configs = require 'lspconfig.configs'
configs.omnisharp = {
default_config = {
cmd = { "dotnet",
"C:\\Users\\andre.schaf\\.vscode\\extensions\\ms-dotnettools.csharp-2.13.10-win32-x64\\.roslyn\\Microsoft.CodeAnalysis.LanguageServer.dll"
-- "C:\\dev\\tools\\omni\\OmniSharp.Roslyn.dll"
-- "/path/to/omnisharp/OmniSharp.dll" },
},
filetypes = { 'cs' },
root_dir = util.root_pattern('*.sln', '*.csproj', 'omnisharp.json', 'function.json'),
enable_editorconfig_support = true,
-- If true, MSBuild project system will only load projects for files that
-- were opened in the editor. This setting is useful for big C# codebases
-- and allows for faster initialization of code navigation features only
-- for projects that are relevant to code that is being edited. With this
-- setting enabled OmniSharp may load fewer projects and may thus display
-- incomplete reference lists for symbols.
enable_ms_build_load_projects_on_demand = false,
-- Enables support for roslyn analyzers, code fixes and rulesets.
enable_roslyn_analyzers = false,
-- Specifies whether 'using' directives should be grouped and sorted during
-- document formatting.
organize_imports_on_format = false,
-- Enables support for showing unimported types and unimported extension
-- methods in completion lists. When committed, the appropriate using
-- directive will be added at the top of the current file. This option can
-- have a negative impact on initial completion responsiveness,
-- particularly for the first few completion sessions after opening a
-- solution.
enable_import_completion = false,
-- Specifies whether to include preview versions of the .NET SDK when
-- determining which version to use for project loading.
sdk_include_prereleases = true,
-- Only run analyzers against open files when 'enableRoslynAnalyzers' is
-- true
analyze_open_documents_only = false,
on_new_config = function(new_config, _)
-- Get the initially configured value of `cmd`
new_config.cmd = { unpack(new_config.cmd or {}) }
-- Append hard-coded command arguments
table.insert(new_config.cmd, '-z') -- https://github.com/OmniSharp/omnisharp-vscode/pull/4300
vim.list_extend(new_config.cmd, { '--hostPID', tostring(vim.fn.getpid()) })
table.insert(new_config.cmd, 'DotNet:enablePackageRestore=false')
vim.list_extend(new_config.cmd, { '--encoding', 'utf-8' })
table.insert(new_config.cmd, '--languageserver')
-- Append configuration-dependent command arguments
if new_config.enable_editorconfig_support then
table.insert(new_config.cmd, 'FormattingOptions:EnableEditorConfigSupport=true')
end
if new_config.organize_imports_on_format then
table.insert(new_config.cmd, 'FormattingOptions:OrganizeImports=true')
end
if new_config.enable_ms_build_load_projects_on_demand then
table.insert(new_config.cmd, 'MsBuild:LoadProjectsOnDemand=true')
end
if new_config.enable_roslyn_analyzers then
table.insert(new_config.cmd, 'RoslynExtensionsOptions:EnableAnalyzersSupport=true')
end
if new_config.enable_import_completion then
table.insert(new_config.cmd, 'RoslynExtensionsOptions:EnableImportCompletion=true')
end
if new_config.sdk_include_prereleases then
table.insert(new_config.cmd, 'Sdk:IncludePrereleases=true')
end
if new_config.analyze_open_documents_only then
table.insert(new_config.cmd, 'RoslynExtensionsOptions:AnalyzeOpenDocumentsOnly=true')
end
-- Disable the handling of multiple workspaces in a single instance
new_config.capabilities = vim.deepcopy(new_config.capabilities)
new_config.capabilities.workspace.workspaceFolders = false -- https://github.com/OmniSharp/omnisharp-roslyn/issues/909
end,
init_options = {},
}
}

View file

@ -7,16 +7,16 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true
if not configs.intelephense then if not configs.intelephense then
configs.intelephense = { configs.intelephense = {
default_config = { default_config = {
cmd = { 'intelephense', '--stdio' }; cmd = { 'intelephense', '--stdio' },
filetypes = { 'php' }; filetypes = { 'php' },
root_dir = function(fname) root_dir = function(fname)
return vim.loop.cwd() return vim.loop.cwd()
end; end,
settings = { settings = {
intelephense = { intelephense = {
files = { files = {
maxSize = 1000000; maxSize = 1000000,
}; },
environment = { environment = {
includePaths = { includePaths = {
"/home/serii/Sites/wordpress", "/home/serii/Sites/wordpress",
@ -31,4 +31,3 @@ if not configs.intelephense then
end end
lspconfig.intelephense.setup { capabilities = capabilities } lspconfig.intelephense.setup { capabilities = capabilities }

View file

@ -1,2 +1,2 @@
vim.api.nvim_set_keymap('i', '<C-k>', 'copilot#Accept("<CR>")', {expr = true, silent = true}) -- vim.api.nvim_set_keymap('i', '<C-k>', 'copilot#Accept("<CR>")', {expr = true, silent = true})

10
lua/plugin/formatter.lua Normal file
View file

@ -0,0 +1,10 @@
local formatter = require("conform")
formatter.setup({
formatters_by_ft = {
lua = { "stylua" },
-- Use a sub-list to run only the first available formatter
javascript = { { "prettierd", "prettier" } },
typescript = { { "prettier" } },
},
})

View file

@ -35,6 +35,5 @@ require('gitsigns').setup {
map('n', '<leader>gbf', function() map('n', '<leader>gbf', function()
vim.fn.system('smerge blame ' .. vim.fn.expand('%') .. ' ' .. vim.fn.line('.')) vim.fn.system('smerge blame ' .. vim.fn.expand('%') .. ' ' .. vim.fn.line('.'))
end) end)
end end
} }

12
lua/plugin/neo-tree.lua Normal file
View file

@ -0,0 +1,12 @@
local neotree = require("neo-tree")
neotree.setup({
buffers = {
follow_current_file = {
enabled = true,
},
},
window = {
position = "right",
},
})

View file

@ -1,5 +1,68 @@
local telescope = require('telescope')
local builtin = require('telescope.builtin') local builtin = require('telescope.builtin')
telescope.setup({
defaults = {
vimgrep_arguments = {
"rg",
"-L",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case",
},
prompt_prefix = "",
selection_caret = " ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.55,
results_width = 0.8,
},
vertical = {
mirror = false,
},
width = 0.87,
height = 0.80,
preview_cutoff = 120,
},
file_sorter = require("telescope.sorters").get_fuzzy_file,
file_ignore_patterns = { "node_modules", ".git", ".angular" },
generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
path_display = { "truncate" },
winblend = 0,
border = {},
borderchars = { "", "", "", "", "", "", "", "" },
color_devicons = true,
set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,
file_previewer = require("telescope.previewers").vim_buffer_cat.new,
grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new,
-- Developer configurations: Not meant for general override
buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
mappings = {
n = { ["q"] = require("telescope.actions").close },
},
},
extensions_list = { "themes", "terms", "fzf" },
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
})
vim.keymap.set('n', '<leader>ff', builtin.find_files, {}) vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>jj', builtin.buffers, {}) vim.keymap.set('n', '<leader>jj', builtin.buffers, {})

View file

@ -11,7 +11,8 @@ configs.setup({
"heex", "heex",
"javascript", "javascript",
"html", "html",
"php", "css",
"typescript",
}, },
sync_install = false, sync_install = false,
highlight = { enable = true }, highlight = { enable = true },

View file

@ -19,6 +19,12 @@ require("lazy").setup({
tag = '0.1.2', tag = '0.1.2',
dependencies = { 'nvim-lua/plenary.nvim' } dependencies = { 'nvim-lua/plenary.nvim' }
}, },
-- themes
{ 'gruvbox-community/gruvbox' },
-- gitsigns
{ 'lewis6991/gitsigns.nvim' },
-- tpope commentary
{ 'tpope/vim-commentary' },
{ {
"nvim-treesitter/nvim-treesitter", build = ":TSUpdate" "nvim-treesitter/nvim-treesitter", build = ":TSUpdate"
@ -36,22 +42,38 @@ require("lazy").setup({
end, end,
}, },
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional { 'williamboman/mason-lspconfig.nvim' }, -- Optional
-- formatter
{
'stevearc/conform.nvim',
opts = {},
},
-- Autocompletion -- Autocompletion
{ 'hrsh7th/nvim-cmp' }, -- Required { 'hrsh7th/nvim-cmp' }, -- Required
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required { 'hrsh7th/cmp-nvim-lsp' }, -- Required
{ 'L3MON4D3/LuaSnip' }, -- Required { 'L3MON4D3/LuaSnip' }, -- Required
{ 'nvim-cmp' }, { 'nvim-cmp' },
{ 'github/copilot.vim' }, -- { 'github/copilot.vim' },
{ 'mhinz/vim-startify' }, { 'mhinz/vim-startify' },
-- themes
{ 'gruvbox-community/gruvbox' },
-- gitsigns
{ 'lewis6991/gitsigns.nvim' },
-- tpope commentary
{ 'tpope/vim-commentary' },
} }
}, },
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
},
lazy = true,
},
{
"kdheepak/lazygit.nvim",
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
},
}, opts) }, opts)

View file

@ -1,4 +1,5 @@
vim.keymap.set("n", "<leader>;;", vim.cmd.Ex) vim.keymap.set("n", "<leader>;;", ":Neotree toggle<CR>")
vim.keymap.set("n", "<leader>kk", ":Neotree reveal<CR>")
-- jk to escape -- jk to escape
vim.keymap.set("i", "jk", "<Esc>") vim.keymap.set("i", "jk", "<Esc>")

View file

@ -14,7 +14,7 @@ vim.opt.list = true
vim.opt.swapfile = false vim.opt.swapfile = false
vim.opt.backup = false vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" -- vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true vim.opt.undofile = true
vim.opt.hlsearch = true vim.opt.hlsearch = true