extract neovim
This commit is contained in:
parent
be3aecc343
commit
a93abe6f04
13 changed files with 113 additions and 101 deletions
28
lib/programs/home/neovim/config.lua
Normal file
28
lib/programs/home/neovim/config.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
vim.o.relativenumber = true
|
||||
vim.o.signcolumn = 'yes'
|
||||
vim.o.tabstop = 2
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.expandtab = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.hlsearch = false
|
||||
vim.o.scrolloff = 4
|
||||
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
||||
vim.keymap.set("x", "p", "\"_dP")
|
||||
|
||||
vim.keymap.set("n", "<leader>y", "\"+y")
|
||||
vim.keymap.set("v", "<leader>y", "\"+y")
|
||||
|
||||
-- Global mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
|
||||
|
||||
vim.keymap.set('v', '<C-c>', '"+y')
|
||||
vim.keymap.set('i', '<C-v>', '<escape>"+p')
|
||||
51
lib/programs/home/neovim/default.nix
Normal file
51
lib/programs/home/neovim/default.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
extraLuaConfig = ''
|
||||
${builtins.readFile ./config.lua}
|
||||
'';
|
||||
extraPackages = with pkgs; [
|
||||
nodePackages_latest.typescript-language-server
|
||||
vscode-langservers-extracted
|
||||
gopls
|
||||
nil
|
||||
];
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
vim-surround
|
||||
vim-commentary
|
||||
{
|
||||
plugin = telescope-nvim;
|
||||
type = "lua";
|
||||
config = ''
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
|
||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
||||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = nvim-lspconfig;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./lspconfig.lua;
|
||||
}
|
||||
firenvim
|
||||
];
|
||||
};
|
||||
|
||||
programs.vscode = {
|
||||
extensions = [ pkgs.vscode-extensions.asvetliakov.vscode-neovim ];
|
||||
userSettings = {
|
||||
"vscode-neovim.neovimExecutablePaths.linux" = "${pkgs.neovim}/bin/nvim";
|
||||
"extensions.experimental.affinity" = {
|
||||
"asvetliakov.vscode-neovim" = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
48
lib/programs/home/neovim/lspconfig.lua
Normal file
48
lib/programs/home/neovim/lspconfig.lua
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
-- Setup language servers.
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
lspconfig.tsserver.setup {
|
||||
on_attach = function(client)
|
||||
client.server_capabilities.documentFormattingProvider = false
|
||||
end
|
||||
}
|
||||
|
||||
lspconfig.eslint.setup {
|
||||
on_attach = function(client)
|
||||
client.server_capabilities.documentFormattingProvider = true
|
||||
end
|
||||
}
|
||||
|
||||
lspconfig.gopls.setup {}
|
||||
lspconfig.nil_ls.setup {}
|
||||
|
||||
-- Use LspAttach autocommand to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||
callback = function(ev)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||
vim.keymap.set('n', '<leader>f', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, opts)
|
||||
end,
|
||||
})
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
};
|
||||
|
||||
home-manager.users.${user}.imports = [
|
||||
(import ./swaylock.nix)
|
||||
(import ./swayidle.nix)
|
||||
(import ./home/swaylock.nix)
|
||||
(import ./home/swayidle.nix)
|
||||
{
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
};
|
||||
|
||||
home-manager.users.${user}.imports = [
|
||||
(import ./swaylock.nix)
|
||||
(import ./home/swaylock.nix)
|
||||
{
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue