Commit 6d2f91bf authored by Oskar Lappi's avatar Oskar Lappi
Browse files

Configured omnifunc for lsp

parent f52ea975
......@@ -41,33 +41,32 @@ if !empty($NVIM_PLUGIN_BOOTSTRAP)
finish
endif
" vim-rooter project patterns
lua << EOF
-- default opts
local opts = { noremap = true, silent = true }
-- vim-rooter
vim.g.rooter_patterns = { '.git', 'src', 'include' }
-- Fugitive (git integration)
local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap('n', '<leader>gb', ':Git blame<CR>', opts)
-- Telescope (finder)
local telescope = require('telescope')
-- require('telescope').load_extension 'fzf'
local opts = { noremap = true, silent = true}
vim.api.nvim_set_keymap('n', '<leader>fg', [[<cmd>lua require('telescope.builtin').live_grep()<CR>]], opts)
vim.api.nvim_set_keymap('n', '<leader>fb', [[<cmd>lua require('telescope.builtin').buffers()<CR>]], opts)
vim.api.nvim_set_keymap('n', '<leader>fh', [[<cmd>lua require('telescope.builtin').help_tags()<CR>]], opts)
vim.g.rooter_patterns = { '.git', 'src', 'include' }
function find_files_in_project()
local opts = { noremap = true, silent = true, cwd = vim.fn.FindRootDirectory() }
require('telescope.builtin').find_files(opts)
end
vim.api.nvim_set_keymap('n', '<leader>ff', [[<cmd>lua find_files_in_project()<CR>]], opts)
vim.api.nvim_set_keymap('n', '<leader>fg', [[<cmd>lua require('telescope.builtin').live_grep()<CR>]], opts)
vim.api.nvim_set_keymap('n', '<leader>fb', [[<cmd>lua require('telescope.builtin').buffers()<CR>]], opts)
vim.api.nvim_set_keymap('n', '<leader>fh', [[<cmd>lua require('telescope.builtin').help_tags()<CR>]], opts)
-- Treesitter
-- TODO: configure folds etc.
......@@ -77,7 +76,10 @@ lua << EOF
-- LSP
-- TODO: think about integrating with telescope (https://github.com/nvim-telescope/telescope.nvim#neovim-lsp-pickers)
local on_attach = function(client, bufnr)
local opts = { noremap = true, silent = true}
-- use omnifunc for completion (<C-x><C-o>)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- omnifunc is mutually exclusive with nvim-cmp
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
......@@ -100,14 +102,16 @@ lua << EOF
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fmt', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
-- These have dependencies
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>so', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts)
-- immediate quickfix
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>q', [[<cmd>lua require('lsp_code_action_no_menu')()<CR>]], opts)
-- telescope
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>so', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts)
-- TODO: check if <leader>gr works for references. If not, think about using telescope.
end
require('lspconfig').clangd.setup{
on_attach = on_attach
}
EOF
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment