Add flake.nix #1
4 changed files with 78 additions and 64 deletions
19
_config/nvim/lsp/luals.lua
Normal file
19
_config/nvim/lsp/luals.lua
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
return {
|
||||||
|
-- Command and arguments to start the server.
|
||||||
|
cmd = { 'lua-language-server' },
|
||||||
|
-- Filetypes to automatically attach to.
|
||||||
|
filetypes = { 'lua' },
|
||||||
|
-- Sets the "workspace" to the directory where any of these files is found.
|
||||||
|
-- Files that share a root directory will reuse the LSP server connection.
|
||||||
|
-- Nested lists indicate equal priority, see |vim.lsp.Config|.
|
||||||
|
root_markers = { { '.luarc.json', '.luarc.jsonc' }, '.git' },
|
||||||
|
-- Specific settings to send to the server. The schema is server-defined.
|
||||||
|
-- Example: https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
version = 'LuaJIT',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,49 +1,58 @@
|
||||||
vim.diagnostic.config({ virtual_text = true })
|
vim.lsp.enable('ts_ls')
|
||||||
|
vim.lsp.enable('luals')
|
||||||
|
vim.lsp.enable('clangd')
|
||||||
|
|
||||||
local lsp = require('lsp-zero').preset({})
|
-- LSP keymaps to mimic lsp-zero's defaults
|
||||||
|
-- Source for lsp-zero defaults: see note at bottom
|
||||||
|
|
||||||
lsp.on_attach(function(client, bufnr)
|
-- Create the autocommand once
|
||||||
-- see :help lsp-zero-keybindings
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
-- to learn the available actions
|
group = vim.api.nvim_create_augroup('UserLspKeymaps', { clear = true }),
|
||||||
lsp.default_keymaps({buffer = bufnr})
|
callback = function(ev)
|
||||||
end)
|
local buf = ev.buf
|
||||||
|
|
||||||
-- " (Optional) Configure lua language server for neovim
|
local function map(mode, lhs, rhs, desc)
|
||||||
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
vim.keymap.set(mode, lhs, rhs, { buffer = buf, silent = true, noremap = true, desc = desc })
|
||||||
|
end
|
||||||
|
|
||||||
-- You need to setup `cmp` after lsp-zero
|
-- Hover
|
||||||
local cmp = require('cmp')
|
map('n', 'K', vim.lsp.buf.hover, 'LSP: Hover')
|
||||||
local cmp_action = require('lsp-zero').cmp_action()
|
|
||||||
|
|
||||||
cmp.setup({
|
-- Go to...
|
||||||
mapping = {
|
map('n', 'gd', vim.lsp.buf.definition, 'LSP: Go to Definition')
|
||||||
-- `Enter` key to confirm completion
|
map('n', 'gD', vim.lsp.buf.declaration, 'LSP: Go to Declaration')
|
||||||
['<CR>'] = cmp.mapping.confirm({select = false}),
|
map('n', 'gi', vim.lsp.buf.implementation, 'LSP: Go to Implementation')
|
||||||
|
map('n', 'go', vim.lsp.buf.type_definition, 'LSP: Go to Type Definition')
|
||||||
|
map('n', 'gr', vim.lsp.buf.references, 'LSP: List References')
|
||||||
|
|
||||||
-- Ctrl+Space to trigger completion menu
|
-- Signatures
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
map('n', 'gs', vim.lsp.buf.signature_help, 'LSP: Signature Help')
|
||||||
|
|
||||||
-- Navigate between snippet placeholder
|
-- Rename / Actions / Format (normal + visual)
|
||||||
['<C-f>'] = cmp_action.luasnip_jump_forward(),
|
map('n', '<F2>', vim.lsp.buf.rename, 'LSP: Rename')
|
||||||
['<C-b>'] = cmp_action.luasnip_jump_backward(),
|
map({ 'n', 'x' }, '<F3>', function()
|
||||||
}
|
vim.lsp.buf.format({ async = false })
|
||||||
})
|
end, 'LSP: Format')
|
||||||
|
map({ 'n', 'x' }, '<F4>', vim.lsp.buf.code_action, 'LSP: Code Action')
|
||||||
lsp.ensure_installed({
|
|
||||||
'ts_ls',
|
|
||||||
})
|
|
||||||
|
|
||||||
local null_ls = require('null-ls')
|
|
||||||
local null_opts = lsp.build_options('null-ls', {})
|
|
||||||
|
|
||||||
null_ls.setup({
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
null_opts.on_attach(client, bufnr)
|
|
||||||
--- you can add more stuff here if you need it
|
|
||||||
end,
|
end,
|
||||||
sources = {
|
|
||||||
null_ls.builtins.formatting.black,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
lsp.setup()
|
require("mason").setup()
|
||||||
|
require("mason-lspconfig").setup {
|
||||||
|
ensure_installed = { "rust_analyzer" },
|
||||||
|
}
|
||||||
|
|
||||||
|
local cmp = require('cmp')
|
||||||
|
local cmp_nvim_lsp = require('cmp_nvim_lsp')
|
||||||
|
|
||||||
|
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||||
|
cmp.setup({
|
||||||
|
sources = {
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp_nvim_lsp.default_capabilities()
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
local rt = require("rust-tools")
|
require('rust-tools').setup({
|
||||||
|
|
||||||
rt.setup({
|
|
||||||
server = {
|
server = {
|
||||||
on_attach = function(_, bufnr)
|
on_attach = function(_, bufnr)
|
||||||
-- Hover actions
|
-- Example keymaps
|
||||||
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
vim.keymap.set("n", "<C-space>", require("rust-tools").hover_actions.hover_actions, { buffer = bufnr })
|
||||||
|
vim.keymap.set("n", "<Leader>a", require("rust-tools").code_action_group.code_action_group,
|
||||||
-- Code action groups
|
{ buffer = bufnr })
|
||||||
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,14 +4,7 @@ Plug 'tpope/vim-fugitive'
|
||||||
Plug 'vim-syntastic/syntastic'
|
Plug 'vim-syntastic/syntastic'
|
||||||
Plug 'junegunn/fzf.vim'
|
Plug 'junegunn/fzf.vim'
|
||||||
Plug 'tpope/vim-surround'
|
Plug 'tpope/vim-surround'
|
||||||
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
|
|
||||||
" Plug 'deoplete-plugins/deoplete-clang'
|
|
||||||
" Plug 'deoplete-plugins/deoplete-jedi'
|
|
||||||
" Plug 'deoplete-plugins/deoplete-go', { 'do': 'make'}
|
|
||||||
" Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install tern'}
|
|
||||||
" Plug 'tbodt/deoplete-tabnine', { 'do': './install.sh' }
|
|
||||||
Plug 'mg979/vim-visual-multi'
|
Plug 'mg979/vim-visual-multi'
|
||||||
" Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
|
||||||
" Plug 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' }
|
" Plug 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' }
|
||||||
Plug 'luochen1990/rainbow'
|
Plug 'luochen1990/rainbow'
|
||||||
" Plug 'wlangstroth/vim-racket'
|
" Plug 'wlangstroth/vim-racket'
|
||||||
|
@ -24,18 +17,14 @@ Plug 'neovim/nvim-lspconfig'
|
||||||
Plug 'williamboman/mason.nvim'
|
Plug 'williamboman/mason.nvim'
|
||||||
Plug 'williamboman/mason-lspconfig.nvim'
|
Plug 'williamboman/mason-lspconfig.nvim'
|
||||||
|
|
||||||
Plug 'nvim-lua/plenary.nvim'
|
|
||||||
Plug 'nvimtools/none-ls.nvim'
|
|
||||||
|
|
||||||
" Autocompletion
|
" Autocompletion
|
||||||
Plug 'hrsh7th/nvim-cmp'
|
Plug 'hrsh7th/nvim-cmp'
|
||||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||||
Plug 'L3MON4D3/LuaSnip'
|
Plug 'L3MON4D3/LuaSnip'
|
||||||
|
|
||||||
Plug 'VonHeikemen/lsp-zero.nvim', {'branch': 'v2.x'}
|
|
||||||
|
|
||||||
Plug 'simrat39/rust-tools.nvim'
|
Plug 'simrat39/rust-tools.nvim'
|
||||||
|
|
||||||
|
" Debugging
|
||||||
Plug 'mfussenegger/nvim-dap'
|
Plug 'mfussenegger/nvim-dap'
|
||||||
Plug 'rcarriga/nvim-dap-ui'
|
Plug 'rcarriga/nvim-dap-ui'
|
||||||
Plug 'nvim-neotest/nvim-nio'
|
Plug 'nvim-neotest/nvim-nio'
|
||||||
|
|
Loading…
Add table
Reference in a new issue