From 5ee962ee3cf8003648b6dbc284c6e189f2c01681 Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Mon, 23 Jan 2023 14:47:01 +0100 Subject: [PATCH] Add missing files --- lua/conf/treesitter.lua | 16 ++++++++++++++++ lua/lsp/installer.lua | 8 ++++++++ lua/lsp/metals.lua | 19 +++++++++++++++++++ lua/lsp/typescript.lua | 13 +++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 lua/conf/treesitter.lua create mode 100644 lua/lsp/installer.lua create mode 100644 lua/lsp/metals.lua create mode 100644 lua/lsp/typescript.lua diff --git a/lua/conf/treesitter.lua b/lua/conf/treesitter.lua new file mode 100644 index 0000000..4d9554a --- /dev/null +++ b/lua/conf/treesitter.lua @@ -0,0 +1,16 @@ +require'nvim-treesitter.configs'.setup { + ensure_installed = { "typescript" }, + sync_install = true, + auto_install = true, + highlight = { + enable = true, + -- 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, + }, + indent = { + enable = true + }, +} diff --git a/lua/lsp/installer.lua b/lua/lsp/installer.lua new file mode 100644 index 0000000..6214255 --- /dev/null +++ b/lua/lsp/installer.lua @@ -0,0 +1,8 @@ +local status, lsp_installer = pcall(require,"nvim-lsp-installer") +if (not status) then return end + +lsp_installer.on_server_ready(function(server) + local opts = {} + + server:setup(opts) +end) diff --git a/lua/lsp/metals.lua b/lua/lsp/metals.lua new file mode 100644 index 0000000..f141b72 --- /dev/null +++ b/lua/lsp/metals.lua @@ -0,0 +1,19 @@ +local status, metals = pcall(require, "metals") +if (not status) then return function() end end + +return function(on_attach) + metals_config = metals.bare_config() + metals_config.init_options.statusBarProvider = "on" + metals_config.settings = { showImplicitArguments = true } + metals_config.on_attach = on_attach + metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities() + + + vim.cmd [[augroup lsp]] + vim.cmd [[au!]] + vim.cmd([[autocmd FileType scala setlocal omnifunc=v:lua.vim.lsp.omnifunc]]) + vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach(metals_config)]] + vim.cmd [[augroup end]] + + return metals_config +end diff --git a/lua/lsp/typescript.lua b/lua/lsp/typescript.lua new file mode 100644 index 0000000..560a7fe --- /dev/null +++ b/lua/lsp/typescript.lua @@ -0,0 +1,13 @@ +local status, nvim_lsp = pcall(require, "lspconfig") +if (not status) then return function() end end + +return function(on_attach) + local protocol = require('vim.lsp.protocol') + + -- TypeScript + nvim_lsp.tsserver.setup { + on_attach = on_attach, + filetypes = { "typescript", "typescriptreact", "typescript.tsx" }, + cmd = { "typescript-language-server", "--stdio" } + } +end