diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 4bae69c..f1ec82a 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,35 +1,35 @@ local lsp_attach = function(client, buf) - vim.api.nvim_set_option_value("formatexpr", "v:lua.vim.lsp.formatexpr()", { buf = buf }) - vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = buf }) - vim.api.nvim_set_option_value("tagfunc", "v:lua.vim.lsp.tagfunc", { buf = buf }) + vim.api.nvim_set_option_value("formatexpr", "v:lua.vim.lsp.formatexpr()", { buf = buf }) + vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = buf }) + vim.api.nvim_set_option_value("tagfunc", "v:lua.vim.lsp.tagfunc", { buf = buf }) - vim.lsp.inlay_hint.enable(true, nil) + vim.lsp.inlay_hint.enable(true, nil) - local bufopts = { noremap = true, silent = true, buffer = buf } - local wk = require("which-key") + local bufopts = { noremap = true, silent = true, buffer = buf } + local wk = require("which-key") - local diag_next = function() - vim.diagnostic.jump({ count = 1, float = true }) - end + local diag_next = function() + vim.diagnostic.jump({ count = 1, float = true }) + end - local diag_prev = function() - vim.diagnostic.jump({ count = -1, float = true }) - end + local diag_prev = function() + vim.diagnostic.jump({ count = -1, float = true }) + end - wk.add({ - { '', require("telescope.builtin").diagnostics, bufopts, desc = "Show diagnostics under cursor" }, - { 'e', vim.diagnostic.open_float, bufopts, desc = "Show diagnostics in buffer" }, - { '[d', diag_prev, bufopts }, - { ']d', diag_next, bufopts }, + wk.add({ + { '', require("telescope.builtin").diagnostics, bufopts, desc = "Show diagnostics under cursor" }, + { 'e', vim.diagnostic.open_float, bufopts, desc = "Show diagnostics in buffer" }, + { '[d', diag_prev, bufopts }, + { ']d', diag_next, bufopts }, - { 'gD', vim.lsp.buf.declaration, bufopts, desc = "Go to declaration" }, - { 'gd', vim.lsp.buf.definition, bufopts, desc = "Go to definition" }, - { 'gi', vim.lsp.buf.implementation, bufopts, desc = "Go to implementation" }, - { '', vim.lsp.buf.signature_help, bufopts, desc = "Show signature" }, - { 'rn', vim.lsp.buf.rename, bufopts, desc = "Rename" }, - { 'ca', vim.lsp.buf.code_action, bufopts, desc = "Show code actions" }, - { 'gr', require("telescope.builtin").lsp_references, bufopts, desc = "Shwo references" }, - }) + { 'gD', vim.lsp.buf.declaration, bufopts, desc = "Go to declaration" }, + { 'gd', vim.lsp.buf.definition, bufopts, desc = "Go to definition" }, + { 'gi', vim.lsp.buf.implementation, bufopts, desc = "Go to implementation" }, + { '', vim.lsp.buf.signature_help, bufopts, desc = "Show signature" }, + { 'rn', vim.lsp.buf.rename, bufopts, desc = "Rename" }, + { 'ca', vim.lsp.buf.code_action, bufopts, desc = "Show code actions" }, + { 'gr', require("telescope.builtin").lsp_references, bufopts, desc = "Shwo references" }, + }) end local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/packages/codelldb/extension/") @@ -37,446 +37,451 @@ local codelldb_path = mason_path .. "adapter/codelldb" local liblldb_path = mason_path .. "lldb/lib/liblldb.so" if vim.fn.has "mac" == 1 then - liblldb_path = mason_path .. "lldb/lib/liblldb.dylib" + liblldb_path = mason_path .. "lldb/lib/liblldb.dylib" end return { - -- lsp - { - 'williamboman/mason.nvim', - lazy = true, - config = true - }, - { - 'williamboman/mason-lspconfig.nvim', - config = true - --config = function() - -- ensure_installed = { "lua_ls", "ts_ls", "gopls", "rust_analyzer", "bashls", "sqlls", "html", "cssls", - -- "tailwindcss", "phpactor", "julials", "glsl_analyzer", "wgsl_analyzer", "emmet_language_server", "zls" } - --end - }, - { - 'neovim/nvim-lspconfig', - config = function() - local capabilities = require('cmp_nvim_lsp').default_capabilities() + -- lsp + { + 'williamboman/mason.nvim', + lazy = true, + config = true + }, + { + 'williamboman/mason-lspconfig.nvim', + config = true + --config = function() + -- ensure_installed = { "lua_ls", "ts_ls", "gopls", "rust_analyzer", "bashls", "sqlls", "html", "cssls", + -- "tailwindcss", "phpactor", "julials", "glsl_analyzer", "wgsl_analyzer", "emmet_language_server", "zls" } + --end + }, + { + 'neovim/nvim-lspconfig', + config = function() + local capabilities = require('cmp_nvim_lsp').default_capabilities() - vim.lsp.config('lua_ls', { - capabilities = capabilities, - root_markers = { '.git' }, - 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' } - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - } - }, - on_attach = lsp_attach - }) - vim.lsp.config('ts_ls', { - capabilities = capabilities, - on_attach = lsp_attach, - filetypes = { "typescript", "javascript", "typescriptreact", "javascriptreact", "javascript.jsx", "typescript.tsx", "vue" }, - init_options = { - plugins = { { - name = '@vue/typescript-plugin', - location = vim.fn.expand(vim.fn.stdpath "data" .. - "/mason/packages/vue-language-server/node_modules/@vue/language-server"), - languages = { 'vue' }, - configNamespace = 'typescript' - } } - } - }) - vim.lsp.config('vue_ls', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('gopls', { - capabilities = capabilities, - on_attach = lsp_attach - }) - --vim.lsp.config(rust_analyzer.setup { - -- capabilities = capabilities, - -- on_attach = lsp_attach - --}) - vim.lsp.config('bashls', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('sqlls', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('html', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('cssls', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('tailwindcss', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('phpactor', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('julials', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('wgsl_analyzer', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('glsl_analyzer', { - capabilities = capabilities, - on_attach = lsp_attach - }) - vim.lsp.config('emmet_ls', { - filetypes = { "css", "html" }, - -- Read more about this options in the [vscode docs](https://code.visualstudio.com/docs/editor/emmet#_emmet-configuration). - -- **Note:** only the options listed in the table are supported. - init_options = { - ---@type table - includeLanguages = {}, - --- @type string[] - excludeLanguages = {}, - --- @type string[] - extensionsPath = {}, - --- @type table [Emmet Docs](https://docs.emmet.io/customization/preferences/) - preferences = {}, - --- @type boolean Defaults to `true` - showAbbreviationSuggestions = true, - --- @type "always" | "never" Defaults to `"always"` - showExpandedAbbreviation = "always", - --- @type boolean Defaults to `false` - showSuggestionsAsSnippets = false, - --- @type table [Emmet Docs](https://docs.emmet.io/customization/syntax-profiles/) - syntaxProfiles = {}, - --- @type table [Emmet Docs](https://docs.emmet.io/customization/snippets/#variables) - variables = {}, - }, - }) - -- vim.lsp.config('ccls.setup { - -- capabilities = capabilities, - -- on_attach = lsp_attach, - -- }) - vim.lsp.config('clangd', { - capabilities = capabilities, - on_attach = lsp_attach, + vim.lsp.config('lua_ls', { + capabilities = capabilities, + root_markers = { '.git' }, + 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' } + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + } + }, + on_attach = lsp_attach + }) + vim.lsp.config('ts_ls', { + capabilities = capabilities, + on_attach = lsp_attach, + filetypes = { "typescript", "javascript", "typescriptreact", "javascriptreact", "javascript.jsx", "typescript.tsx", "vue" }, + root_markers = { 'tsconfig.json', 'jsconfig.json', 'package.json', '.git' }, + init_options = { + plugins = { { + name = '@vue/typescript-plugin', + location = vim.fn.expand(vim.fn.stdpath "data" .. + "/mason/packages/vue-language-server/node_modules/@vue/language-server"), + languages = { 'vue' }, + configNamespace = 'typescript' + } } + } + }) + vim.lsp.config('vue_ls', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('denols', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('gopls', { + capabilities = capabilities, + on_attach = lsp_attach + }) + --vim.lsp.config(rust_analyzer.setup { + -- capabilities = capabilities, + -- on_attach = lsp_attach + --}) + vim.lsp.config('bashls', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('sqlls', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('html', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('cssls', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('tailwindcss', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('phpactor', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('julials', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('wgsl_analyzer', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('glsl_analyzer', { + capabilities = capabilities, + on_attach = lsp_attach + }) + vim.lsp.config('emmet_ls', { + filetypes = { "css", "html" }, + -- Read more about this options in the [vscode docs](https://code.visualstudio.com/docs/editor/emmet#_emmet-configuration). + -- **Note:** only the options listed in the table are supported. + init_options = { + ---@type table + includeLanguages = {}, + --- @type string[] + excludeLanguages = {}, + --- @type string[] + extensionsPath = {}, + --- @type table [Emmet Docs](https://docs.emmet.io/customization/preferences/) + preferences = {}, + --- @type boolean Defaults to `true` + showAbbreviationSuggestions = true, + --- @type "always" | "never" Defaults to `"always"` + showExpandedAbbreviation = "always", + --- @type boolean Defaults to `false` + showSuggestionsAsSnippets = false, + --- @type table [Emmet Docs](https://docs.emmet.io/customization/syntax-profiles/) + syntaxProfiles = {}, + --- @type table [Emmet Docs](https://docs.emmet.io/customization/snippets/#variables) + variables = {}, + }, + }) + -- vim.lsp.config('ccls.setup { + -- capabilities = capabilities, + -- on_attach = lsp_attach, + -- }) + vim.lsp.config('clangd', { + capabilities = capabilities, + on_attach = lsp_attach, filetypes = { 'c', 'cpp', 'h' }, - cmd = { "clangd", '--background-index', '--clang-tidy' } - }) - vim.lsp.enable({ 'ts_ls', 'vue_ls', 'clangd' }) - end - }, - { - 'mrcjkb/rustaceanvim', - version = "^6", - lazy = false, - ft = { "rust" }, - config = function() - local rust_analyzer_path = vim.fn.trim(vim.fn.system("rustup which rust-analyzer")) - if rust_analyzer_path == "" then - vim.notify("rust-analyzer not found! Install it with: rustup component add rust-analyzer", - vim.log.levels.ERROR) - return - end - vim.g.rustaceanvim = { - server = { - cmd = { rust_analyzer_path }, - on_attach = lsp_attach, - settings = { - -- rust-analyzer language server configuration - ["rust-analyzer"] = { - rustfmt = { - extraArgs = { "+nightly" }, - }, - cargo = { - loadOutDirsFromCheck = true, - runBuildScripts = true, - }, - -- Add clippy lints for Rust. - checkOnSave = true, - -- TODO this breaks diagnostics, look into what can be done - -- procMacro = { - -- enable = true, - -- ignored = { - -- ["async-trait"] = { "async_trait" }, - -- ["napi-derive"] = { "napi" }, - -- ["async-recursion"] = { "async_recursion" }, - -- }, - -- }, - }, - }, - } - } - end - }, - { - 'mfussenegger/nvim-jdtls', - ft = { "java" }, - config = function() - local home = os.getenv('HOME') - local jdtls = require('jdtls') - local capabilities = require('cmp_nvim_lsp').default_capabilities() - local root_markers = { 'gradlew', 'mvnw', 'git' } - local root_dir = require('jdtls.setup').find_root(root_markers) - local workspace_folder = home .. "/.local/share/eclipse/" .. vim.fn.fnamemodify(root_dir, ":p:h:t") - local config = { - flags = { - debounce_text_changes = 80, - }, - capabilities = capabilities, - on_attach = lsp_attach, -- We pass our on_attach keybindings to the configuration map - root_dir = root_dir, -- Set the root directory to our found root_marker - -- here you can configure eclipse.jdt.ls specific settings - -- these are defined by the eclipse.jdt.ls project and will be passed to eclipse when starting. - -- see https://github.com/eclipse/eclipse.jdt.ls/wiki/running-the-java-ls-server-from-the-command-line#initialize-request - -- for a list of options - settings = { - java = { - format = { - settings = { - -- use google java style guidelines for formatting - -- to use, make sure to download the file from https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml - -- and place it in the ~/.local/share/eclipse directory - -- url = "/.local/share/eclipse/eclipse-java-google-style.xml", - -- profile = "googlestyle", - }, - }, - signaturehelp = { enabled = true }, - contentprovider = { preferred = 'fernflower' }, -- use fernflower to decompile library code - -- specify any completion options - completion = { - favoritestaticmembers = { - -- "org.hamcrest.matcherassert.assertthat", - -- "org.hamcrest.matchers.*", - -- "org.hamcrest.corematchers.*", - -- "org.junit.jupiter.api.assertions.*", - -- "java.util.objects.requirenonnull", - -- "java.util.objects.requirenonnullelse", - -- "org.mockito.mockito.*" - }, - filteredtypes = { - -- "com.sun.*", - -- "io.micrometer.shaded.*", - -- "java.awt.*", - -- "jdk.*", "sun.*", - }, - }, - -- specify any options for organizing imports - sources = { - organizeimports = { - starthreshold = 9999, - staticstarthreshold = 9999, - }, - }, - -- how code generation should act - codegeneration = { - tostring = { - template = "${object.classname}{${member.name()}=${member.value}, ${othermembers}}" - }, - hashcodeequals = { - usejava7objects = true, - }, - useblocks = true, - }, - -- if you are developing in projects with different java versions, you need - -- to tell eclipse.jdt.ls to use the location of the jdk for your java version - -- see https://github.com/eclipse/eclipse.jdt.ls/wiki/running-the-java-ls-server-from-the-command-line#initialize-request - -- and search for `interface runtimeoption` - -- the `name` is not arbitrary, but must match one of the elements from `enum executionenvironment` in the link above - configuration = { - runtimes = { - { - name = "JavaSE-17", - path = home .. "/.local/share/asdf/installs/java/oracle-17.0.11/", - }, - { - name = "JavaSE-21", - path = home .. "/.local/share/asdf/installs/java/oracle-21.0.2/", - }, - { - name = "JavaSE-1.8", - path = home .. "/.local/share/asdf/installs/java/adoptopenjdk-8.0.412+8/" - }, - } - } - } - }, - -- cmd is the command that starts the language server. whatever is placed - -- here is what is passed to the command line to execute jdtls. - -- note that eclipse.jdt.ls must be started with a java version of 17 or higher - -- see: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line - -- for the full list of options - cmd = { - home .. "/.local/share/asdf/installs/java/oracle-21.0.2/bin/java", - '-Declipse.application=org.eclipse.jdt.ls.core.id1', - '-Dosgi.bundles.defaultstartlevel=4', - '-Declipse.product=org.eclipse.jdt.ls.core.product', - '-Dlog.protocol=true', - '-Dlog.level=all', - '-Xmx4G', - '--add-modules=ALL-SYSTEM', - '--add-opens', 'java.base/java.util=ALL-UNNAMED', - '--add-opens', 'java.base/java.lang=ALL-UNNAMED', - -- if you use lombok, download the lombok jar and place it in ~/.local/share/eclipse - '-javaagent:' .. home .. '/.local/share/nvim/mason/packages/jdtls/lombok.jar', + cmd = { "clangd", '--background-index', '--clang-tidy' } + }) + vim.lsp.enable({ 'ts_ls', 'vue_ls', 'clangd' }) + end + }, + { + 'mrcjkb/rustaceanvim', + version = "^6", + lazy = false, + ft = { "rust" }, + config = function() + local rust_analyzer_path = vim.fn.trim(vim.fn.system("rustup which rust-analyzer")) + if rust_analyzer_path == "" then + vim.notify("rust-analyzer not found! Install it with: rustup component add rust-analyzer", + vim.log.levels.ERROR) + return + end + vim.g.rustaceanvim = { + server = { + cmd = { rust_analyzer_path }, + on_attach = lsp_attach, + settings = { + -- rust-analyzer language server configuration + ["rust-analyzer"] = { + rustfmt = { + extraArgs = { "+nightly" }, + }, + cargo = { + loadOutDirsFromCheck = true, + runBuildScripts = true, + }, + -- Add clippy lints for Rust. + checkOnSave = true, + -- TODO this breaks diagnostics, look into what can be done + -- procMacro = { + -- enable = true, + -- ignored = { + -- ["async-trait"] = { "async_trait" }, + -- ["napi-derive"] = { "napi" }, + -- ["async-recursion"] = { "async_recursion" }, + -- }, + -- }, + }, + }, + } + } + end + }, + { + 'mfussenegger/nvim-jdtls', + ft = { "java" }, + config = function() + local home = os.getenv('HOME') + local jdtls = require('jdtls') + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local root_markers = { 'gradlew', 'mvnw', 'git' } + local root_dir = require('jdtls.setup').find_root(root_markers) + local workspace_folder = home .. "/.local/share/eclipse/" .. vim.fn.fnamemodify(root_dir, ":p:h:t") + local config = { + flags = { + debounce_text_changes = 80, + }, + capabilities = capabilities, + on_attach = lsp_attach, -- We pass our on_attach keybindings to the configuration map + root_dir = root_dir, -- Set the root directory to our found root_marker + -- here you can configure eclipse.jdt.ls specific settings + -- these are defined by the eclipse.jdt.ls project and will be passed to eclipse when starting. + -- see https://github.com/eclipse/eclipse.jdt.ls/wiki/running-the-java-ls-server-from-the-command-line#initialize-request + -- for a list of options + settings = { + java = { + format = { + settings = { + -- use google java style guidelines for formatting + -- to use, make sure to download the file from https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml + -- and place it in the ~/.local/share/eclipse directory + -- url = "/.local/share/eclipse/eclipse-java-google-style.xml", + -- profile = "googlestyle", + }, + }, + signaturehelp = { enabled = true }, + contentprovider = { preferred = 'fernflower' }, -- use fernflower to decompile library code + -- specify any completion options + completion = { + favoritestaticmembers = { + -- "org.hamcrest.matcherassert.assertthat", + -- "org.hamcrest.matchers.*", + -- "org.hamcrest.corematchers.*", + -- "org.junit.jupiter.api.assertions.*", + -- "java.util.objects.requirenonnull", + -- "java.util.objects.requirenonnullelse", + -- "org.mockito.mockito.*" + }, + filteredtypes = { + -- "com.sun.*", + -- "io.micrometer.shaded.*", + -- "java.awt.*", + -- "jdk.*", "sun.*", + }, + }, + -- specify any options for organizing imports + sources = { + organizeimports = { + starthreshold = 9999, + staticstarthreshold = 9999, + }, + }, + -- how code generation should act + codegeneration = { + tostring = { + template = "${object.classname}{${member.name()}=${member.value}, ${othermembers}}" + }, + hashcodeequals = { + usejava7objects = true, + }, + useblocks = true, + }, + -- if you are developing in projects with different java versions, you need + -- to tell eclipse.jdt.ls to use the location of the jdk for your java version + -- see https://github.com/eclipse/eclipse.jdt.ls/wiki/running-the-java-ls-server-from-the-command-line#initialize-request + -- and search for `interface runtimeoption` + -- the `name` is not arbitrary, but must match one of the elements from `enum executionenvironment` in the link above + configuration = { + runtimes = { + { + name = "JavaSE-17", + path = home .. "/.local/share/asdf/installs/java/oracle-17.0.11/", + }, + { + name = "JavaSE-21", + path = home .. "/.local/share/asdf/installs/java/oracle-21.0.2/", + }, + { + name = "JavaSE-1.8", + path = home .. "/.local/share/asdf/installs/java/adoptopenjdk-8.0.412+8/" + }, + } + } + } + }, + -- cmd is the command that starts the language server. whatever is placed + -- here is what is passed to the command line to execute jdtls. + -- note that eclipse.jdt.ls must be started with a java version of 17 or higher + -- see: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line + -- for the full list of options + cmd = { + home .. "/.local/share/asdf/installs/java/oracle-21.0.2/bin/java", + '-Declipse.application=org.eclipse.jdt.ls.core.id1', + '-Dosgi.bundles.defaultstartlevel=4', + '-Declipse.product=org.eclipse.jdt.ls.core.product', + '-Dlog.protocol=true', + '-Dlog.level=all', + '-Xmx4G', + '--add-modules=ALL-SYSTEM', + '--add-opens', 'java.base/java.util=ALL-UNNAMED', + '--add-opens', 'java.base/java.lang=ALL-UNNAMED', + -- if you use lombok, download the lombok jar and place it in ~/.local/share/eclipse + '-javaagent:' .. home .. '/.local/share/nvim/mason/packages/jdtls/lombok.jar', - -- the jar file is located where jdtls was installed. this will need to be updated - -- to the location where you installed jdtls - '-jar', vim.fn.glob( - home .. - '/.local/share/nvim/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_*.jar'), + -- the jar file is located where jdtls was installed. this will need to be updated + -- to the location where you installed jdtls + '-jar', vim.fn.glob( + home .. + '/.local/share/nvim/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_*.jar'), - -- the configuration for jdtls is also placed where jdtls was installed. this will - -- need to be updated depending on your environment - '-configuration', home .. '/.local/share/nvim/mason/packages/jdtls/config_linux', + -- the configuration for jdtls is also placed where jdtls was installed. this will + -- need to be updated depending on your environment + '-configuration', home .. '/.local/share/nvim/mason/packages/jdtls/config_linux', - -- use the workspace_folder defined above to store data for this project - '-data', workspace_folder, - }, - } + -- use the workspace_folder defined above to store data for this project + '-data', workspace_folder, + }, + } - jdtls.start_or_attach(config) - end - }, - { - "Kurren123/mssql.nvim", - opts = { - -- optional - keymap_prefix = "m" - }, - -- optional - dependencies = { "folke/which-key.nvim" } - }, - { 'onsails/lspkind-nvim' }, -- pictograms replace (?) with lspsaga - { - 'j-hui/fidget.nvim', - config = true - }, -- show lsp status - -- completion - { - 'hrsh7th/nvim-cmp', - config = function() - local cmp = require('cmp') - local lspkind = require('lspkind') + jdtls.start_or_attach(config) + end + }, + { + "Kurren123/mssql.nvim", + opts = { + -- optional + keymap_prefix = "m" + }, + -- optional + dependencies = { "folke/which-key.nvim" } + }, + { 'onsails/lspkind-nvim' }, -- pictograms replace (?) with lspsaga + { + 'j-hui/fidget.nvim', + config = true + }, -- show lsp status + -- completion + { + 'hrsh7th/nvim-cmp', + config = function() + local cmp = require('cmp') + local lspkind = require('lspkind') - vim.opt.shortmess:append 'c' + vim.opt.shortmess:append 'c' - cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, - [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true - }), - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [''] = cmp.mapping.confirm({ select = true }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lua' }, - { name = 'nvim_lsp' }, - { name = 'path' }, - { name = 'luasnip' }, - { name = 'nvim_lsp_signature_help' }, - }, { - { name = 'buffer', keyword_length = 5 }, - { name = 'minuet' }, - }), - performance = { - -- It is recommended to increase the timeout duration due to - -- the typically slower response speed of LLMs compared to - -- other completion sources. This is not needed when you only - -- need manual completion. - fetching_timeout = 2000, - }, - formatting = { - format = lspkind.cmp_format { - with_text = true, - menu = { - buffer = "[buf]", - nvim_lsp = "[LSP]", - nvim_lua = "[api]", - path = "[path]", - luasnip = "[snip]", - minuet = "[llm]", - } - } - } - }) + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true + }), + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lua' }, + { name = 'nvim_lsp' }, + { name = 'path' }, + { name = 'luasnip' }, + { name = 'nvim_lsp_signature_help' }, + }, { + { name = 'buffer', keyword_length = 5 }, + { name = 'minuet' }, + }), + performance = { + -- It is recommended to increase the timeout duration due to + -- the typically slower response speed of LLMs compared to + -- other completion sources. This is not needed when you only + -- need manual completion. + fetching_timeout = 2000, + }, + formatting = { + format = lspkind.cmp_format { + with_text = true, + menu = { + buffer = "[buf]", + nvim_lsp = "[LSP]", + nvim_lua = "[api]", + path = "[path]", + luasnip = "[snip]", + minuet = "[llm]", + } + } + } + }) - -- Use buffer source for `/` (basically search words in buffer) - cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' } - } - }) + -- Use buffer source for `/` (basically search words in buffer) + cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + } + }) - -- Use cmdline & path source for ':' - cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) - }) - end, - event = 'InsertEnter', - dependencies = { - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-nvim-lsp-signature-help', - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', - 'hrsh7th/cmp-nvim-lua', - 'hrsh7th/cmp-cmdline', - 'saadparwaiz1/cmp_luasnip', - } - }, - { - 'L3MON4D3/LuaSnip', - version = "v2.*", - build = "make install_jsregexp", - config = function() - require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) - end - }, - { - 'windwp/nvim-autopairs', - config = true - }, - { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }, - }, + -- Use cmdline & path source for ':' + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + end, + event = 'InsertEnter', + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-nvim-lsp-signature-help', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-nvim-lua', + 'hrsh7th/cmp-cmdline', + 'saadparwaiz1/cmp_luasnip', + } + }, + { + 'L3MON4D3/LuaSnip', + version = "v2.*", + build = "make install_jsregexp", + config = function() + require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) + end + }, + { + 'windwp/nvim-autopairs', + config = true + }, + { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + }, } diff --git a/lua/plugins/writing.lua b/lua/plugins/writing.lua index 615ad98..5b516cc 100644 --- a/lua/plugins/writing.lua +++ b/lua/plugins/writing.lua @@ -1,12 +1,15 @@ return { - -- writing - { - 'vimwiki/vimwiki', - ft = { 'md', 'wiki', 'tex' }, - config = function() - vim.g.vimwiki_list = { { path = '~/Documents/Buch/wiki', syntax = 'markdown', ext = '.md' } } - end - }, - --{ 'junegunn/goyo.vim' }, -- try replacing these 2 at some point because they don't work that well anymore - --{ 'junegunn/limelight.vim' }, + -- writing + { + 'vimwiki/vimwiki', + ft = { 'md', 'wiki', 'tex' }, + config = function() + vim.g.vimwiki_list = { + { path = '~/Documents/Buch/wiki', syntax = 'markdown', ext = '.md' }, + { path = '~/Notes', syntax = 'markdown', ext = '.md' }, + } + end + }, + --{ 'junegunn/goyo.vim' }, -- try replacing these 2 at some point because they don't work that well anymore + --{ 'junegunn/limelight.vim' }, }