diff --git a/nvim/init.lua b/nvim/init.lua index 1a82bc2..9f9d714 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -137,10 +137,10 @@ map('n', 'v', '"+p') map('n', 'rv', ':source $MYVIMRC') -- insert mode mapping -map('i', '', 'b') -map('i', '', 'l') -map('i', '', 'j') -map('i', '', 'k') +--map('i', '', 'b') +--map('i', '', 'l') +--map('i', '', 'j') +--map('i', '', 'k') map('n', '', '') map('i', '', '') diff --git a/nvim/lua/config/lsp_servers/yamlls.lua b/nvim/lua/config/lsp_servers/yamlls.lua deleted file mode 100644 index 44c8186..0000000 --- a/nvim/lua/config/lsp_servers/yamlls.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - filetypes = { 'yaml', 'yml' }, - settings = { - yaml = { - schemas = { - ['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*', - Kubernetes = { '/*k8s.yaml', '/*k8s.yml' }, - --['https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.18.0-standalone-strict/all.json'] = '/*.k8s.yaml', - }, - }, - }, -} diff --git a/nvim/lua/config/nvim-lsp-installer.lua b/nvim/lua/config/nvim-lsp-installer.lua deleted file mode 100644 index 4d183b9..0000000 --- a/nvim/lua/config/nvim-lsp-installer.lua +++ /dev/null @@ -1,160 +0,0 @@ -local lsp = vim.lsp -local api = vim.api -local cmd = vim.cmd - -local lsp_installer = require('nvim-lsp-installer') --- Include the servers you want to have installed by default below -local servers = { - 'bashls', - 'pylsp', - 'yamlls', - 'eslint', - 'jsonls', - 'sumneko_lua', - 'rust_analyzer', - 'clangd', - 'gopls', - 'tsserver', - 'prosemd_lsp', -} - -for _, name in pairs(servers) do - local server_is_found, server = lsp_installer.get_server(name) - if server_is_found and not server:is_installed() then - print('Installing ' .. name) - server:install() - end -end - --- lspconfig && lspinstaller -local on_attach = function(client, bufnr) - local function buf_set_keymap(...) - api.nvim_buf_set_keymap(bufnr, ...) - end - local function buf_set_option(...) - api.nvim_buf_set_option(bufnr, ...) - end - --require "lsp_signature".on_attach() - - -- Enable completion triggered by - --buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - local opts = { noremap = true, silent = true } - -- See `:help vim.lsp.*` for documentation on any of the below functions - buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - buf_set_keymap('n', 'gr', 'Telescope lsp_references', opts) - buf_set_keymap('n', 'gd', 'Telescope lsp_definitions', opts) - buf_set_keymap('n', 'go', 'Telescope lsp_document_symbols', opts) - buf_set_keymap('n', 'gO', 'Telescope lsp_workspace_symbols', opts) - --buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) - buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) - --buf_set_keymap('i', 'f', 'lua vim.lsp.buf.formatting()', opts) - - if client.resolved_capabilities.document_formatting then - vim.cmd([[ - augroup Format - au! * - au BufWritePre lua vim.lsp.buf.formatting_sync(nil, 1000) - augroup END - ]]) - end -end - -local capabilities = lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) - --- Register a handler that will be called for all installed servers. --- Alternatively, you may also register handlers on specific server instances instead (see example below). -lsp_installer.on_server_ready(function(server) - local opts = { - on_attach = on_attach, - capabilities = capabilities, - flags = { - debounce_text_changes = 150, - }, - } - - if server.name == 'sumneko_lua' then - local luadev = require('lua-dev').setup({ - lspconfig = { - settings = { - Lua = { - workspace = { - checkThirdParty = false, - }, - }, - }, - }, - }) - opts = vim.tbl_deep_extend('force', opts, luadev) - end - - if server.name == 'yamlls' then - --local yamlls_opts = { - --settings = { - --yaml = { - --filetypes = { 'yaml', 'yml' }, - --schemaStore = { - --enable = true, - --url = 'https://www.schemastore.org/api/json/catalog.json', - --}, - --validate = false, - --schemas = { - --['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*', - --kubernetes = '/*.k8s.yaml', - --}, - --}, - --}, - --} - local conf = require(string.format('config.lsp_servers.%s', server.name)) - opts = vim.tbl_deep_extend('force', opts, conf) - end - if server.name == 'rust_analyzer' then - -- Initialize the LSP via rust-tools instead - require('rust-tools').setup({ - -- The "server" property provided in rust-tools setup function are the - -- settings rust-tools will provide to lspconfig during init. -- - -- We merge the necessary settings from nvim-lsp-installer (server:get_default_options()) - -- with the user's own settings (opts). - server = vim.tbl_deep_extend('force', server:get_default_options(), opts), - }) - server:attach_buffers() - -- Only if standalone support is needed - --require('rust-tools').start_standalone_if_required() - else - -- (optional) Customize the options passed to the server - -- if server.name == "tsserver" then - -- opts.root_dir = function() ... end - -- end - - -- This setup() function is exactly the same as lspconfig's setup function. - -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md - server:setup(opts) - end -end) - -local null_ls = require('null-ls') -null_ls.setup({ - sources = { - null_ls.builtins.formatting.stylua.with({ - extra_args = { '--config-path', vim.fn.expand('~/.config/stylua.toml') }, - }), - null_ls.builtins.formatting.shfmt, - }, - on_attach = on_attach, -}) diff --git a/nvim/lua/config/nvim-lsp-setup.lua b/nvim/lua/config/nvim-lsp-setup.lua new file mode 100644 index 0000000..4467166 --- /dev/null +++ b/nvim/lua/config/nvim-lsp-setup.lua @@ -0,0 +1,74 @@ +require('nvim-lsp-setup').setup({ + default_mappings = true, + -- Default mappings + -- gD = 'lua vim.lsp.buf.declaration()', + -- gd = 'lua vim.lsp.buf.definition()', + -- gt = 'lua vim.lsp.buf.type_definition()', + -- gi = 'lua vim.lsp.buf.implementation()', + -- gr = 'lua vim.lsp.buf.references()', + -- K = 'lua vim.lsp.buf.hover()', + -- [''] = 'lua vim.lsp.buf.signature_help()', + -- ['rn'] = 'lua vim.lsp.buf.rename()', + -- ['ca'] = 'lua vim.lsp.buf.code_action()', + -- ['f'] = 'lua vim.lsp.buf.formatting()', + -- ['e'] = 'lua vim.lsp.diagnostic.show_line_diagnostics()', + -- ['[d'] = 'lua vim.lsp.diagnostic.goto_prev()', + -- [']d'] = 'lua vim.lsp.diagnostic.goto_next()', + mappings = { + -- Example mappings for telescope pickers + -- gd = 'lua require"telescope.builtin".lsp_definitions()', + -- gi = 'lua require"telescope.builtin".lsp_implementations()', + -- gr = 'lua require"telescope.builtin".lsp_references()', + }, + -- Global on_attach + -- on_attach = function(client, bufnr) { + -- utils.format_on_save(client) + -- }, + servers = { + -- Automatically install lsp server + -- LSP server configuration please see: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + bashls = {}, + yamlls = { + filetypes = { 'yaml', 'yml' }, + settings = { + yaml = { + schemas = { + ['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*', + Kubernetes = { '/*k8s.yaml', '/*k8s.yml' }, + --['https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.18.0-standalone-strict/all.json'] = '/*.k8s.yaml', + }, + }, + }, + }, + eslint = {}, + jsonls = {}, + sumneko_lua = {}, + clangd = {}, + gopls = {}, + tsserver = {}, + prosemd_lsp = {}, + + pylsp = {}, + rust_analyzer = { + settings = { + ['rust-analyzer'] = { + cargo = { + loadOutDirsFromCheck = true, + }, + procMacro = { + enable = true, + }, + }, + }, + }, + -- Setup sumneko_lua with lua-dev + sumneko_lua = require('lua-dev').setup({ + lspconfig = { + on_attach = function(client, _) + -- Disable formatting + require('nvim-lsp-setup.utils').disable_formatting(client) + end, + }, + }), + }, +}) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 274f9c4..393bc1a 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -36,18 +36,6 @@ return require('packer').startup(function(use) }) end, }) - --use({ - --'folke/trouble.nvim', - --config = function() - --require('trouble').setup({}) - --end, - --}) - --use({ - --'sindrets/diffview.nvim', - --config = function() - --require('diffview').setup({}) - --end, - --}) use({ 'lukas-reineke/indent-blankline.nvim', config = function() @@ -175,42 +163,36 @@ return require('packer').startup(function(use) require('config.nvim_hop') end, }) - --use { - --"ray-x/lsp_signature.nvim", - --config = function() - --require "lsp_signature".setup { - --transpancy = 10, - --hint_prefix = "😼", - ---- zindex = 50, - --} - --end - --} use({ 'preservim/tagbar', config = function() require('config.tagbar') end, }) - --use { - --"liuchengxu/vista.vim", - --config = function() - --require "config.vista" - --end - --} -- LANGUAGES use({ - 'neovim/nvim-lspconfig', + 'Junnplus/nvim-lsp-setup', + config = function() + require('config.nvim-lsp-setup') + end, + requires = { + 'neovim/nvim-lspconfig', + 'williamboman/nvim-lsp-installer', + }, }) use({ 'jose-elias-alvarez/null-ls.nvim', }) - use({ - 'williamboman/nvim-lsp-installer', - config = function() - require('config.nvim-lsp-installer') - end, - }) + --use({ + --'neovim/nvim-lspconfig', + --}) + --use({ + --'williamboman/nvim-lsp-installer', + --config = function() + --require('config.nvim-lsp-installer') + --end, + --}) -- k8s use('andrewstuart/vim-kubernetes')