require('buildcmd') local tbuiltin = require('telescope.builtin') vim.g.mapleader = ' ' --space local function project_files() local opts = {} local ok = pcall(tbuiltin.git_files, opts) if not ok then tbuiltin.find_files(opts) end end -- 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', project_files, opts) vim.keymap.set('n', 'fb', 'Telescope buffers', opts) vim.keymap.set('n', 'bb', save_all_and_build, 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.keymap.set('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) 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) 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 } } -- honestly don't need this, telemetry is a big yikes. lspconfig.sumneko_lua.setup{ on_attach = on_attach, flags = lsp_flags, 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), }, -- Do not send telemetry data containing a randomized but unique identifier telemetry = { enable = false, }, }, }, } lspconfig.rust_analyzer.setup{ on_attach = on_attach, }