]> git.rmz.io Git - dotfiles.git/commitdiff
Merge remote-tracking branch 'refs/remotes/origin/master'
authorSamir Benmendil <me@rmz.io>
Mon, 24 Oct 2016 08:20:22 +0000 (09:20 +0100)
committerSamir Benmendil <me@rmz.io>
Mon, 24 Oct 2016 08:20:22 +0000 (09:20 +0100)
awesome/bindings.lua
awesome/topbar.lua
awesome/utils.lua
awesome/widgets/network_widget.lua
systemd/user/ssh-agent.service [new file with mode: 0644]
vim/after/plugin/togglelist.vim
vim/ftplugin/cpp.vim
vim/vimrc
vim/ycm_extra_conf.py
zshenv

index c57c87af7766776e20ae35f23e119616b0012715..d21b61606df1cedc3b520e9298541ed4dbc6b28f 100644 (file)
@@ -95,7 +95,9 @@ globalkeys = awful.util.table.join(globalkeys,
     awful.key({ }, "XF86AudioMute",         function () awful.util.spawn("ponymix toggle")     end),
     awful.key({ modkey }, "F10",  function () awful.util.spawn("ponymix toggle")     end),
     awful.key({ modkey }, "F11",  function () awful.util.spawn("ponymix decrease 5") end),
-    awful.key({ modkey }, "F12",  function () awful.util.spawn("ponymix increase 5") end)
+    awful.key({ modkey }, "F12",  function () awful.util.spawn("ponymix increase 5") end),
+    -- Lock
+    awful.key({ modkey, "Control" }, "Escape", function () awful.util.spawn("xautolock -locknow") end)
 )
 
 -- Client keys {{{1
index 7986af062689ae0f357d1f6e3a0e298e2fbc2984..4d5d50546d28b9cae5cc6e6f17143366f610af25 100644 (file)
@@ -91,7 +91,7 @@ for s = 1, screen.count() do
     right_layout:add(separator)
     right_layout:add(require("widgets/awesompd"))
     right_layout:add(require("widgets/volume_widget"))
-    if utils.host == "chronos" then
+    if utils.has_battery() then
         right_layout:add(separator)
         right_layout:add(require("widgets/battery_widget"))
     end
index 0c56131b0b47a90c681fd134530e251888d4440c..0f12be1aab2c6ba50fd5ae8d5efb339c7449c9b0 100644 (file)
@@ -9,6 +9,10 @@ utils.globalkeys = { }
 local host = io.popen("hostname")
 utils.host = host:read("*l")
 
+function utils.is_dir(path)
+    return os.execute(('[ -d "%s" ]'):format(path))
+end
+
 function utils.run_or_kill(prg, cprop, screen)
     if not prg then
         do return nil end
@@ -82,4 +86,8 @@ function utils.globalkeys.append(keys)
     globalkeys = awful.util.table.join(globalkeys, keys)
 end
 
+function utils.has_battery()
+    return utils.is_dir("/sys/class/power_supply/BAT0")
+end
+
 return utils
index 4be69821f9c72f1fc355f65a9fbdcbd0ace2747c..5b562af92a0d5250e1d427c3e0fbe326ffe63eba 100644 (file)
@@ -14,5 +14,8 @@ end
 if utils.host == "sb-arch" then
     widget = net_widget.indicator({interfaces={"enp0s31f6"}, command_mode="newer", font='monospace'})
 end
+if utils.host == "UH-LPT044" then
+    widget = net_widget.wireless({interface="wlp4s0", command_mode="newer", font='monospace'})
+end
 
 return widget
diff --git a/systemd/user/ssh-agent.service b/systemd/user/ssh-agent.service
new file mode 100644 (file)
index 0000000..87d6c04
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=SSH key agent
+
+[Service]
+Type=forking
+Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
+ExecStart=/usr/bin/ssh-agent -a $SSH_AUTH_SOCK
+
+[Install]
+WantedBy=default.target
index 01ba8de23135141363716b216f28ac702a1964ec..dbb06f1ec74dfa8ee2e11ad4739f7b152a07b86a 100644 (file)
@@ -59,9 +59,10 @@ function! s:ToggleUnite()
   UniteResume
 endfunction
 
-nmap <silent> [oq :copen<cr>
-nmap <silent> ]oq :cclose<cr>
-nmap <silent> coq :call <SID>ToggleLocationList()<CR>
-nmap <silent> [ol :lopen<cr>
-nmap <silent> ]ol :lclose<cr>
-nmap <silent> col :call <SID>ToggleQuickfixList()<CR>
+nnoremap <silent> [oq :copen<cr>
+nnoremap <silent> ]oq :cclose<cr>
+nnoremap <silent> coq :call <SID>ToggleQuickfixList()<CR>
+nnoremap <silent> [ol :lopen<cr>
+nnoremap <silent> ]ol :lclose<cr>
+nnoremap <silent> col :call <SID>ToggleLocationList()<CR>
+nnoremap <silent> cop :pclose<CR>
index af391a13f56976ff8d3e2b7c0b40abd6c348bf5b..7631f49a966d5f5268b84e008f1f657ea7cd3a52 100644 (file)
@@ -17,7 +17,7 @@ let b:load_doxygen_syntax = 1
 augroup fswitch
     au BufEnter *.h   let b:fswitchdst  = 'cpp,c'
     au BufEnter *.h   let b:fswitchlocs = 'reg:|include.*|source|'
-    au BufEnter *.cpp let b:fswitchdst  = 'h'
+    au BufEnter *.cpp let b:fswitchdst  = 'hpp,h'
     au BufEnter *.cpp let b:fswitchlocs = 'reg:|source|include/**|'
 augroup END
 
index 636350fbe3c076766d263a126ab905992104370d..47529e3c4152be3ef740ad6b43c02943ae205013 100644 (file)
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -444,9 +444,9 @@ nnoremap zx zMzxzt
 
 map <F1> :ls<CR>:b<space>
 
-" move between windows
-nnoremap <C-L> <C-W>w
-nnoremap <C-H> <C-W>W
+" move between windows (skip previewwindow)
+nnoremap <silent> <C-L> <C-W>w:if &previewwindow \| wincmd w \| endif<CR>
+nnoremap <silent> <C-H> <C-W>W:if &previewwindow \| wincmd W \| endif<CR>
 
 "xterm mouse with middleclick paste
 nnoremap <MiddleMouse> i<MiddleMouse>
@@ -656,7 +656,7 @@ let g:unite_source_grep_max_candidates = 2000
 if executable('ag')
     " Use ag in unite grep source.
     let g:unite_source_grep_command = 'ag'
-    let g:unite_source_grep_default_opts = '--smart-case --vimgrep --hidden --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
+    let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
     let g:unite_source_grep_recursive_opt = ''
 end
 nnoremap <silent> [unite]a :<C-u>Unite grep:.::\12\17<CR>
@@ -665,7 +665,7 @@ command! -nargs=1 Ag Unite grep:.::<args>
 " unite-file_rec {{{3
 if executable('ag')
     " Use ag in unite rec source
-    let g:unite_source_rec_async_command = 'ag --follow --nocolor --nogroup --hidden -g ""'
+    let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
 end
 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
index ac15c2297f5316fdf57ff37e29ffae07cfc694d2..b262265c28b19c1d13e2446bdb42b0800cf34cca 100644 (file)
@@ -1,83 +1,86 @@
-import os
-import shlex
-import subprocess
+from glob import glob
+from os import path
+
 import ycm_core
 
-def FlagsForFile( filename, **kwargs ):
-  client_data = kwargs['client_data']
-  cwd = client_data['getcwd()']
-  # These are the compilation flags that will be used in case there's no
-  # compilation database set (by default, one is not set).
-  flags = [
-  '-Wall',
-  # '-Wextra',
-  # '-Wshadow',
-  # '-Werror',
-  # '-Wc++98-compat',
-  # '-Wno-long-long',
-  # '-Wno-variadic-macros',
-  # '-fexceptions',
-  # '-DNDEBUG',
-  '-std=c++11',
-  '-stdlib=libstdc++',
-  '-x', 'c++',
-  '-I', '.',
-  '-I', './include',
-  ]
-  flags += rospack()
-  relative_to = cwd
-  final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
 
-  return {
-    'flags': final_flags,
-    'do_cache': True
-  }
+def findCompilationDatabaseFolder(dir='.'):
+    dirs = [path.dirname(f) for f in glob(dir + '/**/compile_commands.json',
+                                          recursive=True)]
+    return dirs
+
+
+def generateQtFlags():
+    flags = []
+    for p in glob('/usr/include/qt/*/'):
+        flags += ['-isystem', p]
+    return flags
 
-# This function makes it easy to pull in additional flags from rospack
-def rospack():
-  cmd = ['rospack', 'cflags-only-I']
-  try:
-    out = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE).stdout
-  except:
-    return []
-  line = out.readline()[:-1].split(" ")
-  includes = []
-  for include in line:
-    if include.startswith(os.path.expanduser('~')):
-      includes += ['-I', include]
-    else:
-      includes += ['-isystem', include]
-  return filter(lambda a: a != ' ', includes)
 
+def isHeader(filename):
+    ext = path.splitext(filename)[1]
+    return ext in ['.hpp', '.h']
 
-def DirectoryOfThisScript():
-  return os.path.dirname( os.path.abspath( __file__ ) )
 
-def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
-  if not working_directory:
-    return list( flags )
-  new_flags = []
-  make_next_absolute = False
-  path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
-  for flag in flags:
-    new_flag = flag
+def GetCompilationInfoForFile(database, filename):
+    if isHeader(filename):
+        basename = path.splitext(filename)[0]
+        for ext in ['.cpp', '.c']:
+            cpp_file = basename + ext
+            if path.exists(cpp_file):
+                compilation_info = database.GetCompilationInfoForFile(
+                    cpp_file)
+                if compilation_info.compiler_flags_:
+                    return compilation_info
+        return None
+    return database.GetCompilationInfoForFile(filename)
 
-    if make_next_absolute:
-      make_next_absolute = False
-      if not flag.startswith( '/' ):
-        new_flag = os.path.join( working_directory, flag )
 
-    for path_flag in path_flags:
-      if flag == path_flag:
-        make_next_absolute = True
-        break
+def FlagsForFile(filename, **kwargs):
+    client_data = kwargs['client_data']
+    cwd = client_data['getcwd()']
 
-      if flag.startswith( path_flag ):
-        path = flag[ len( path_flag ): ]
-        new_flag = path_flag + os.path.join( working_directory, path )
-        break
+    extra_flags = [
+        '-Wall',
+        '-Wextra',
+        # '-Wshadow',
+        # '-Werror',
+        # '-Wc++98-compat',
+        # '-Wno-long-long',
+        # '-Wno-variadic-macros',
+        # '-fexceptions',
+        # '-DNDEBUG',
+    ]
 
-    if new_flag:
-      new_flags.append( new_flag )
-  return new_flags
+    folders = findCompilationDatabaseFolder(cwd)
+    if not folders:
+        folder = None
+    else:
+        folder = folders[0]
+        if len(folders) > 1:
+            print("Multiple compilation databases found!")
+            print(folders)
+            print("Selecting first: %s" % (folder))
+
+    if folder:
+        database = ycm_core.CompilationDatabase(folder)
+        compilation_info = GetCompilationInfoForFile(database, filename)
+        if not compilation_info:
+            return None
+        flags = list(compilation_info.compiler_flags_)
+    else:
+        flags = [
+            '-std=c++14',
+            '-stdlib=libstdc++',
+            '-x', 'c++',
+            '-isystem', '/usr/include',
+            '-isystem', '/usr/local/include',
+            '-I', cwd,
+            '-I', cwd + '/include',
+        ]
+        flags = generateQtFlags()
 
+    return {
+        'flags': flags + extra_flags,
+        'do_cache': True
+    }
diff --git a/zshenv b/zshenv
index fb9c7abb28472e4cb5189ce117e944fcb315c354..06037be8e945bc0b563f9ef39a3eaa06e4bb71e0 100644 (file)
--- a/zshenv
+++ b/zshenv
@@ -42,3 +42,7 @@ export GNUPGHOME="$XDG_CONFIG_HOME/gnupg"
 
 # pass
 export PASSWORD_STORE_DIR="$XDG_DATA_HOME/pass"
+
+# SSH Agent
+export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
+