91 lines
3.1 KiB
Lua
91 lines
3.1 KiB
Lua
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', '<leader>q', vim.diagnostic.open_float, opts)
|
|
vim.keymap.set('n', '<leader>e', '<cmd>Ex<CR>', opts)
|
|
vim.keymap.set('n', '<leader>ff', project_files, opts)
|
|
vim.keymap.set('n', '<leader>fb', '<cmd>Telescope buffers<cr>', opts)
|
|
vim.keymap.set('n', '<leader>bb', save_all_and_build, opts)
|
|
-- TODO: get fancy and read the commentstring and user
|
|
vim.keymap.set('i', '<A-t>', '// TODO(twig): ', opts)
|
|
vim.keymap.set('i', '<A-y>', '// NOTE(twig): ', opts)
|
|
--vim.keymap.set('i', '<C-.>', '->', opts)
|
|
vim.api.nvim_set_keymap('i', '<A-.>', '->', opts)
|
|
-- This is horrendous on windows, can't use nvim for almost a minute!
|
|
vim.keymap.set('n', 'K', '')
|
|
vim.keymap.set('n', '<leader>fs', '<cmd>Telescope grep_string<cr>', opts)
|
|
vim.keymap.set('n', '<leader>ss', '<cmd>Telescope spell_suggest<cr>', opts)
|
|
vim.keymap.set('n', '<leader>t', '<cmd>Telescope<cr>', 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', '<leader>rb', vim.lsp.buf.declaration, bufopts)
|
|
vim.keymap.set('n', '<leader>rd', vim.lsp.buf.definition, bufopts)
|
|
vim.keymap.set('n', '<leader>rf', tbuiltin.lsp_references, bufopts)
|
|
vim.keymap.set('n', '<leader>rs', tbuiltin.lsp_document_symbols, bufopts)
|
|
vim.keymap.set('n', '<leader>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,
|
|
}
|