diff --git a/lazy-lock.json b/lazy-lock.json index e327410..f73ac50 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,18 +1,22 @@ { - "LuaSnip": { "branch": "master", "commit": "45a4e899ca8f54936fe32ead6bba65f2a8d42e12" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, - "copilot.vim": { "branch": "release", "commit": "a4a6d6b3f9e284e7f5c849619e06cd228cad8abd" }, - "gitsigns.nvim": { "branch": "main", "commit": "5a04466685008f29c71fa5ec25d421deb1c83fea" }, - "gruvbox": { "branch": "master", "commit": "2b5b1f777f0583ffb39086d6c16f39e6e37459c0" }, - "lazy.nvim": { "branch": "main", "commit": "14d76aac4bd3ff07c1fca074c210f28f766a931e" }, - "lsp-zero.nvim": { "branch": "v2.x", "commit": "0b4c5966884e80c5100c04790defe1fd72d918aa" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "796008869e67ef27a5aa5ac44c08ce2a60b89f55" }, - "mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, - "nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" }, - "nvim-lspconfig": { "branch": "master", "commit": "b88b227cf8d61d6e43dd23d8a39b8b2897bc17e5" }, - "nvim-treesitter": { "branch": "master", "commit": "a51236f068547487ed34c3a32d9a0b3bf793afa7" }, - "plenary.nvim": { "branch": "master", "commit": "bda256fab0eb66a15e8190937e417e6a14ee5d72" }, + "LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "conform.nvim": { "branch": "master", "commit": "c4b2efb8aee4af0ef179a9b49ba401de3c4ef5d2" }, + "gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" }, + "gruvbox": { "branch": "master", "commit": "e1f033164931797a67b68089995c8078415f9d7d" }, + "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "lazygit.nvim": { "branch": "main", "commit": "1e08e3f5ac1152339690140e61a4a32b3bdc7de5" }, + "lsp-zero.nvim": { "branch": "v2.x", "commit": "84771a9ec7f7d1fecec8bb84c0c97d811e4b08ec" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" }, + "mason.nvim": { "branch": "main", "commit": "a09da6ac634926a299dd439da08bdb547a8ca011" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" }, + "nui.nvim": { "branch": "main", "commit": "80445d015d2b5f9af0d9e8bce63d303bc86eda8a" }, + "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" }, "vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" }, - "vim-startify": { "branch": "master", "commit": "81e36c352a8deea54df5ec1e2f4348685569bed2" } + "vim-startify": { "branch": "master", "commit": "4e089dffdad46f3f5593f34362d530e8fe823dcf" } } \ No newline at end of file diff --git a/lua/lsp.lua b/lua/lsp.lua index 26ab2bd..0d4fea6 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,39 +1,9 @@ local lsp = require('lsp-zero').preset({}) local lspconfig = require('lspconfig') local loaded_configs = require('lspconfig.configs') +local conform = require('conform') -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 on_attach = function(_, bufnr) local opts = { buffer = bufnr, remap = false, } -- Global mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions @@ -55,11 +25,51 @@ lsp.on_attach(function(_, bufnr) end, opts) vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, opts) -end) + vim.keymap.set('n', 'L', ':EslintFixAll') + + vim.keymap.set('n', '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() -- You need to setup `cmp` after lsp-zero @@ -69,7 +79,7 @@ local cmp_action = require('lsp-zero').cmp_action() cmp.setup({ mapping = { -- `Enter` key to confirm completion - [''] = cmp.mapping.confirm({select = false}), + [''] = cmp.mapping.confirm({ select = false }), -- Ctrl+Space to trigger completion menu [''] = cmp.mapping.complete(), @@ -79,6 +89,3 @@ cmp.setup({ [''] = cmp_action.luasnip_jump_backward(), } }) - --- Use LspAttach autocommand to only map the following keys --- after the language server attaches to the current buffer diff --git a/lua/lspconf/angular.lua b/lua/lspconf/angular.lua new file mode 100644 index 0000000..fb86039 --- /dev/null +++ b/lua/lspconf/angular.lua @@ -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 +}) diff --git a/lua/lspconf/csharp.lua b/lua/lspconf/csharp.lua new file mode 100644 index 0000000..a47be71 --- /dev/null +++ b/lua/lspconf/csharp.lua @@ -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 = {}, + } +} diff --git a/lua/lspconf/php.lua b/lua/lspconf/php.lua index 1b2f294..cc67e03 100644 --- a/lua/lspconf/php.lua +++ b/lua/lspconf/php.lua @@ -7,16 +7,16 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true if not configs.intelephense then configs.intelephense = { default_config = { - cmd = { 'intelephense', '--stdio' }; - filetypes = { 'php' }; + cmd = { 'intelephense', '--stdio' }, + filetypes = { 'php' }, root_dir = function(fname) return vim.loop.cwd() - end; + end, settings = { intelephense = { files = { - maxSize = 1000000; - }; + maxSize = 1000000, + }, environment = { includePaths = { "/home/serii/Sites/wordpress", @@ -31,4 +31,3 @@ if not configs.intelephense then end lspconfig.intelephense.setup { capabilities = capabilities } - diff --git a/lua/plugin/copilot.lua b/lua/plugin/copilot.lua index 91c0de2..798c31b 100644 --- a/lua/plugin/copilot.lua +++ b/lua/plugin/copilot.lua @@ -1,2 +1,2 @@ -vim.api.nvim_set_keymap('i', '', 'copilot#Accept("")', {expr = true, silent = true}) +-- vim.api.nvim_set_keymap('i', '', 'copilot#Accept("")', {expr = true, silent = true}) diff --git a/lua/plugin/formatter.lua b/lua/plugin/formatter.lua new file mode 100644 index 0000000..48f5e6d --- /dev/null +++ b/lua/plugin/formatter.lua @@ -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" } }, + }, +}) diff --git a/lua/plugin/gitsigns.lua b/lua/plugin/gitsigns.lua index ba1eae0..05bec4c 100644 --- a/lua/plugin/gitsigns.lua +++ b/lua/plugin/gitsigns.lua @@ -1,40 +1,39 @@ require('gitsigns').setup { - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- map leader gj to go to next hunk - map('n', 'gj', function() - if vim.wo.diff then return ']c' end - vim.schedule(function() gs.next_hunk() end) - return '' - end, { expr = true }) - - -- map leader gk to go to previous hunk - map('n', 'gk', function() - if vim.wo.diff then return '[c' end - vim.schedule(function() gs.prev_hunk() end) - return '' - end, { expr = true }) - - map('n', 'gp', gs.preview_hunk) - map('n', 'gs', gs.stage_hunk) - map('v', 'gs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) - map('n', 'gu', gs.reset_hunk) - - -- nnoremap glf :!smerge log % - map('n', 'glf', function() - vim.fn.system('smerge log ' .. vim.fn.expand('%')) - end) - -- nnoremap gbf :!smerge blame % line('.') - map('n', 'gbf', function() - vim.fn.system('smerge blame ' .. vim.fn.expand('%') .. ' ' .. vim.fn.line('.')) - end) + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) end + + -- map leader gj to go to next hunk + map('n', 'gj', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '' + end, { expr = true }) + + -- map leader gk to go to previous hunk + map('n', 'gk', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '' + end, { expr = true }) + + map('n', 'gp', gs.preview_hunk) + map('n', 'gs', gs.stage_hunk) + map('v', 'gs', function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end) + map('n', 'gu', gs.reset_hunk) + + -- nnoremap glf :!smerge log % + map('n', 'glf', function() + vim.fn.system('smerge log ' .. vim.fn.expand('%')) + end) + -- nnoremap gbf :!smerge blame % line('.') + map('n', 'gbf', function() + vim.fn.system('smerge blame ' .. vim.fn.expand('%') .. ' ' .. vim.fn.line('.')) + end) + end } diff --git a/lua/plugin/neo-tree.lua b/lua/plugin/neo-tree.lua new file mode 100644 index 0000000..8719510 --- /dev/null +++ b/lua/plugin/neo-tree.lua @@ -0,0 +1,12 @@ +local neotree = require("neo-tree") + +neotree.setup({ + buffers = { + follow_current_file = { + enabled = true, + }, + }, + window = { + position = "right", + }, +}) diff --git a/lua/plugin/startify.lua b/lua/plugin/startify.lua index 7040405..a6571aa 100644 --- a/lua/plugin/startify.lua +++ b/lua/plugin/startify.lua @@ -1,6 +1,6 @@ vim.g.startify_session_persistence = 1 vim.g.startify_change_to_dir = 0 vim.g.startify_lists = { - { type = 'sessions', header = { ' Sessions' } }, - { type = 'bookmarks', header = { ' Bookmarks' } }, + { type = 'sessions', header = { ' Sessions' } }, + { type = 'bookmarks', header = { ' Bookmarks' } }, } diff --git a/lua/plugin/telescope.lua b/lua/plugin/telescope.lua index e032b39..0b00d89 100644 --- a/lua/plugin/telescope.lua +++ b/lua/plugin/telescope.lua @@ -1,5 +1,68 @@ +local telescope = require('telescope') 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', 'ff', builtin.find_files, {}) vim.keymap.set('n', 'fg', builtin.live_grep, {}) vim.keymap.set('n', 'jj', builtin.buffers, {}) diff --git a/lua/plugin/treesitter.lua b/lua/plugin/treesitter.lua index cca0085..cca4c57 100644 --- a/lua/plugin/treesitter.lua +++ b/lua/plugin/treesitter.lua @@ -1,19 +1,20 @@ local configs = require("nvim-treesitter.configs") configs.setup({ - ensure_installed = { - "c", - "lua", - "vim", - "vimdoc", - "query", - "elixir", - "heex", - "javascript", - "html", - "php", - }, - sync_install = false, - highlight = { enable = true }, - indent = { enable = true }, + ensure_installed = { + "c", + "lua", + "vim", + "vimdoc", + "query", + "elixir", + "heex", + "javascript", + "html", + "css", + "typescript", + }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, }) diff --git a/lua/plugins.lua b/lua/plugins.lua index f7a90fb..fce0ffb 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -19,6 +19,12 @@ require("lazy").setup({ tag = '0.1.2', dependencies = { 'nvim-lua/plenary.nvim' } }, + -- themes + { 'gruvbox-community/gruvbox' }, + -- gitsigns + { 'lewis6991/gitsigns.nvim' }, + -- tpope commentary + { 'tpope/vim-commentary' }, { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" @@ -36,22 +42,38 @@ require("lazy").setup({ end, }, { 'williamboman/mason-lspconfig.nvim' }, -- Optional - + -- formatter + { + 'stevearc/conform.nvim', + opts = {}, + }, -- Autocompletion { 'hrsh7th/nvim-cmp' }, -- Required { 'hrsh7th/cmp-nvim-lsp' }, -- Required { 'L3MON4D3/LuaSnip' }, -- Required { 'nvim-cmp' }, - { 'github/copilot.vim' }, + -- { 'github/copilot.vim' }, { '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) diff --git a/lua/remap.lua b/lua/remap.lua index 2269117..f3aa2dc 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -1,4 +1,5 @@ -vim.keymap.set("n", ";;", vim.cmd.Ex) +vim.keymap.set("n", ";;", ":Neotree toggle") +vim.keymap.set("n", "kk", ":Neotree reveal") -- jk to escape vim.keymap.set("i", "jk", "") diff --git a/lua/set.lua b/lua/set.lua index 9078812..3bd9f18 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -14,7 +14,7 @@ vim.opt.list = true vim.opt.swapfile = 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.hlsearch = true