require('buildcmd') local tbuiltin = require('telescope.builtin') vim.g.mapleader = ' ' --space -- Mappings, mostly taken from nvim-lspconfig local opts = { noremap=true, silent=true } vim.keymap.set('n', 'q', vim.diagnostic.open_float, opts) vim.keymap.set('n', 'e', 'Ex', opts) vim.keymap.set('n', 'ff', tbuiltin.find_files, opts) vim.keymap.set('n', 'fb', 'Telescope buffers', opts) vim.keymap.set('n', 'bb', save_all_and_build, opts) vim.keymap.set('n', 'br', save_all_and_buildnrun, opts) -- TODO: get fancy and read the commentstring and user vim.keymap.set('i', '', '// TODO(twig): ', opts) vim.keymap.set('i', '', '// NOTE(twig): ', opts) vim.api.nvim_set_keymap('i', '', '->', opts) --vim.api.nvim_set_keymap('i', '', '->', opts) -- This is horrendous on windows, can't use nvim for almost a minute! vim.keymap.set('n', 'K', '') vim.keymap.set('n', 'fs', 'Telescope grep_string', opts) vim.keymap.set('n', 'ss', 'Telescope spell_suggest', opts) vim.keymap.set('n', 't', 'Telescope', opts) local on_attach = function(client, bufnr) client.server_capabilities.semanticTokensProvider = nil vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings local bufopts = { noremap=true, silent=true, buffer=bufnr } -- Replace these with telescope equivalent vim.keymap.set('n', 'rb', vim.lsp.buf.declaration, bufopts) vim.keymap.set('n', 'rd', vim.lsp.buf.definition, bufopts) vim.keymap.set('n', 'rf', tbuiltin.lsp_references, bufopts) vim.keymap.set('n', 'rs', tbuiltin.lsp_document_symbols, bufopts) vim.keymap.set('n', 'rr', vim.lsp.buf.rename, bufopts) --vim.keymap.set('i', '', v:lua.vim.lsp.omnifunc, bufopts) end --local lsp_flags = { -- debounce_text_changes = 150, --wtf is this --} --local lspconfig = require('lspconfig'); --lspconfig.zls.setup { -- on_attach = on_attach, -- flags = lsp_flags, --} --lspconfig.gopls.setup{ -- on_attach = on_attach, -- flags = lsp_flags, --} --lspconfig.clangd.setup{ -- on_attach = on_attach, -- flags = lsp_flags, -- handlers = { -- ["textDocument/publishDiagnostics"] = function(err, result, ctx, config) -- end -- } --} --lspconfig.rust_analyzer.setup{ -- on_attach = on_attach, --} --lspconfig.ols.setup{ -- on_attach = on_attach, --} --lspconfig.pylsp.setup{ -- on_attach = on_attach, -- flags = lsp_flags, --} --lspconfig.gdscript.setup{ -- on_attach = on_attach, -- flags = lsp_flags, --} local lsps = { { "clangd", { cmd = { 'clangd', '--clang-tidy', }, root_markers = { '.clangd', 'compile_commands.json' }, filetypes = { 'c', 'cpp', 'h' }, on_attach = on_attach, } }, { "luals", { cmd = { 'lua-language-server', }, root_markers = { '.git', 'init.lua' }, filetypes = { 'lua' }, on_attach = on_attach, } }, { "python-lsp", { cmd = { 'pylsp' }, root_markers = { '.git' }, filetype = { 'py' }, on_attach = on_attach, } } } for _, lsp in pairs(lsps) do local name, config = lsp[1], lsp[2] vim.lsp.enable(name) if config then vim.lsp.config(name, config) end end