diff --git a/nvim/init.vim b/nvim/init.vim index 2c709c1..ff80c30 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -8,6 +8,7 @@ set expandtab set shiftwidth=4 set autoindent set completeopt=menu,menuone,noselect + filetype plugin on lua require('plugins') diff --git a/nvim/lua/haskell-config.lua b/nvim/lua/haskell-config.lua new file mode 100644 index 0000000..98acd7a --- /dev/null +++ b/nvim/lua/haskell-config.lua @@ -0,0 +1,21 @@ +local ht = require('haskell-tools') +local def_opts = { noremap = true, silent = true, } +ht.setup { + hls = { + on_attach = function(client, bufnr) + local opts = vim.tbl_extend('keep', def_opts, { buffer = bufnr, }) + -- haskell-language-server relies heavily on codeLenses, + -- so auto-refresh (see advanced configuration) is enabled by default + vim.keymap.set('n', 'ca', vim.lsp.codelens.run, opts) + vim.keymap.set('n', 'hs', ht.hoogle.hoogle_signature, opts) + end, + }, +} +-- Suggested keymaps that do not depend on haskell-language-server +-- Toggle a GHCi repl for the current package +vim.keymap.set('n', 'rr', ht.repl.toggle, def_opts) +-- Toggle a GHCi repl for the current buffer +vim.keymap.set('n', 'rf', function() + ht.repl.toggle(vim.api.nvim_buf_get_name(0)) +end, def_opts) +vim.keymap.set('n', 'rq', ht.repl.quit, def_opts) diff --git a/nvim/lua/nvim-lsp-config.lua b/nvim/lua/nvim-lsp-config.lua index 89a6366..3bef19a 100644 --- a/nvim/lua/nvim-lsp-config.lua +++ b/nvim/lua/nvim-lsp-config.lua @@ -41,3 +41,5 @@ require('lspconfig')['pyright'].setup { on_attach = on_attach, flags = lsp_flags, } + +require'lspconfig'.clangd.setup{} diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index e33e407..9989d61 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -34,14 +34,22 @@ return require('packer').startup(function(use) use 'nvim-treesitter/nvim-treesitter' use 'neovim/nvim-lspconfig' -- Configurations for Nvim LSP + + -- (batch)commenting tool use 'preservim/nerdcommenter' use "lukas-reineke/indent-blankline.nvim" + -- themeing use "EdenEast/nightfox.nvim" - use "lukas-reineke/virt-column.nvim" + -- thin bar indicating an arbitray character limit + use "lukas-reineke/virt-column.nvim" + -- fuzzy file finder + use 'nvim-telescope/telescope.nvim' + + -- autocompletion engine, plugs into lsp use { "hrsh7th/nvim-cmp", requires = { @@ -53,6 +61,7 @@ return require('packer').startup(function(use) } } + -- renders images in nvim use { 'samodostal/image.nvim', requires = { @@ -61,12 +70,23 @@ return require('packer').startup(function(use) }, } + use { + 'mrcjkb/haskell-tools.nvim', + requires = { + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope.nvim' + }, + branch = '1.x.x', + } + + use 'dense-analysis/ale' + vim.cmd([[ augroup packer_user_config autocmd! autocmd BufWritePost plugins.lua source | PackerCompile augroup end - ]]) + ]]) -- init configs require('nightfox-config') @@ -74,9 +94,14 @@ return require('packer').startup(function(use) require('nvim-tree-config') require('nvim-cmp-config') require('image-config') + require('haskell-config') + require('telescope-config') require('lualine').setup() require("virt-column").setup() + + vim.g.ale_linters = { haskell = {'hlint', 'hdevtools', 'hfmt'} } + if packer_bootstrap then require('packer').sync() end diff --git a/nvim/lua/telescope-config.lua b/nvim/lua/telescope-config.lua new file mode 100644 index 0000000..00dc1b5 --- /dev/null +++ b/nvim/lua/telescope-config.lua @@ -0,0 +1,8 @@ +require('telescope').setup() + +local builtin = require('telescope.builtin') + +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fh', builtin.help_tags, {})